1 #ifndef _utl_SMatrix_h_
2 #define _utl_SMatrix_h_
4 #include <boost/lambda/lambda.hpp>
6 #include <utl/ListAssignmentProxy.h>
22 template<
unsigned int n,
unsigned int m,
typename T =
double>
27 static const unsigned int NRows = n;
29 static const unsigned int Size = n *
m;
39 explicit SMatrix(
const T& init) { Clear(init); }
41 template<
class Matrix>
44 template<
typename Matrix>
48 for (
unsigned int i = 0; i < n; ++i)
49 for (
unsigned int j = 0; j <
m; ++j)
60 template<
typename Matrix>
64 Clear(
const T& init = T())
68 for (
unsigned int i = 1; i <
Size; ++i)
76 template<
unsigned int i,
unsigned int j>
79 template<
unsigned int i,
unsigned int j>
88 for (
unsigned int i = 1; i <
Size; ++i)
99 for (
unsigned int i = 1; i <
Size; ++i)
111 for (
unsigned int i = 1; i <
Size; ++i)
123 for (
unsigned int i = 1; i <
Size; ++i)
128 template<
unsigned int nn,
unsigned int mm,
typename U>
133 if (n != nn ||
m !=
mm)
135 for (
unsigned int i = 0; i < n; ++i)
136 for (
unsigned int j = 0; j <
m; ++j)
142 template<
unsigned int nn,
unsigned int mm,
typename U>
150 template<
unsigned int n,
unsigned int m,
typename T>
153 template<
unsigned int n,
unsigned int m,
typename T>
156 template<
unsigned int n,
unsigned int m,
typename T>
160 template<
unsigned int n,
unsigned int m,
typename T,
typename U>
162 typename boost::lambda::return_type_2<
163 boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
169 typedef typename boost::lambda::return_type_2<
170 boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
173 >::type ProductMatrixType;
177 for (
unsigned int i = 0; i < n; ++i)
178 for (
unsigned int j = 0; j < n; ++j) {
179 r[i][j] = a[i][0] * b[0][j];
180 for (
unsigned int k = 1; k <
m; ++k)
181 r[i][j] += a[i][k] * b[k][j];
195 template<
unsigned int n,
unsigned int m,
typename T,
typename U>
196 class plain_return_type_2<
197 arithmetic_action<multiply_action>,
198 utl::SMatrix<n, m, T>,
205 arithmetic_action<multiply_action>,
219 #include <utl/SMatrixSVectorOp.h>
SMatrix & operator/=(const U &div)
return_type_2< arithmetic_action< multiply_action >, T, U >::type res_type
static const unsigned int NColumns
SMatrix & operator*=(const U &fact)
SMatrix & operator-=(const SMatrix< n, m, U > &mat)
bool operator==(const SMatrix< nn, mm, U > &a) const
void Assign(const Matrix &a)
static const unsigned int Size
Vector operator*(const double d, const Vector &v)
utl::SMatrix< n, n, res_type > type
static unsigned int GetSize()
SMatrix & operator=(const Matrix &a)
const T * operator[](const unsigned int i) const
SMatrix & operator+=(const SMatrix< n, m, U > &mat)
bool operator!=(const SMatrix< nn, mm, U > &a) const
static unsigned int GetNRows()
static unsigned int GetNColumns()
ListMatrixAssignmentProxy< SMatrix, m > operator=(const T &e)
Static (small and dense) matrix class.
T * operator[](const unsigned int i)
static const unsigned int NRows