Example for a symmetric matric
- Author
- woelk 11/2007 (c) www.vision-n.de
#include <Base/Math/SymmetricMatrix3x3.hh>
#include <Base/Math/Matrix3x3.hh>
#include <fstream>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
for (int r=0; r<3; r++){
for (int c=r; c<3; c++){
src[r][c] = src[c][r] = (float)(r*3+c);
}
}
cout << "src: "<<src<<endl;
sm = src;
cout << "symmetric matrix: \n"<< sm << endl;
cout << "dst: "<<dst<<endl;
for (int r=0; r<3; r++){
for (int c=0; c<3; c++){
cout << sm(r,c) << "\t";
}
cout << endl;
}
sm(2,1) = 7.0f;
cout << "\nafter changing one element: \n" << sm << endl;
cout << endl << "writing: \n";
for (int r=0; r<3; r++){
for (int c=0; c<3; c++){
cout << sm(r,c) << "\t";
}
cout << endl;
}
string fname = "foo.mat";
ofstream of(fname.c_str());
BIASERR("error writing symmetric matrix");
return -1;
}
of.close();
ifstream is(fname.c_str());
BIASERR("error reading Symmetric matrix");
return -1;
}
is.close();
cout << "read: \n"<<sm2<<endl;
return 0;
}