#ifndef _MATRIX_H_
#define _MATRIX_H_
#include
#include
#include
#include
using namespace std;
class matrix{
public:
matrix(){
arr=new double*[100];
for(int i=0;i<100;i++){
arr[i]=new double[100];
for(int j=0;j<100;j++){
arr[i][j]=0;
}
}
name=new char[100];
name[0]='\0';
row=0;
col=0;
};
~matrix(){
for(int i=0;i<100;i++){
delete arr[i];
}
delete[] arr;
delete[] name;
};
void setname(const char* str,int start,int end){
for(int i=0;i<=end-start;i++){
name[i]=str[start+i];
}
name[end-start+1]='\0';
};
matrix(const matrix other){
arr=new double*[100];
for(int i=0;i<100;i++){
arr[i]=new double[100];
for(int j=0;j<100;j++){
arr[i][j]=0;
}
}
for(int i=0;i<100;i++)
for(int j=0;j<100;j++){
arr[i][j]=other.arr[i][j];
}
name=new char[100];
name[0]='\0';
if(other.name!=NULL) strcpy(name,other.name);
col=other.col;
row=other.row;
};
void setarr(string sinput,int start,int end){
int j=start,sta=start;
for(j=start;j<=end;j++){
if(sinput[j]==','){
char *temp=new char[100];
strcpy(temp,sinput.substr(sta,j-sta).c_str());
temp[j-sta]='\0';
arr[row][col]=atof(temp);
delete[] temp;
col++;
sta=j+1;
}
else if(sinput[j]==';'){
char *temp=new char[100];
strcpy(temp,sinput.substr(sta,j-sta).c_str());
temp[j-sta]='\0';
arr[row][col]=atof(temp);
delete[] temp;
row++;
sta=j+1;
col=0;
}
else if(j==end){
char *temp=new char[100];
strcpy(temp,sinput.substr(sta,j-sta+1).c_str());
temp[j-sta+1]='\0';
arr[row][col]=atof(temp);
delete[] temp;
}
}
}
bool isnotempty(){ /**/
if(row==0col==0) return 0;
else return 1;
}
void disp(){ /**/
cout< for(int i=0;i<=row;i++)
for(int j=0;j<=col;j++){
cout< cout< cout< if(j!=col) cout<<"\t,\t";
else if(i!=row) cout< }
matrix perator=(const matrix other){ /**/
row=other.row;
col=other.col;
for(int i=0;i<100;i++)
for(int j=0;j<100;j++){
arr[i][j]=other.arr[i][j];
}
if(other.name!=NULL) strcpy(name,other.name);
};
matrix operator+(const matrix other){}; /**/
matrix operator-(const matrix other){}; /**/
matrix operator*(const matrix other){}; /**/
matrix operator~(){}; /**/
protected:
double** arr;
char* name;
int row;
int col;
};
#endif