#define MSP_LINAL_DYNAMICMATRIX_H_
#include <algorithm>
+#include <ostream>
#include "dynamicvector.h"
#include "matrixops.h"
return r.invert();
}
+template<typename T>
+inline std::ostream &operator<<(std::ostream &s, const DynamicMatrix<T> &m)
+{
+ s << "DynamicMatrix" << m.rows() << 'x' << m.columns() << '(';
+ for(unsigned i=0; i<m.columns(); ++i)
+ {
+ if(i)
+ s << ", ";
+ s << '[';
+ for(unsigned j=0; j<m.rows(); ++j)
+ {
+ if(j)
+ s << ", ";
+ s << m(j, i);
+ }
+ s << ']';
+ }
+ s << ')';
+ return s;
+}
+
} // namespace LinAl
} // namespace Msp
#include <algorithm>
#include <cmath>
+#include <ostream>
#include <stdexcept>
namespace Msp {
return r.normalize();
}
+template<typename T>
+inline std::ostream &operator<<(std::ostream &s, const DynamicVector<T> &v)
+{
+ s << "DynamicVector" << v.size() << '(';
+ for(unsigned i=0; i<v.size(); ++i)
+ {
+ if(i)
+ s << ", ";
+ s << v[i];
+ }
+ s << ')';
+ return s;
+}
+
} // namespace LinAL
} // namespace Msp
#define MSP_LINAL_MATRIX_H_
#include <algorithm>
+#include <ostream>
#include "vector.h"
namespace Msp {
return r;
}
+template<typename T, unsigned M, unsigned N>
+inline std::ostream &operator<<(std::ostream &s, const Matrix<T, M, N> &m)
+{
+ s << "Matrix" << M << 'x' << N << '(';
+ for(unsigned i=0; i<N; ++i)
+ {
+ if(i)
+ s << ", ";
+ s << '[';
+ for(unsigned j=0; j<M; ++j)
+ {
+ if(j)
+ s << ", ";
+ s << m(j, i);
+ }
+ s << ']';
+ }
+ s << ')';
+ return s;
+}
+
} // namespace LinAl
} // namespace Msp
#include <algorithm>
#include <cmath>
+#include <ostream>
namespace Msp {
namespace LinAl {
return Vector<T, 3>(v1.y*v2.z-v1.z*v2.y, v1.z*v2.x-v1.x*v2.z, v1.x*v2.y-v1.y*v2.x);
}
+template<typename T, unsigned N>
+inline std::ostream &operator<<(std::ostream &s, const Vector<T, N> &v)
+{
+ s << "Vector" << N << '(';
+ for(unsigned i=0; i<N; ++i)
+ {
+ if(i)
+ s << ", ";
+ s << v[i];
+ }
+ s << ')';
+ return s;
+}
+
} // namespace LinAl
} // namespace Msp
void special_cases();
};
-namespace Msp {
-namespace LinAl {
-
-void operator<<(LexicalConverter &conv, const Vector<double, 3> &vec)
-{
- conv.result(format("[%g %g %g]", vec.x, vec.y, vec.z));
-}
-
-} }
-
BoundingBoxTests::BoundingBoxTests()
{
add(&BoundingBoxTests::simple_union, "Union");
LinAl::Matrix<double, 3, 2> a(data);
LinAl::Matrix<double, 2, 3> b(data+6);
- EXPECT(a*b == (LinAl::Matrix<double, 3, 3>(data+12)));
- EXPECT(b*a == (LinAl::Matrix<double, 2, 2>(data+21)));
+ EXPECT_EQUAL(a*b, (LinAl::Matrix<double, 3, 3>(data+12)));
+ EXPECT_EQUAL(b*a, (LinAl::Matrix<double, 2, 2>(data+21)));
}
template<typename T, unsigned N>