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; }
121 friend std::ostream & operator << (std::ostream & os, const DenseMatrixBase<T> &
m)
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
DenseVector< T > diagonal() const
Return the matrix diagonal.
The libMesh namespace provides an interface to certain functionality in the library.
void print(std::ostream &os=libMesh::out) const
Pretty-print the matrix, by default to libMesh::out.
virtual T el(const unsigned int i, const unsigned int j) const =0
virtual void left_multiply(const DenseMatrixBase< T > &M2)=0
Performs the operation: (*this) <- M2 * (*this)
DenseMatrixBase(const unsigned int new_m=0, const unsigned int new_n=0)
Constructor.
DenseMatrixBase & operator=(const DenseMatrixBase &)=default
unsigned int _n
The column dimension.
virtual void right_multiply(const DenseMatrixBase< T > &M3)=0
Performs the operation: (*this) <- (*this) * M3.
void print_scientific(std::ostream &os, unsigned precision=8) const
Prints the matrix entries with more decimal places in scientific notation.
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 zero()=0
Set every element in the matrix to 0.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Defines an abstract dense vector base class for use in Finite Element-type computations.
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)...
Defines a dense vector for use in Finite Element-type computations.
Defines an abstract dense matrix base class for use in Finite Element-type computations.
virtual ~DenseMatrixBase()=default
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.
unsigned int _m
The row dimension.