32 #include <boost/scope_exit.hpp> 52 template <
class Type,
class Row,
class Col,
class AT>
class Matrix {
60 inline Matrix<Type,Row,Col,AT>& copy(
const Matrix<Type,Row,Col,AT> &A);
65 typedef AT value_type;
83 FMATVEC_ASSERT(i>=0, AT);
84 FMATVEC_ASSERT(j>=0, AT);
85 FMATVEC_ASSERT(i<
rows(), AT);
86 FMATVEC_ASSERT(j<
cols(), AT);
96 FMATVEC_ASSERT(i>=0, AT);
97 FMATVEC_ASSERT(j>=0, AT);
98 FMATVEC_ASSERT(i<
rows(), AT);
99 FMATVEC_ASSERT(j<
cols(), AT);
106 const AT& e(
int i,
int j)
const;
124 operator std::vector<std::vector<AT>>()
const;
127 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) {
128 for(
int i=0; i<rows(); i++)
129 for(
int j=0; j<cols(); j++)
141 std::ofstream os(str);
142 for (
int i=0; i < A.rows(); ++i) {
143 for (
int j=0; j < A.cols(); ++j)
144 os << std::setw(14) << A.e(i,j);
146 if (i != A.rows() - 1)
152 template <
class Type,
class Row,
class Col,
class AT>
154 std::vector<std::vector<AT>> ret(rows());
155 for(
int r=0; r<rows(); r++) {
156 ret[r].resize(cols());
157 for(
int c=0; c<cols(); c++)
166 template <
class Row,
class AT>
class Vector {
169 template <
class Col,
class AT>
class RowVector {
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
AT & operator()(int i, int j)
Standard constructor.
Definition: matrix.h:82
void dump(const char *str, const Matrix< Type, Row, Col, AT > &A)
Matrix dump.
Definition: matrix.h:140
int cols() const
Number of columns.
const AT & operator()(int i, int j) const
Element operator.
Definition: matrix.h:95
Namespace fmatvec.
Definition: _memory.cc:28
int rows() const
Number of rows.