有一个大的矩阵,大致可以分为3到4块(指的是对角线),每块的维数是不确定的,所以大矩阵的维数也是不确定的!!在程序执行的过程才可以知道每一块的维数,最终要把大的矩阵搭建起来!!不知道我说的意思大家明不明白!!请问大家有什么好的方法!!谢谢!!
#include<iostream.h>
double *EMGD_H;
const int GS=10;
class generator
{
public:
//generator();
void Setcanshu(double Td011,double Tq011,double Td022,double Tq022,double D1,double M1,int Mnumber1);
void GetEMGD_H1();
void GetEMGD_H2();
void GetEMGD_H3();
void GetEMGD_H4();
int Getnum(){return Mnumber;}
//~generator();
private:
double Td01,Tq01,Td02,Tq02;
double D,M;
int Mnumber;
};
void generator::Setcanshu(double Td011,double Tq011,double Td022,double Tq022,double D1,double M1,int Mnumber1)
{
Td01=Td011;
Tq01=Tq011;
Td02=Td022;
Tq02=Tq022;
D=D1;
M=M1;
Mnumber=Mnumber1;
}
void generator::GetEMGD_H1()
{
EMGD_H=new double[Mnumber*Mnumber];
EMGD_H[0]=-1/Td01;
}
void generator::GetEMGD_H2()
{
EMGD_H=new double[Mnumber*Mnumber];
EMGD_H[0]=-1/Td01;
EMGD_H[1]=0;
EMGD_H[2]=0;
EMGD_H[3]=-1/Tq01;
}
void generator::GetEMGD_H3()
{
EMGD_H=new double[Mnumber*Mnumber];
EMGD_H[0]=-1/Td01;
EMGD_H[1]=0;
EMGD_H[2]=0;
EMGD_H[3]=1/Td02-1/Td01;
EMGD_H[4]=-1/Td02;
EMGD_H[5]=0;
EMGD_H[6]=0;
EMGD_H[7]=0;
EMGD_H[8]=-1/Tq01;
}
void generator::GetEMGD_H4()
{
EMGD_H=new double[Mnumber*Mnumber];
EMGD_H[0]=-1/Td01;
EMGD_H[1]=0;
EMGD_H[2]=0;
EMGD_H[3]=0;
EMGD_H[4]=1/Td02-1/Td01;
EMGD_H[5]=-1/Td02;
EMGD_H[6]=0;
EMGD_H[7]=0;
EMGD_H[8]=0;
EMGD_H[9]=0;
EMGD_H[10]=-1/Tq01;
EMGD_H[11]=0;
EMGD_H[12]=0;
EMGD_H[13]=0;
EMGD_H[14]=1/Tq02-1/Tq01;
EMGD_H[15]=-1/Tq02;
}
/*generator::~generator()
{
delete[] EMGD_H;
}*/
void main()
{
int i,j,k,l;
int weishu;
generator GSzwj[GS];
for(i=0;i<GS;i++)
GSzwj[i].Setcanshu(1,1,1,1,1,1,1);
for(i=0;i<GS;i++)
{
weishu=GSzwj[i].Getnum();
switch(weishu)
{
case 1:GSzwj[i].GetEMGD_H1();break;
case 2:GSzwj[i].GetEMGD_H2();break;
case 3:GSzwj[i].GetEMGD_H3();break;
case 4:GSzwj[i].GetEMGD_H4();break;
default:cout<<"没有相匹配的模型"<<endl;
}
for(j=0;j<weishu*weishu;j++)
cout<<EMGD_H[j]<<endl;
cout<<endl;
cout<<endl;
delete[] EMGD_H;
}
}