1template<
int Rows,
typename Scalar>
5 for (
int i=0;
i<Rows;
i++) {
13template<
int Rows,
int Cols,
typename Scalar>
14Scalar tarch::la::frobeniusNorm(
15 const Matrix<Rows,Cols,Scalar>& matrix
19 for (
int row=0;
row<Rows;
row++)
20 for (
int col=0;
col<Cols;
col++) {
21 result += matrix(row,col) * matrix(row,col);
24 return std::sqrt(result);
28template<
int Rows,
int Cols,
typename Scalar>
29Scalar tarch::la::elementMax(
30 const Matrix<Rows,Cols,Scalar>& matrix
34 for (
int row=0;
row<Rows;
row++)
35 for (
int col=0;
col<Cols;
col++) {
36 result = std::max( result,
std::abs( matrix(row,col) ) );
43template<
int Rows,
int Cols,
typename Scalar>
49 for (
int i=0;
i<Rows;
i++) {
50 for (
int j=0;
j<Cols;
j++) {
51 result(i,j) = 1.0/matrix(i,j);
60template<
int Rows,
int Cols,
typename Scalar>
64 for (
int i=0;
i<Cols;
i++) {
65 result(i) = matrix(whichRow,i);
72template<
int Rows,
int Cols,
typename Scalar>
76 for (
int i=0;
i<Rows;
i++) {
77 result(i) = matrix(i,whichColumn);
84template<
int Rows,
int Cols,
typename Scalar>
90 for (
int i=0;
i < Rows;
i++) {
91 for (
int j=0;
j < Cols;
j++) {
92 result(j,i) += matrix(i,j);
100template<
int Rows,
int Cols,
typename Scalar>
103 for (
int i=0; i < Rows; i++) {
104 for (
int j=0; j < Cols; j++) {
105 result += matrix(i,j);
113template<
int Rows,
int Cols,
typename Scalar>
123template<
int Rows,
typename Scalar>
126 for (
int i=0;
i<Rows;
i++) {
127 result(i) = matrix(i,i);
std::ostream & operator<<(std::ostream &os, const tarch::la::Matrix< Rows, Cols, Scalar > &matrix)
std::string toString() const
DynamicMatrix transpose(const DynamicMatrix &matrix)
Scalar sum(const Matrix< Rows, Cols, Scalar > &matrix)
Computes the sum of all entries of the matrix.
Vector< Rows, Scalar > col(const Matrix< Rows, Cols, Scalar > &matrix, int whichColumn)
Extract row from matrix.
Vector< Rows, Scalar > diag(const Matrix< Rows, Rows, Scalar > &matrix)
Extract diagonal vector from matrix.
static Matrix< Rows, Rows, Scalar > identity()
Returns the identity matrix.
Vector< Size, Scalar > invertEntries(const Vector< Size, Scalar > &vector)
Vector< Cols, Scalar > row(const Matrix< Rows, Cols, Scalar > &matrix, int whichRow)
Extract row from matrix.