added operator<<(std::ostream, Matrix) to util/Matrix
git-svn-id: svn://anubis/fart/trunk@15 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
160d6998d6
commit
746b17227c
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
#include <math.h> /* fabs() */
|
#include <math.h> /* fabs() */
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip> /* setprecision() */
|
||||||
|
|
||||||
#define FP_EQ(x,y) (fabs((x)-(y)) < 0.00001)
|
#define FP_EQ(x,y) (fabs((x)-(y)) < 0.00001)
|
||||||
|
|
||||||
@ -209,3 +211,21 @@ bool operator==(const Matrix & m1, const Matrix & m2)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream & operator<<(std::ostream & out, const Matrix & m)
|
||||||
|
{
|
||||||
|
out << std::setprecision(3);
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
out << (i == 0 ? "[ " : " ");
|
||||||
|
out << "[ ";
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
out << m[i][j];
|
||||||
|
if (j < 3)
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
|
out << "]" << std::endl;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define MATRIX_H MATRIX_H
|
#define MATRIX_H MATRIX_H
|
||||||
|
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class Matrix
|
class Matrix
|
||||||
{
|
{
|
||||||
@ -25,6 +26,7 @@ class Matrix
|
|||||||
Matrix operator*(const Matrix & m1, const Matrix & m2);
|
Matrix operator*(const Matrix & m1, const Matrix & m2);
|
||||||
Vector operator*(const Matrix & m, const Vector & v);
|
Vector operator*(const Matrix & m, const Vector & v);
|
||||||
bool operator==(const Matrix & m1, const Matrix & m2);
|
bool operator==(const Matrix & m1, const Matrix & m2);
|
||||||
|
std::ostream & operator<<(std::ostream & out, const Matrix & m);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user