MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
densemat.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_DENSEMAT
13 #define MFEM_DENSEMAT
14 
15 #include "../config/config.hpp"
16 #include "matrix.hpp"
17 
18 namespace mfem
19 {
20 
22 class DenseMatrix : public Matrix
23 {
24  friend class DenseTensor;
25  friend class DenseMatrixInverse;
26 
27 private:
28  double *data;
29  int capacity; // zero or negative capacity means we do not own the data.
30 
31  void Eigensystem(Vector &ev, DenseMatrix *evect = NULL);
32 
33 public:
36  DenseMatrix();
37 
39  DenseMatrix(const DenseMatrix &);
40 
42  explicit DenseMatrix(int s);
43 
45  DenseMatrix(int m, int n);
46 
48  DenseMatrix(const DenseMatrix &mat, char ch);
49 
53  DenseMatrix(double *d, int h, int w) : Matrix(h, w)
54  { data = d; capacity = -h*w; }
55 
60  void UseExternalData(double *d, int h, int w)
61  { data = d; height = h; width = w; capacity = -h*w; }
62 
65  void ClearExternalData() { data = NULL; height = width = 0; capacity = 0; }
66 
68  int Size() const { return Width(); }
69 
71  void SetSize(int s) { SetSize(s, s); }
72 
74  void SetSize(int h, int w);
75 
77  inline double *Data() const { return data; }
78 
80  inline double &operator()(int i, int j);
81 
83  inline const double &operator()(int i, int j) const;
84 
86  double operator*(const DenseMatrix &m) const;
87 
89  double Trace() const;
90 
92  virtual double &Elem(int i, int j);
93 
95  virtual const double &Elem(int i, int j) const;
96 
98  void Mult(const double *x, double *y) const;
99 
101  virtual void Mult(const Vector &x, Vector &y) const;
102 
104  void MultTranspose(const double *x, double *y) const;
105 
107  virtual void MultTranspose(const Vector &x, Vector &y) const;
108 
110  void AddMult(const Vector &x, Vector &y) const;
111 
113  void AddMult_a(double a, const Vector &x, Vector &y) const;
114 
115  // y += a * A^t x
116  void AddMultTranspose_a(double a, const Vector &x, Vector &y) const;
117 
119  double InnerProduct(const double *x, const double *y) const;
120 
122  void LeftScaling(const Vector & s);
124  void InvLeftScaling(const Vector & s);
126  void RightScaling(const Vector & s);
128  void InvRightScaling(const Vector & s);
130  void SymmetricScaling(const Vector & s);
132  void InvSymmetricScaling(const Vector & s);
133 
135  double InnerProduct(const Vector &x, const Vector &y) const
136  { return InnerProduct((const double *)x, (const double *)y); }
137 
139  virtual MatrixInverse *Inverse() const;
140 
142  void Invert();
143 
145  double Det() const;
146 
147  double Weight() const;
148 
150  void Add(const double c, const DenseMatrix &A);
151 
153  DenseMatrix &operator=(double c);
154 
156  DenseMatrix &operator=(const double *d);
157 
159  DenseMatrix &operator=(const DenseMatrix &m);
160 
162 
164 
165  DenseMatrix &operator*=(double c);
166 
168  void Neg();
169 
171  void Norm2(double *v) const;
172 
174  double MaxMaxNorm() const;
175 
177  double FNorm() const;
178 
179  void Eigenvalues(Vector &ev)
180  { Eigensystem(ev); }
181 
182  void Eigenvalues(Vector &ev, DenseMatrix &evect)
183  { Eigensystem(ev, &evect); }
184 
185  void Eigensystem(Vector &ev, DenseMatrix &evect)
186  { Eigensystem(ev, &evect); }
187 
188  void SingularValues(Vector &sv) const;
189  int Rank(double tol) const;
190 
192  double CalcSingularvalue(const int i) const;
193 
196  void CalcEigenvalues(double *lambda, double *vec) const;
197 
198  void GetColumn(int c, Vector &col);
199 
200  void GetColumnReference(int c, Vector &col)
201  { col.SetDataAndSize(data + c * height, height); }
202 
204  void GetDiag(Vector &d);
206  void Getl1Diag(Vector &l);
208  void GetRowSums(Vector &l) const;
209 
211  void Diag(double c, int n);
213  void Diag(double *diag, int n);
214 
216  void Transpose();
218  void Transpose(DenseMatrix &A);
220  void Symmetrize();
221 
222  void Lump();
223 
228  void GradToCurl(DenseMatrix &curl);
233  void GradToDiv(Vector &div);
234 
236  void CopyRows(const DenseMatrix &A, int row1, int row2);
238  void CopyCols(const DenseMatrix &A, int col1, int col2);
240  void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco);
242  void CopyMN(const DenseMatrix &A, int row_offset, int col_offset);
244  void CopyMNt(const DenseMatrix &A, int row_offset, int col_offset);
247  void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco,
248  int row_offset, int col_offset);
250  void CopyMNDiag(double c, int n, int row_offset, int col_offset);
252  void CopyMNDiag(double *diag, int n, int row_offset, int col_offset);
253 
255  void AddMatrix(DenseMatrix &A, int ro, int co);
257  void AddMatrix(double a, DenseMatrix &A, int ro, int co);
258 
260  void AddToVector(int offset, Vector &v) const;
262  void GetFromVector(int offset, const Vector &v);
265  void AdjustDofDirection(Array<int> &dofs);
266 
268  void SetRow(int row, double value);
270  void SetCol(int col, double value);
271 
273  void Threshold(double eps);
274 
277  int CheckFinite() const { return mfem::CheckFinite(data, height*width); }
278 
280  virtual void Print(std::ostream &out = std::cout, int width_ = 4) const;
281  virtual void PrintMatlab(std::ostream &out = std::cout) const;
283  virtual void PrintT(std::ostream &out = std::cout, int width_ = 4) const;
284 
286  void TestInversion();
287 
289  virtual ~DenseMatrix();
290 };
291 
293 void Add(const DenseMatrix &A, const DenseMatrix &B,
294  double alpha, DenseMatrix &C);
295 
297 void Add(double alpha, const DenseMatrix &A,
298  double beta, const DenseMatrix &B, DenseMatrix &C);
299 
301 void Mult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a);
302 
304 void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a);
305 
309 void CalcAdjugate(const DenseMatrix &a, DenseMatrix &adja);
310 
312 void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat);
313 
316 void CalcInverse(const DenseMatrix &a, DenseMatrix &inva);
317 
319 void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva);
320 
324 void CalcOrtho(const DenseMatrix &J, Vector &n);
325 
327 void MultAAt(const DenseMatrix &a, DenseMatrix &aat);
328 
330 void MultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt);
331 
333 void AddMultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt);
334 
336 void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt);
337 
339 void MultADBt(const DenseMatrix &A, const Vector &D,
340  const DenseMatrix &B, DenseMatrix &ADAt);
341 
343 void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt);
344 
346 void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB);
347 
349 void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt);
350 
352 void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt);
353 
355 void MultVVt(const Vector &v, DenseMatrix &vvt);
356 
357 void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt);
358 
360 void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt);
361 
363 void AddMult_a_VWt(const double a, const Vector &v, const Vector &w,
364  DenseMatrix &VWt);
365 
367 void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt);
368 
369 
373 {
374 public:
375  double *data;
376  int *ipiv;
377 #ifdef MFEM_USE_LAPACK
378  static const int ipiv_base = 1;
379 #else
380  static const int ipiv_base = 0;
381 #endif
382 
385  LUFactors() { }
386 
387  LUFactors(double *data_, int *ipiv_) : data(data_), ipiv(ipiv_) { }
388 
392  void Factor(int m);
393 
396  void Mult(int m, int n, double *X) const;
397 
400  void LSolve(int m, int n, double *X) const;
401 
404  void USolve(int m, int n, double *X) const;
405 
408  void Solve(int m, int n, double *X) const;
409 
411  void GetInverseMatrix(int m, double *X) const;
412 
415  static void SubMult(int m, int n, int r, const double *A21,
416  const double *X1, double *X2);
417 
428  void BlockFactor(int m, int n, double *A12, double *A21, double *A22) const;
429 
445  void BlockForwSolve(int m, int n, int r, const double *L21,
446  double *B1, double *B2) const;
447 
454  void BlockBackSolve(int m, int n, int r, const double *U12,
455  const double *X2, double *Y1) const;
456 };
457 
458 
462 {
463 private:
464  const DenseMatrix *a;
465  LUFactors lu;
466 
467 public:
469  DenseMatrixInverse() : a(NULL), lu(NULL, NULL) { }
470 
473  DenseMatrixInverse(const DenseMatrix &mat);
474 
476  DenseMatrixInverse(const DenseMatrix *mat);
477 
479  int Size() const { return Width(); }
480 
482  void Factor();
483 
485  void Factor(const DenseMatrix &mat);
486 
487  virtual void SetOperator(const Operator &op);
488 
490  virtual void Mult(const Vector &x, Vector &y) const;
491 
493  void Mult(const DenseMatrix &B, DenseMatrix &X) const;
494 
496  void GetInverseMatrix(DenseMatrix &Ainv) const
497  {
498  Ainv.SetSize(width);
499  lu.GetInverseMatrix(width, Ainv.Data());
500  }
501 
503  void TestInversion();
504 
506  virtual ~DenseMatrixInverse();
507 };
508 
509 
511 {
512  DenseMatrix &mat;
513  Vector EVal;
514  DenseMatrix EVect;
515  Vector ev;
516  int n;
517 
518 #ifdef MFEM_USE_LAPACK
519  double *work;
520  char jobz, uplo;
521  int lwork, info;
522 #endif
523 
524 public:
525 
527  void Eval();
528  Vector &Eigenvalues() { return EVal; }
529  DenseMatrix &Eigenvectors() { return EVect; }
530  double Eigenvalue(int i) { return EVal(i); }
531  const Vector &Eigenvector(int i)
532  {
533  ev.SetData(EVect.Data() + i * EVect.Height());
534  return ev;
535  }
537 };
538 
539 
541 {
542  Vector sv;
543  int m, n;
544 
545 #ifdef MFEM_USE_LAPACK
546  double *work;
547  char jobu, jobvt;
548  int lwork, info;
549 #endif
550 
551  void Init();
552 public:
553 
555  DenseMatrixSVD(int h, int w);
556  void Eval(DenseMatrix &M);
557  Vector &Singularvalues() { return sv; }
558  double Singularvalue(int i) { return sv(i); }
559  ~DenseMatrixSVD();
560 };
561 
562 class Table;
563 
566 {
567 private:
568  DenseMatrix Mk;
569  double *tdata;
570  int nk;
571 
572 public:
573  DenseTensor() { nk = 0; tdata = NULL; }
574 
575  DenseTensor(int i, int j, int k)
576  : Mk(NULL, i, j)
577  { nk = k; tdata = new double[i*j*k]; }
578 
579  int SizeI() const { return Mk.Height(); }
580  int SizeJ() const { return Mk.Width(); }
581  int SizeK() const { return nk; }
582 
583  void SetSize(int i, int j, int k)
584  {
585  delete [] tdata;
586  Mk.UseExternalData(NULL, i, j);
587  nk = k;
588  tdata = new double[i*j*k];
589  }
590 
591  DenseMatrix &operator()(int k) { Mk.data = GetData(k); return Mk; }
592  const DenseMatrix &operator()(int k) const
593  { return const_cast<DenseTensor&>(*this)(k); }
594 
595  double &operator()(int i, int j, int k)
596  { return tdata[i+SizeI()*(j+SizeJ()*k)]; }
597  const double &operator()(int i, int j, int k) const
598  { return tdata[i+SizeI()*(j+SizeJ()*k)]; }
599 
600  double *GetData(int k) { return tdata+k*Mk.Height()*Mk.Width(); }
601 
602  double *Data() { return tdata; }
603 
606  void AddMult(const Table &elem_dof, const Vector &x, Vector &y) const;
607 
608  ~DenseTensor() { delete [] tdata; }
609 };
610 
611 
612 // Inline methods
613 
614 inline double &DenseMatrix::operator()(int i, int j)
615 {
616 #ifdef MFEM_DEBUG
617  if ( data == 0 || i < 0 || i >= height || j < 0 || j >= width )
618  {
619  mfem_error("DenseMatrix::operator()");
620  }
621 #endif
622 
623  return data[i+j*height];
624 }
625 
626 inline const double &DenseMatrix::operator()(int i, int j) const
627 {
628 #ifdef MFEM_DEBUG
629  if ( data == 0 || i < 0 || i >= height || j < 0 || j >= width )
630  {
631  mfem_error("DenseMatrix::operator() const");
632  }
633 #endif
634 
635  return data[i+j*height];
636 }
637 
638 }
639 
640 #endif
virtual void PrintT(std::ostream &out=std::cout, int width_=4) const
Prints the transpose matrix to stream out.
Definition: densemat.cpp:2719
void GetColumn(int c, Vector &col)
Definition: densemat.cpp:2193
int Size() const
For backward compatibility define Size to be synonym of Width()
Definition: densemat.hpp:68
void Symmetrize()
(*this) = 1/2 ((*this) + (*this)^t)
Definition: densemat.cpp:2317
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
Definition: densemat.cpp:3182
void SymmetricScaling(const Vector &s)
SymmetricScaling this = diag(sqrt(s)) * this * diag(sqrt(s))
Definition: densemat.cpp:341
int CheckFinite(const double *v, const int n)
Definition: vector.hpp:225
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Definition: densemat.cpp:3489
DenseMatrix & operator*=(double c)
Definition: densemat.cpp:539
void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
Definition: densemat.cpp:3467
DenseMatrix & operator+=(DenseMatrix &m)
Definition: densemat.cpp:514
void InvRightScaling(const Vector &s)
InvRightScaling: this = this * diag(1./s);.
Definition: densemat.cpp:326
const DenseMatrix & operator()(int k) const
Definition: densemat.hpp:592
void Eigenvalues(Vector &ev)
Definition: densemat.hpp:179
void SingularValues(Vector &sv) const
Definition: densemat.cpp:988
DenseMatrix & operator()(int k)
Definition: densemat.hpp:591
double Det() const
Calculates the determinant of the matrix (for 2x2 or 3x3 matrices)
Definition: densemat.cpp:416
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Definition: table.cpp:445
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols.
Definition: operator.hpp:41
int SizeK() const
Definition: densemat.hpp:581
void BlockFactor(int m, int n, double *A12, double *A21, double *A22) const
Definition: densemat.cpp:3785
void BlockBackSolve(int m, int n, int r, const double *U12, const double *X2, double *Y1) const
Definition: densemat.cpp:3821
double InnerProduct(const double *x, const double *y) const
Compute y^t A x.
Definition: densemat.cpp:271
void CalcAdjugate(const DenseMatrix &a, DenseMatrix &adja)
Definition: densemat.cpp:2864
void AddMult(const Table &elem_dof, const Vector &x, Vector &y) const
Definition: densemat.cpp:4032
void TestInversion()
Invert and print the numerical conditioning of the inversion.
Definition: densemat.cpp:2745
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
void CopyRows(const DenseMatrix &A, int row1, int row2)
Copy rows row1 through row2 from A to *this.
Definition: densemat.cpp:2428
void SetSize(int i, int j, int k)
Definition: densemat.hpp:583
void Eval(DenseMatrix &M)
Definition: densemat.cpp:4001
Abstract data type for matrix inverse.
Definition: matrix.hpp:58
void SetCol(int col, double value)
Set all entries of a column to the specified value.
Definition: densemat.cpp:2652
void GetInverseMatrix(DenseMatrix &Ainv) const
Compute and return the inverse matrix in Ainv.
Definition: densemat.hpp:496
void Factor(int m)
Definition: densemat.cpp:3557
void Factor()
Factor the current DenseMatrix, *a.
Definition: densemat.cpp:3850
void GetInverseMatrix(int m, double *X) const
Assuming L.U = P.A factored data of size (m x m), compute X &lt;- A^{-1}.
Definition: densemat.cpp:3703
void CalcOrtho(const DenseMatrix &J, Vector &n)
Definition: densemat.cpp:3100
DenseMatrix & operator=(double c)
Sets the matrix elements equal to constant c.
Definition: densemat.cpp:481
void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt = a * A * A^t.
Definition: densemat.cpp:3444
static void SubMult(int m, int n, int r, const double *A21, const double *X1, double *X2)
Definition: densemat.cpp:3768
const Vector & Eigenvector(int i)
Definition: densemat.hpp:531
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with the inverse of dense matrix.
Definition: densemat.cpp:3883
const double & operator()(int i, int j, int k) const
Definition: densemat.hpp:597
void Add(const DenseMatrix &A, const DenseMatrix &B, double alpha, DenseMatrix &C)
C = A + alpha*B.
Definition: densemat.cpp:2769
double & operator()(int i, int j)
Returns reference to a_{ij}.
Definition: densemat.hpp:614
double Weight() const
Definition: densemat.cpp:445
void USolve(int m, int n, double *X) const
Definition: densemat.cpp:3670
double FNorm() const
Compute the Frobenius norm of the matrix.
Definition: densemat.cpp:709
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
Definition: densemat.cpp:193
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
Definition: densemat.cpp:2936
double & operator()(int i, int j, int k)
Definition: densemat.hpp:595
void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A += B * C.
Definition: densemat.cpp:2832
double operator*(const DenseMatrix &m) const
Matrix inner product: tr(A^t B)
Definition: densemat.cpp:178
double Singularvalue(int i)
Definition: densemat.hpp:558
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows.
Definition: operator.hpp:35
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
Definition: densemat.cpp:472
void AddMult_a_VWt(const double a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
Definition: densemat.cpp:3510
void InvSymmetricScaling(const Vector &s)
InvSymmetricScaling this = diag(sqrt(1./s)) * this * diag(sqrt(1./s))
Definition: densemat.cpp:367
void BlockForwSolve(int m, int n, int r, const double *L21, double *B1, double *B2) const
Definition: densemat.cpp:3812
DenseMatrixSVD(DenseMatrix &M)
Definition: densemat.cpp:3967
Abstract data type matrix.
Definition: matrix.hpp:27
void Norm2(double *v) const
Take the 2-norm of the columns of A and store in v.
Definition: densemat.cpp:678
void Invert()
Replaces the current matrix with its inverse.
Definition: densemat.cpp:568
virtual ~DenseMatrixInverse()
Destroys dense inverse matrix.
Definition: densemat.cpp:3906
void LSolve(int m, int n, double *X) const
Definition: densemat.cpp:3645
void LeftScaling(const Vector &s)
LeftScaling this = diag(s) * this.
Definition: densemat.cpp:289
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.
Definition: densemat.cpp:2504
double * GetData(int k)
Definition: densemat.hpp:600
virtual void PrintMatlab(std::ostream &out=std::cout) const
Definition: densemat.cpp:2700
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
Definition: densemat.cpp:3532
void Neg()
(*this) = -(*this)
Definition: densemat.cpp:549
virtual void Print(std::ostream &out=std::cout, int width_=4) const
Prints matrix to stream out.
Definition: densemat.cpp:2674
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition: densemat.cpp:3876
void Solve(int m, int n, double *X) const
Definition: densemat.cpp:3689
void AddToVector(int offset, Vector &v) const
Add the matrix &#39;data&#39; to the Vector &#39;v&#39; at the given &#39;offset&#39;.
Definition: densemat.cpp:2595
void SetData(double *d)
Definition: vector.hpp:67
DenseMatrix & Eigenvectors()
Definition: densemat.hpp:529
void AddMult(const Vector &x, Vector &y) const
y += A.x
Definition: densemat.cpp:216
void Threshold(double eps)
Replace small entries, abs(a_ij) &lt;= eps, with zero.
Definition: densemat.cpp:2660
int SizeI() const
Definition: densemat.hpp:579
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
Definition: densemat.cpp:2972
void TestInversion()
Print the numerical conditioning of the inversion: ||A^{-1} A - I||.
Definition: densemat.cpp:3895
double MaxMaxNorm() const
Compute the norm ||A|| = max_{ij} |A_{ij}|.
Definition: densemat.cpp:691
double * Data() const
Returns vector of the elements.
Definition: densemat.hpp:77
void Transpose()
(*this) = (*this)^t
Definition: densemat.cpp:2284
void MultVVt(const Vector &v, DenseMatrix &vvt)
Make a matrix from a vector V.Vt.
Definition: densemat.cpp:3458
double Trace() const
Trace of a square matrix.
Definition: densemat.cpp:392
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
Definition: densemat.cpp:3305
DenseTensor(int i, int j, int k)
Definition: densemat.hpp:575
void mfem_error(const char *msg)
Definition: error.cpp:23
void ClearExternalData()
Definition: densemat.hpp:65
int CheckFinite() const
Definition: densemat.hpp:277
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
Definition: densemat.cpp:3124
void GetColumnReference(int c, Vector &col)
Definition: densemat.hpp:200
void AddMatrix(DenseMatrix &A, int ro, int co)
Perform (ro+i,co+j)+=A(i,j) for 0&lt;=i&lt;A.Height, 0&lt;=j&lt;A.Width.
Definition: densemat.cpp:2535
DenseMatrix(double *d, int h, int w)
Definition: densemat.hpp:53
void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
Calculate the inverse transpose of a matrix (for NxN matrices, N=1,2,3)
Definition: densemat.cpp:3061
void SetDataAndSize(double *d, int s)
Definition: vector.hpp:69
DenseMatrix & operator-=(DenseMatrix &m)
Definition: densemat.cpp:528
void MultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt = A D A^t, where D is diagonal.
Definition: densemat.cpp:3166
void CopyCols(const DenseMatrix &A, int col1, int col2)
Copy columns col1 through col2 from A to *this.
Definition: densemat.cpp:2439
int SizeJ() const
Definition: densemat.hpp:580
virtual MatrixInverse * Inverse() const
Returns a pointer to the inverse matrix.
Definition: densemat.cpp:411
virtual ~DenseMatrix()
Destroys dense matrix.
Definition: densemat.cpp:2759
void CopyMNt(const DenseMatrix &A, int row_offset, int col_offset)
Copy matrix A^t to the location in *this at row_offset, col_offset.
Definition: densemat.cpp:2475
void GetDiag(Vector &d)
Returns the diagonal of the matrix.
Definition: densemat.cpp:2209
void Diag(double c, int n)
Creates n x n diagonal matrix with diagonal elements c.
Definition: densemat.cpp:2254
void Mult(int m, int n, double *X) const
Definition: densemat.cpp:3609
void MultADBt(const DenseMatrix &A, const Vector &D, const DenseMatrix &B, DenseMatrix &ADBt)
ADBt = A D B^t, where D is diagonal.
Definition: densemat.cpp:3265
static const int ipiv_base
Definition: densemat.hpp:378
void GradToCurl(DenseMatrix &curl)
Definition: densemat.cpp:2348
DenseMatrixInverse()
Default constructor.
Definition: densemat.hpp:469
double CalcSingularvalue(const int i) const
Return the i-th singular value (decreasing order) of NxN matrix, N=1,2,3.
Definition: densemat.cpp:1654
void GetRowSums(Vector &l) const
Compute the row sums of the DenseMatrix.
Definition: densemat.cpp:2240
void CalcEigenvalues(double *lambda, double *vec) const
Definition: densemat.cpp:1953
void Eigenvalues(Vector &ev, DenseMatrix &evect)
Definition: densemat.hpp:182
void Getl1Diag(Vector &l)
Returns the l1 norm of the rows of the matrix v_i = sum_j |a_ij|.
Definition: densemat.cpp:2223
DenseMatrixEigensystem(DenseMatrix &m)
Definition: densemat.cpp:3913
int Rank(double tol) const
Definition: densemat.cpp:1027
LUFactors(double *data_, int *ipiv_)
Definition: densemat.hpp:387
void AddMult_a(double a, const Vector &x, Vector &y) const
y += a * A.x
Definition: densemat.cpp:234
void RightScaling(const Vector &s)
RightScaling: this = this * diag(s);.
Definition: densemat.cpp:311
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
Definition: densemat.cpp:3362
Vector data type.
Definition: vector.hpp:33
void Mult(const double *x, double *y) const
Matrix vector multiplication.
Definition: densemat.cpp:142
void AddMultTranspose_a(double a, const Vector &x, Vector &y) const
Definition: densemat.cpp:252
void AddMultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt += A D A^t, where D is diagonal.
Definition: densemat.cpp:3138
void GetFromVector(int offset, const Vector &v)
Get the matrix &#39;data&#39; from the Vector &#39;v&#39; at the given &#39;offset&#39;.
Definition: densemat.cpp:2606
void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco)
Copy the m x n submatrix of A at row/col offsets Aro/Aco to *this.
Definition: densemat.cpp:2450
double * Data()
Definition: densemat.hpp:602
void InvLeftScaling(const Vector &s)
InvLeftScaling this = diag(1./s) * this.
Definition: densemat.cpp:300
void UseExternalData(double *d, int h, int w)
Definition: densemat.hpp:60
void Eigensystem(Vector &ev, DenseMatrix &evect)
Definition: densemat.hpp:185
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Definition: densemat.hpp:71
void SetRow(int row, double value)
Set all entries of a row to the specified value.
Definition: densemat.cpp:2644
Abstract operator.
Definition: operator.hpp:21
int Size() const
Get the size of the inverse matrix.
Definition: densemat.hpp:479
Vector & Singularvalues()
Definition: densemat.hpp:557
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:565
double InnerProduct(const Vector &x, const Vector &y) const
Compute y^t A x.
Definition: densemat.hpp:135
virtual double & Elem(int i, int j)
Returns reference to a_{ij}.
Definition: densemat.cpp:132
void AdjustDofDirection(Array< int > &dofs)
Definition: densemat.cpp:2617
void GradToDiv(Vector &div)
Definition: densemat.cpp:2407
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
Definition: densemat.cpp:3419
double * data
Definition: densemat.hpp:375