B
bluekite2000
I have
template <typename T>
inline std::istream& operator >> (std::istream& is, Matrix<T>& mIn)
{
int rows,cols;
is.clear();
is >> rows >> cols;
mIn._M=rows;
mIn._N=cols;
mIn.MatAlloc(rows,cols);//alllocate mem
for (int i=0;i<rows;i++)
for (int j=0;j<cols; j++)
if(is.good())
is >> mIn(i,j);
return is;
}
This works fine if i have a text file such as
2 3 //2 rows 3 cols
1 2 3
4 5 6
but if i have something like
2 3
1 2
I get a matrix M with the following data member
2 3
1 2 2
0 0 0
notice how M(0,1)==M(0,2) ==2 which i DONT want. Any idea?
template <typename T>
inline std::istream& operator >> (std::istream& is, Matrix<T>& mIn)
{
int rows,cols;
is.clear();
is >> rows >> cols;
mIn._M=rows;
mIn._N=cols;
mIn.MatAlloc(rows,cols);//alllocate mem
for (int i=0;i<rows;i++)
for (int j=0;j<cols; j++)
if(is.good())
is >> mIn(i,j);
return is;
}
This works fine if i have a text file such as
2 3 //2 rows 3 cols
1 2 3
4 5 6
but if i have something like
2 3
1 2
I get a matrix M with the following data member
2 3
1 2 2
0 0 0
notice how M(0,1)==M(0,2) ==2 which i DONT want. Any idea?