32#include <boost/scope_exit.hpp>
52 template <
class Type,
class Row,
class Col,
class AT>
class Matrix {
65 static constexpr bool isVector {
false};
66 using value_type = AT;
67 using shape_type = Type;
85 FMATVEC_ASSERT(i>=0, AT);
86 FMATVEC_ASSERT(j>=0, AT);
87 FMATVEC_ASSERT(i<
rows(), AT);
88 FMATVEC_ASSERT(j<
cols(), AT);
98 FMATVEC_ASSERT(i>=0, AT);
99 FMATVEC_ASSERT(j>=0, AT);
100 FMATVEC_ASSERT(i<
rows(), AT);
101 FMATVEC_ASSERT(j<
cols(), AT);
108 const AT& e(
int i,
int j)
const;
126 operator std::vector<std::vector<AT>>()
const;
129 template <
class Type,
class Row,
class Col,
class AT>
inline Matrix<Type,Row,Col,AT>&
Matrix<Type,Row,Col,AT>::copy(
const Matrix<Type,Row,Col,AT> &A) {
130 for(
int i=0; i<rows(); i++)
131 for(
int j=0; j<cols(); j++)
143 std::ofstream os(str);
144 for (
int i=0; i < A.
rows(); ++i) {
145 for (
int j=0; j < A.
cols(); ++j)
146 os << std::setw(14) << A.e(i,j);
148 if (i != A.
rows() - 1)
154 template <
class Type,
class Row,
class Col,
class AT>
156 std::vector<std::vector<AT>> ret(rows(),std::vector<AT>(cols()));
157 for(
int r=0; r<rows(); r++) {
158 for(
int c=0; c<cols(); c++)
167 template <
class Row,
class AT>
class Vector {
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:52
const AT & operator()(int i, int j) const
Element operator.
Definition: matrix.h:97
int rows() const
Number of rows.
int cols() const
Number of columns.
AT & operator()(int i, int j)
Standard constructor.
Definition: matrix.h:84
Namespace fmatvec.
Definition: _memory.cc:28
void dump(const char *str, const Matrix< Type, Row, Col, AT > &A)
Matrix dump.
Definition: matrix.h:142