matrix.printraw SegFault bug and fix
Pearu Peterson
pearu at cens.ioc.ee
Fri Apr 6 20:11:43 CEST 2001
I found a small bug that gives SegFault if row > 1.
Here is a fix:
void matrix::printraw(std::ostream & os) const
{
debugmsg("matrix printraw",LOGLEVEL_PRINT);
os << class_name() << "(" << row << "," << col <<",";
for (unsigned r=0; r<row-1; ++r) {
os << "(";
for (unsigned c=0; c<col-1; ++c)
os << m[r*col+c] << ",";
os << m[col*(r-1)-1] << "),";
^---------------------------^ this line should be:
os << m[col*(r+1)-1] << "),";
}
os << "(";
for (unsigned c=0; c<col-1; ++c)
os << m[(row-1)*col+c] << ",";
os << m[row*col-1] << "))";
}
Pearu
More information about the GiNaC-devel
mailing list