23 #include "SymmetricMatrix3x3.hh"
25 #include <Base/Common/CompareFloatingPoint.hh>
26 #include <Base/Math/Matrix3x3.hh>
27 #include <Base/Math/Matrix.hh>
28 #include <Base/Math/Utils.hh>
29 #include <Base/Debug/Exception.hh>
40 SymmetricMatrix3x3<T>::
51 if (!
Equal(src[0][1], src[1][0]) ||
52 !
Equal(src[0][2], src[2][0]) ||
53 !
Equal(src[1][2], src[2][1])){
54 BEXCEPTION(
"cannot initialize SymmetricMatrix3x3 from non symmtric "
55 "Matrix3x3: "<<src<<endl);
71 BEXCEPTION(
"cannot initialize SymmetricMatrix3x3 from matrix of different"
75 if (!
Equal(src[0][1], src[1][0]) ||
76 !
Equal(src[0][2], src[2][0]) ||
77 !
Equal(src[1][2], src[2][1])){
78 BEXCEPTION(
"cannot initialize SymmetricMatrix3x3 from non symmtric "
79 "Matrix3x3: "<<src<<endl);
101 memcpy((
void *)Data_, (
void *)src.
Data_, 6*
sizeof(T));
130 return numeric_limits<unsigned>::max();
138 return Data_[SymMatrix3x3ToIndex_(row, col)];
146 return Data_[SymMatrix3x3ToIndex_(row, col)];
154 dst[0][0] = Data_[0];
155 dst[0][1] = dst[1][0] = Data_[1];
156 dst[0][2] = dst[2][0] = Data_[2];
157 dst[1][1] = Data_[3];
158 dst[1][2] = dst[2][1] = Data_[4];
159 dst[2][2] = Data_[5];
177 os.write((
const char*)(Data_),
sizeof(T)*6);
178 if (!os.good())
return -1;
187 is.read((
char*)(Data_),
sizeof(T)*6);
188 if (!is.good())
return -1;
197 template <
class T> BIASMathBase_EXPORT
198 std::ostream& operator<<(std::ostream& os, const SymmetricMatrix3x3<T>& mat)
201 os << mat.Data_[0] <<
"\t" << mat.Data_[1] <<
"\t" << mat.Data_[2] << endl
202 <<
"--" <<
"\t" << mat.Data_[3] <<
"\t" << mat.Data_[4] << endl
203 <<
"--" <<
"\t" <<
"--" <<
"\t" << mat.Data_[5] << endl;
205 for (
int i=0; i<6; i++)
206 os << mat.Data_[i] <<
" ";
212 template <
class T> BIASMathBase_EXPORT
221 for (
int i=0; i<6; i++)
231 template class BIASMathBase_EXPORT BIAS::SymmetricMatrix3x3<type>; \
232 template BIASMathBase_EXPORT ostream& BIAS::operator<<<type>(ostream& os, const SymmetricMatrix3x3<type>& mat); \
233 template BIASMathBase_EXPORT istream& BIAS::operator>><type>(istream& is, SymmetricMatrix3x3<type>& mat);
Subscript num_cols() const
T Data_[6]
The matrix data is stored as follows | Data_[0] Data_[1] Data_[2] | | Data_[1] Data_[3] Data_[4] | | ...
bool IsConsoleStream(const std::ostream &os)
Helper returning true on console ostreams like cerr, cout Useful to distinguish between console (cout...
is a 'fixed size' quadratic matrix of dim.
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
matrix class with arbitrary size, indexing is row major.
Subscript num_rows() const
BIASCommon_EXPORT std::istream & operator>>(std::istream &is, BIAS::TimeStamp &ts)
Standard input operator for TimeStamps.
is a 'fixed size' symmetric quadratic matrix of dim.