56 template <
class Type,
class Row,
class Col,
class AT>
class Matrix {
69 typedef AT AtomicType;
87 #ifndef FMATVEC_NO_BOUNDS_CHECK
102 #ifndef FMATVEC_NO_BOUNDS_CHECK
114 const AT& e(
int i,
int j)
const;
132 operator std::vector<std::vector<AT> >();
137 template <
class Type,
class Row,
class Col,
class AT>
void Matrix<Type,Row,Col,AT>::deepCopy(
const Matrix<Type,Row,Col,AT> &A) {
138 for(
int i=0; i<rows(); i++)
139 for(
int j=0; j<cols(); j++)
150 template <
class Type,
class Row,
class Col,
class AT> std::ostream& operator<<(std::ostream &os, const Matrix<Type,Row,Col,AT> &A) {
151 os << A.rows() <<
" x " << A.cols() << std::endl;
153 for (
int i=0; i < A.rows(); ++i) {
154 for (
int j=0; j < A.cols(); ++j)
155 os << std::setw(14) << A.e(i,j);
157 if (i != A.rows() - 1)
158 os << std::endl <<
" ";
174 is >> m >> c >> n >> c;
176 for (
int i=0; i < B.
rows(); ++i)
177 for (
int j=0; j < B.
cols(); ++j)
191 std::ofstream os(str);
192 for (
int i=0; i < A.
rows(); ++i) {
193 for (
int j=0; j < A.
cols(); ++j)
194 os << std::setw(14) << A.e(i,j);
196 if (i != A.
rows() - 1)
202 template <
class Type,
class Row,
class Col,
class AT>
204 std::vector<std::vector<AT> > ret(rows());
205 for(
int r=0; r<rows(); r++) {
206 ret[r].resize(cols());
207 for(
int c=0; c<cols(); c++)
216 template <
class Row,
class AT>
class Vector {
219 template <
class Col,
class AT>
class RowVector {
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
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:86
int rows() const
Number of rows.
Definition: var_general_matrix.h:233
void dump(const char *str, const Matrix< Type, Row, Col, AT > &A)
Matrix dump.
Definition: matrix.h:190
int rows() const
Number of rows.
int cols() const
Number of columns.
int cols() const
Number of columns.
Definition: var_general_matrix.h:239
std::istream & operator>>(std::istream &is, Matrix< Type, Row, Col, AT > &A)
Matrix input.
Definition: matrix.h:171
const AT & operator()(int i, int j) const
Element operator.
Definition: matrix.h:101