Go to the documentation of this file.
20 #ifndef LIBMESH_DENSE_MATRIX_BASE_H
21 #define LIBMESH_DENSE_MATRIX_BASE_H
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/compare_types.h"
26 #include "libmesh/int_range.h"
34 template <
typename T>
class DenseVectorBase;
35 template <
typename T>
class DenseVector;
55 const unsigned int new_n=0) :
_m(new_m),
_n(new_n) {}
73 virtual void zero() = 0;
80 virtual T
el(
const unsigned int i,
81 const unsigned int j)
const = 0;
88 virtual T &
el(
const unsigned int i,
89 const unsigned int j) = 0;
104 unsigned int m()
const {
return _m; }
109 unsigned int n()
const {
return _n; }
138 template <
typename T2,
typename T3>
141 add (
const T2 factor,
169 const unsigned int j,
191 template<
typename T2,
typename T3>
198 libmesh_assert_equal_to (this->m(), mat.
m());
199 libmesh_assert_equal_to (this->n(), mat.
n());
203 this->el(i,j) += factor*mat.
el(i,j);
209 #endif // LIBMESH_DENSE_MATRIX_BASE_H
friend std::ostream & operator<<(std::ostream &os, const DenseMatrixBase< T > &m)
Formatted print as above but allows you to do DenseMatrix K; libMesh::out << K << std::endl;.
DenseVector< T > diagonal() const
Return the matrix diagonal.
void print_scientific(std::ostream &os, unsigned precision=8) const
Prints the matrix entries with more decimal places in scientific notation.
static void multiply(DenseMatrixBase< T > &M1, const DenseMatrixBase< T > &M2, const DenseMatrixBase< T > &M3)
Helper function - Performs the computation M1 = M2 * M3 where: M1 = (m x n) M2 = (m x p) M3 = (p x n)
The libMesh namespace provides an interface to certain functionality in the library.
DenseMatrixBase & operator=(const DenseMatrixBase &)=default
virtual void left_multiply(const DenseMatrixBase< T > &M2)=0
Performs the operation: (*this) <- M2 * (*this)
Defines an abstract dense vector base class for use in Finite Element-type computations.
void condense(const unsigned int i, const unsigned int j, const T val, DenseVectorBase< T > &rhs)
Condense-out the (i,j) entry of the matrix, forcing it to take on the value val.
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrixBase< T3 > &mat)
Adds factor to every element in the matrix.
virtual void right_multiply(const DenseMatrixBase< T > &M3)=0
Performs the operation: (*this) <- (*this) * M3.
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Defines an abstract dense matrix base class for use in Finite Element-type computations.
virtual ~DenseMatrixBase()=default
unsigned int _n
The column dimension.
void print(std::ostream &os=libMesh::out) const
Pretty-print the matrix, by default to libMesh::out.
virtual void zero()=0
Set every element in the matrix to 0.
DenseMatrixBase(const unsigned int new_m=0, const unsigned int new_n=0)
Constructor.
virtual T el(const unsigned int i, const unsigned int j) const =0
unsigned int _m
The row dimension.
Defines a dense vector for use in Finite Element-type computations.