#ifndef GEOMETRY_UTILS_MATRIXNXN_H #define GEOMETRY_UTILS_MATRIXNXN_H #include #include "VectorNBase.h" #include "GeometryUtilsMath.h" #include "MatrixNxMBase.h" namespace geometry_utils { template struct MatrixNxNBase : MatrixNxMBase { MatrixNxNBase() : MatrixNxMBase() {} MatrixNxNBase(T val) : MatrixNxMBase(val) {} MatrixNxNBase(const MatrixNxNBase& in) : MatrixNxMBase(in.data) {} MatrixNxNBase(const boost::array& in) : MatrixNxMBase(in) {} MatrixNxNBase(T (&in)[N * N]) : MatrixNxMBase(in) {} MatrixNxNBase(const Eigen::Matrix& in) : MatrixNxMBase(in) {} MatrixNxNBase(const MatrixNxMBase& in) : MatrixNxMBase(in) {} inline void Eye() { this->data.fill(0); for (size_t i = 0; i < this->nrows; i++) this->data[this->nrows * i + i] = 1; } virtual inline T Det() const { std::cerr << "MatrixNxMBase::det not implemented" << std::endl; return T(); } virtual inline MatrixNxNBase Inv() const { std::cerr << "MatrixNxMBase::inv not implemented" << std::endl; return MatrixNxNBase(); } static inline MatrixNxNBase Diag(const VectorNBase& in) { T d[N * N] = {0}; for (size_t i = 0; i < N; i++) d[N * i + i] = in(i); return MatrixNxNBase(d); } }; template inline MatrixNxNBase operator*(const float& lhs, const MatrixNxNBase& rhs) { return MatrixNxNBase(rhs * lhs); } template inline MatrixNxNBase operator*(const double& lhs, const MatrixNxNBase& rhs) { return MatrixNxNBase(rhs * lhs); } template inline MatrixNxNBase Inv(const MatrixNxNBase& m) { return m.Inv(); } } #endif