56 template <
class Type,
class Row,
class Col,
class AT>
class Matrix {
86 #ifndef FMATVEC_NO_BOUNDS_CHECK
101 #ifndef FMATVEC_NO_BOUNDS_CHECK
113 const AT& e(
int i,
int j)
const;
131 operator std::vector<std::vector<AT> >();
136 template <
class Type,
class Row,
class Col,
class AT>
void Matrix<Type,Row,Col,AT>::deepCopy(
const Matrix<Type,Row,Col,AT> &A) {
137 for(
int i=0; i<rows(); i++)
138 for(
int j=0; j<cols(); j++)
149 template <
class Type,
class Row,
class Col,
class AT> std::ostream& operator<<(std::ostream &os, const Matrix<Type,Row,Col,AT> &A) {
150 os << A.rows() <<
" x " << A.cols() << std::endl;
152 for (
int i=0; i < A.rows(); ++i) {
153 for (
int j=0; j < A.cols(); ++j)
154 os << std::setw(14) << A.e(i,j);
156 if (i != A.rows() - 1)
157 os << std::endl <<
" ";
173 is >> m >> c >> n >> c;
175 for (
int i=0; i < B.
rows(); ++i)
176 for (
int j=0; j < B.
cols(); ++j)
190 std::ofstream os(str);
191 for (
int i=0; i < A.
rows(); ++i) {
192 for (
int j=0; j < A.
cols(); ++j)
193 os << std::setw(14) << A.e(i,j);
195 if (i != A.
rows() - 1)
201 template <
class Type,
class Row,
class Col,
class AT>
203 std::vector<std::vector<AT> > ret(rows());
204 for(
int r=0; r<rows(); r++) {
205 ret[r].resize(cols());
206 for(
int c=0; c<cols(); c++)
215 template <
class Row,
class AT>
class Vector {
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:56
This is a matrix class for general matrices.
Definition: var_general_matrix.h:38
AT & operator()(int i, int j)
Standard constructor.
Definition: matrix.h:85
int rows() const
Number of rows.
Definition: var_general_matrix.h:232
void dump(const char *str, const Matrix< Type, Row, Col, AT > &A)
Matrix dump.
Definition: matrix.h:189
int rows() const
Number of rows.
int cols() const
Number of columns.
int cols() const
Number of columns.
Definition: var_general_matrix.h:238
std::istream & operator>>(std::istream &is, Matrix< Type, Row, Col, AT > &A)
Matrix input.
Definition: matrix.h:170
const AT & operator()(int i, int j) const
Element operator.
Definition: matrix.h:100