8 #ifndef APFDYNAMICMATRIX_H
9 #define APFDYNAMICMATRIX_H
37 std::size_t
getRows()
const {
return values.getSize()/columns;}
41 void setSize(std::size_t m, std::size_t n)
49 return values[i*columns + j];
54 return values[i*columns + j];
59 for (std::size_t i=0; i < this->values.getSize(); ++i)
60 this->values[i] += b.values[i];
66 for (std::size_t i=0; i < this->values.getSize(); ++i)
67 this->values[i] -= b.values[i];
73 for (std::size_t i=0; i < this->values.getSize(); ++i)
80 for (std::size_t i=0; i < this->values.getSize(); ++i)
88 for (std::size_t j=0; j < columns; ++j)
96 for (std::size_t i=0; i < rows; ++i)
102 for (std::size_t j=0; j < columns; ++j)
109 for (std::size_t i=0; i < rows; ++i)
116 for(std::size_t ii = 0; ii < rows; ii++)
117 for(std::size_t jj = 0; jj < columns; jj++)
118 (*
this)(ii,jj) = 0.0;
122 DynamicArray<double> values;
130 std::size_t rows = a.
getRows();
133 for (std::size_t i=0; i < rows; ++i)
136 for (std::size_t j=1; j < columns; ++j)
146 std::size_t rows = a.
getRows();
149 for (std::size_t j=0; j < columns; ++j)
152 for (std::size_t i=1; i < rows; ++i)
162 std::size_t rows = a.
getRows();
164 std::size_t depth = b.
getRows();
166 for (std::size_t i=0; i < rows; ++i)
167 for (std::size_t j=0; j < columns; ++j)
169 r(i,j) = a(i,0)*b(0,j);
170 for (std::size_t k=1; k < depth; ++k)
171 r(i,j) += a(i,k)*b(k,j);
179 std::size_t rows = a.
getRows();
182 for (std::size_t i=0; i < rows; ++i)
183 for (std::size_t j=0; j < columns; ++j)
188 template <std::
size_t N, std::
size_t M>
192 for(std::size_t ii = 0; ii < N; ii++)
193 for(std::size_t jj = 0; jj < M; jj++)
194 result(ii,jj) = other[ii][jj];
DynamicMatrix & operator+=(DynamicMatrix const &b)
add a matrix to this matrix
DynamicMatrix & operator*=(double s)
multiply this matrix by a scalar
double operator()(std::size_t i, std::size_t j) const
immutable index operator
Matrix< N, M > transpose(Matrix< M, N > const &m)
transpose a matrix
void multiply(DynamicMatrix const &a, DynamicVector const &b, DynamicVector &r)
multiply a DynamicMatrix by a DynamicVector
std::ostream & operator<<(std::ostream &s, apf::Vector3 const &v)
write apf::Vector3 to a C++ stream
The APF linear algebra matrix interface.
A runtime-sized dense matrix.
double & operator()(std::size_t i, std::size_t j)
mutable index operator
void setColumn(std::size_t j, DynamicVector const &r)
copy column data from a DynamicVector
DynamicMatrix & operator/=(double s)
divide this matrix by a scalar
void getRow(std::size_t i, DynamicVector &r) const
copy row data into a DynamicVector
DynamicMatrix(std::size_t m, std::size_t n)
construct with size m by n
DynamicMatrix fromMatrix(Matrix< N, M > other)
convert an apf::Matrix into an apf::DynamicMatrix
std::size_t getRows() const
get the number of rows (first index)
std::size_t getColumns() const
get the number of columns (second index)
DynamicMatrix & operator-=(DynamicMatrix const &b)
subtract a matrix from this matrix
template-generic matrix of M by N doubles
DynamicMatrix()
defautl constructor, no allocation
A runtime-sized linear algebra vector of doubles.
void setRow(std::size_t i, DynamicVector const &r)
copy row data from a DynamicVector
Small runtime-sized vectors.
void getColumn(std::size_t j, DynamicVector &r) const
copy column data into a DynamicVector
void setSize(std::size_t m, std::size_t n)
resize to m by n