15 #include "../config/config.hpp"
69 inline double *
Data()
const {
return data; }
75 inline const double &
operator()(
int i,
int j)
const;
84 virtual double &
Elem(
int i,
int j);
87 virtual const double &
Elem(
int i,
int j)
const;
90 void Mult(
const double *x,
double *y)
const;
105 double InnerProduct(
const double *x,
const double *y)
const;
122 {
return InnerProduct((
const double *)x, (
const double *)y); }
157 void Norm2(
double *v)
const;
163 double FNorm()
const;
169 { Eigensystem(ev, &evect); }
172 { Eigensystem(ev, &evect); }
175 int Rank(
double tol)
const;
195 void Diag(
double c,
int n);
197 void Diag(
double *diag,
int n);
230 void CopyMNDiag(
double c,
int n,
int row_offset,
int col_offset);
232 void CopyMNDiag(
double *diag,
int n,
int row_offset,
int col_offset);
248 void SetRow(
int row,
double value);
250 void SetCol(
int col,
double value);
257 virtual void Print(std::ostream &out = std::cout,
int width_ = 4)
const;
258 virtual void PrintMatlab(std::ostream &out = std::cout)
const;
260 virtual void PrintT(std::ostream &out = std::cout,
int width_ = 4)
const;
270 void Add(
const DenseMatrix &A,
const DenseMatrix &B,
271 double alpha, DenseMatrix &C);
274 void Mult(
const DenseMatrix &b,
const DenseMatrix &c, DenseMatrix &a);
279 void CalcAdjugate(
const DenseMatrix &a, DenseMatrix &adja);
286 void CalcInverse(
const DenseMatrix &a, DenseMatrix &inva);
294 void CalcOrtho(
const DenseMatrix &J, Vector &n);
297 void MultAAt(
const DenseMatrix &a, DenseMatrix &aat);
300 void MultADAt(
const DenseMatrix &A,
const Vector &D, DenseMatrix &ADAt);
303 void AddMultADAt(
const DenseMatrix &A,
const Vector &D, DenseMatrix &ADAt);
306 void MultABt(
const DenseMatrix &A,
const DenseMatrix &B, DenseMatrix &ABt);
309 void AddMultABt(
const DenseMatrix &A,
const DenseMatrix &B, DenseMatrix &ABt);
312 void MultAtB(
const DenseMatrix &A,
const DenseMatrix &B, DenseMatrix &AtB);
315 void AddMult_a_AAt(
double a,
const DenseMatrix &A, DenseMatrix &AAt);
318 void Mult_a_AAt(
double a,
const DenseMatrix &A, DenseMatrix &AAt);
321 void MultVVt(
const Vector &v, DenseMatrix &vvt);
323 void MultVWt(
const Vector &v,
const Vector &w, DenseMatrix &VWt);
326 void AddMultVWt(
const Vector &v,
const Vector &w, DenseMatrix &VWt);
329 void AddMult_a_VWt(
const double a,
const Vector &v,
const Vector &w, DenseMatrix &VWt);
332 void AddMult_a_VVt(
const double a,
const Vector &v, DenseMatrix &VVt);
342 #ifdef MFEM_USE_LAPACK
381 #ifdef MFEM_USE_LAPACK
408 #ifdef MFEM_USE_LAPACK
440 { nk = k; tdata =
new double[i*j*k]; }
451 tdata =
new double[i*j*k];
463 double *
Data() {
return tdata; }
478 if ( data == 0 || i < 0 || i >=
height || j < 0 || j >=
width )
488 if ( data == 0 || i < 0 || i >=
height || j < 0 || j >=
width )
virtual void PrintT(std::ostream &out=std::cout, int width_=4) const
Prints the transpose matrix to stream out.
void GetColumn(int c, Vector &col)
int Size() const
For backward compatibility define Size to be synonym of Width()
void Symmetrize()
(*this) = 1/2 ((*this) + (*this)^t)
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
void SymmetricScaling(const Vector &s)
SymmetricScaling this = diag(sqrt(s)) * this * diag(sqrt(s))
int CheckFinite(const double *v, const int n)
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
DenseMatrix & operator*=(double c)
void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
DenseMatrix & operator+=(DenseMatrix &m)
void InvRightScaling(const Vector &s)
InvRightScaling: this = this * diag(1./s);.
void Eigenvalues(Vector &ev)
void SingularValues(Vector &sv) const
DenseMatrix & operator()(int k)
double Det() const
Calculates the determinant of the matrix (for 2x2 or 3x3 matrices)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols.
double InnerProduct(const double *x, const double *y) const
Compute y^t A x.
void CopyRows(DenseMatrix &A, int row1, int row2)
Copy rows row1 through row2 from A to *this.
void CalcAdjugate(const DenseMatrix &a, DenseMatrix &adja)
void AddMult(const Table &elem_dof, const Vector &x, Vector &y) const
void TestInversion()
Invert and print the numerical conditioning of the inversion.
void SetSize(int i, int j, int k)
void Eval(DenseMatrix &M)
Abstract data type for matrix inverse.
void CopyMN(DenseMatrix &A, int m, int n, int Aro, int Aco)
Copy the m x n submatrix of A at (Aro)ffset, (Aco)loffset to *this.
void SetCol(int col, double value)
Set all entries of a column to the specified value.
void Factor()
Factor the current DenseMatrix, *a.
void CalcOrtho(const DenseMatrix &J, Vector &n)
DenseMatrix & operator=(double c)
Sets the matrix elements equal to constant c.
void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt = a * A * A^t.
const Vector & Eigenvector(int i)
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with inverse of dense matrix.
const double & operator()(int i, int j, int k) const
void Add(const DenseMatrix &A, const DenseMatrix &B, double alpha, DenseMatrix &C)
C = A + alpha*B.
double & operator()(int i, int j)
Returns reference to a_{ij}.
friend void Mult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A = B * C.
double FNorm() const
Compute the Frobenius norm of the matrix.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
double & operator()(int i, int j, int k)
double operator*(const DenseMatrix &m) const
Matrix inner product: tr(A^t B)
double Singularvalue(int i)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows.
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
void AddMult_a_VWt(const double a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
void InvSymmetricScaling(const Vector &s)
InvSymmetricScaling this = diag(sqrt(1./s)) * this * diag(sqrt(1./s))
DenseMatrixSVD(DenseMatrix &M)
Abstract data type matrix.
void Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
void Invert()
Replaces the current matrix with its inverse.
virtual ~DenseMatrixInverse()
Destroys dense inverse matrix.
void LeftScaling(const Vector &s)
LeftScaling this = diag(s) * this.
void CopyMNDiag(double c, int n, int row_offset, int col_offset)
Copy c on the diagonal of size n to *this at row_offset, col_offset.
virtual void PrintMatlab(std::ostream &out=std::cout) const
~DenseMatrixEigensystem()
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
void Neg()
(*this) = -(*this)
virtual void Print(std::ostream &out=std::cout, int width_=4) const
Prints matrix to stream out.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void AddToVector(int offset, Vector &v) const
Add the matrix 'data' to the Vector 'v' at the given 'offset'.
DenseMatrix & Eigenvectors()
void AddMult(const Vector &x, Vector &y) const
y += A.x
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
double MaxMaxNorm() const
Compute the norm ||A|| = max_{ij} |A_{ij}|.
double * Data() const
Returns vector of the elements.
void Transpose()
(*this) = (*this)^t
void MultVVt(const Vector &v, DenseMatrix &vvt)
Make a matrix from a vector V.Vt.
double Trace() const
Trace of a square matrix.
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
DenseTensor(int i, int j, int k)
void mfem_error(const char *msg)
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
void GetColumnReference(int c, Vector &col)
void AddMatrix(DenseMatrix &A, int ro, int co)
Perform (ro+i,co+j)+=A(i,j) for 0<=i<A.Height, 0<=j<A.Width.
DenseMatrix(double *d, int h, int w)
void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
Calculate the inverse transpose of a matrix (for NxN matrices, N=1,2,3)
void SetDataAndSize(double *d, int s)
DenseMatrix & operator-=(DenseMatrix &m)
void CopyMNt(DenseMatrix &A, int row_offset, int col_offset)
Copy matrix A^t to the location in *this at row_offset, col_offset.
void MultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt = A D A^t, where D is diagonal.
virtual MatrixInverse * Inverse() const
Returns a pointer to the inverse matrix.
virtual ~DenseMatrix()
Destroys dense matrix.
void GetDiag(Vector &d)
Returns the diagonal of the matrix.
void Diag(double c, int n)
Creates n x n diagonal matrix with diagonal elements c.
void GradToCurl(DenseMatrix &curl)
double CalcSingularvalue(const int i) const
Return the i-th singular value (decreasing order) of NxN matrix, N=1,2,3.
void CalcEigenvalues(double *lambda, double *vec) const
void Eigenvalues(Vector &ev, DenseMatrix &evect)
void Getl1Diag(Vector &l)
Returns the l1 norm of the rows of the matrix v_i = sum_j |a_ij|.
DenseMatrixEigensystem(DenseMatrix &m)
int Rank(double tol) const
DenseMatrixInverse(const DenseMatrix &mat)
void RightScaling(const Vector &s)
RightScaling: this = this * diag(s);.
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
void AddMultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt += A D A^t, where D is diagonal.
void GetFromVector(int offset, const Vector &v)
Get the matrix 'data' from the Vector 'v' at the given 'offset'.
void CopyCols(DenseMatrix &A, int col1, int col2)
Copy columns col1 through col2 from A to *this.
void InvLeftScaling(const Vector &s)
InvLeftScaling this = diag(1./s) * this.
void UseExternalData(double *d, int h, int w)
void Eigensystem(Vector &ev, DenseMatrix &evect)
void SetSize(int s)
If the matrix is not a square matrix of size s then recreate it.
void SetRow(int row, double value)
Set all entries of a row to the specified value.
int Size() const
Get the size of the inverse matrix.
Vector & Singularvalues()
Rank 3 tensor (array of matrices)
double InnerProduct(const Vector &x, const Vector &y) const
Compute y^t A x.
virtual double & Elem(int i, int j)
Returns reference to a_{ij}.
void AdjustDofDirection(Array< int > &dofs)
void GradToDiv(Vector &div)
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.