MFEM  v3.2
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 GetRow(int r, Vector &row);
199  void GetColumn(int c, Vector &col) const;
200 
201  void GetColumnReference(int c, Vector &col)
202  { col.SetDataAndSize(data + c * height, height); }
203 
204  void SetRow(int r, const Vector &row);
205  void SetCol(int c, const Vector &col);
206 
208  void SetRow(int row, double value);
210  void SetCol(int col, double value);
211 
213  void GetDiag(Vector &d) const;
215  void Getl1Diag(Vector &l) const;
217  void GetRowSums(Vector &l) const;
218 
220  void Diag(double c, int n);
222  void Diag(double *diag, int n);
223 
225  void Transpose();
227  void Transpose(DenseMatrix &A);
229  void Symmetrize();
230 
231  void Lump();
232 
237  void GradToCurl(DenseMatrix &curl);
242  void GradToDiv(Vector &div);
243 
245  void CopyRows(const DenseMatrix &A, int row1, int row2);
247  void CopyCols(const DenseMatrix &A, int col1, int col2);
249  void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco);
251  void CopyMN(const DenseMatrix &A, int row_offset, int col_offset);
253  void CopyMNt(const DenseMatrix &A, int row_offset, int col_offset);
256  void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco,
257  int row_offset, int col_offset);
259  void CopyMNDiag(double c, int n, int row_offset, int col_offset);
261  void CopyMNDiag(double *diag, int n, int row_offset, int col_offset);
262 
264  void AddMatrix(DenseMatrix &A, int ro, int co);
266  void AddMatrix(double a, DenseMatrix &A, int ro, int co);
267 
269  void AddToVector(int offset, Vector &v) const;
271  void GetFromVector(int offset, const Vector &v);
274  void AdjustDofDirection(Array<int> &dofs);
275 
277  void Threshold(double eps);
278 
281  int CheckFinite() const { return mfem::CheckFinite(data, height*width); }
282 
284  virtual void Print(std::ostream &out = std::cout, int width_ = 4) const;
285  virtual void PrintMatlab(std::ostream &out = std::cout) const;
287  virtual void PrintT(std::ostream &out = std::cout, int width_ = 4) const;
288 
290  void TestInversion();
291 
293  virtual ~DenseMatrix();
294 };
295 
297 void Add(const DenseMatrix &A, const DenseMatrix &B,
298  double alpha, DenseMatrix &C);
299 
301 void Add(double alpha, const DenseMatrix &A,
302  double beta, const DenseMatrix &B, DenseMatrix &C);
303 
305 void Mult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a);
306 
308 void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a);
309 
313 void CalcAdjugate(const DenseMatrix &a, DenseMatrix &adja);
314 
316 void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat);
317 
320 void CalcInverse(const DenseMatrix &a, DenseMatrix &inva);
321 
323 void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva);
324 
328 void CalcOrtho(const DenseMatrix &J, Vector &n);
329 
331 void MultAAt(const DenseMatrix &a, DenseMatrix &aat);
332 
334 void MultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt);
335 
337 void AddMultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt);
338 
340 void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt);
341 
343 void MultADBt(const DenseMatrix &A, const Vector &D,
344  const DenseMatrix &B, DenseMatrix &ADAt);
345 
347 void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt);
348 
350 void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB);
351 
353 void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt);
354 
356 void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt);
357 
359 void MultVVt(const Vector &v, DenseMatrix &vvt);
360 
361 void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt);
362 
364 void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt);
365 
367 void AddMult_a_VWt(const double a, const Vector &v, const Vector &w,
368  DenseMatrix &VWt);
369 
371 void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt);
372 
373 
377 {
378 public:
379  double *data;
380  int *ipiv;
381 #ifdef MFEM_USE_LAPACK
382  static const int ipiv_base = 1;
383 #else
384  static const int ipiv_base = 0;
385 #endif
386 
389  LUFactors() { }
390 
391  LUFactors(double *data_, int *ipiv_) : data(data_), ipiv(ipiv_) { }
392 
396  void Factor(int m);
397 
400  void Mult(int m, int n, double *X) const;
401 
404  void LSolve(int m, int n, double *X) const;
405 
408  void USolve(int m, int n, double *X) const;
409 
412  void Solve(int m, int n, double *X) const;
413 
415  void GetInverseMatrix(int m, double *X) const;
416 
419  static void SubMult(int m, int n, int r, const double *A21,
420  const double *X1, double *X2);
421 
432  void BlockFactor(int m, int n, double *A12, double *A21, double *A22) const;
433 
449  void BlockForwSolve(int m, int n, int r, const double *L21,
450  double *B1, double *B2) const;
451 
458  void BlockBackSolve(int m, int n, int r, const double *U12,
459  const double *X2, double *Y1) const;
460 };
461 
462 
466 {
467 private:
468  const DenseMatrix *a;
469  LUFactors lu;
470 
471 public:
473  DenseMatrixInverse() : a(NULL), lu(NULL, NULL) { }
474 
477  DenseMatrixInverse(const DenseMatrix &mat);
478 
480  DenseMatrixInverse(const DenseMatrix *mat);
481 
483  int Size() const { return Width(); }
484 
486  void Factor();
487 
489  void Factor(const DenseMatrix &mat);
490 
491  virtual void SetOperator(const Operator &op);
492 
494  virtual void Mult(const Vector &x, Vector &y) const;
495 
497  void Mult(const DenseMatrix &B, DenseMatrix &X) const;
498 
500  void GetInverseMatrix(DenseMatrix &Ainv) const
501  {
502  Ainv.SetSize(width);
503  lu.GetInverseMatrix(width, Ainv.Data());
504  }
505 
507  void TestInversion();
508 
510  virtual ~DenseMatrixInverse();
511 };
512 
513 
515 {
516  DenseMatrix &mat;
517  Vector EVal;
518  DenseMatrix EVect;
519  Vector ev;
520  int n;
521 
522 #ifdef MFEM_USE_LAPACK
523  double *work;
524  char jobz, uplo;
525  int lwork, info;
526 #endif
527 
528 public:
529 
531  void Eval();
532  Vector &Eigenvalues() { return EVal; }
533  DenseMatrix &Eigenvectors() { return EVect; }
534  double Eigenvalue(int i) { return EVal(i); }
535  const Vector &Eigenvector(int i)
536  {
537  ev.SetData(EVect.Data() + i * EVect.Height());
538  return ev;
539  }
541 };
542 
543 
545 {
546  Vector sv;
547  int m, n;
548 
549 #ifdef MFEM_USE_LAPACK
550  double *work;
551  char jobu, jobvt;
552  int lwork, info;
553 #endif
554 
555  void Init();
556 public:
557 
559  DenseMatrixSVD(int h, int w);
560  void Eval(DenseMatrix &M);
561  Vector &Singularvalues() { return sv; }
562  double Singularvalue(int i) { return sv(i); }
563  ~DenseMatrixSVD();
564 };
565 
566 class Table;
567 
570 {
571 private:
572  DenseMatrix Mk;
573  double *tdata;
574  int nk;
575  bool own_data;
576 
577 public:
579  {
580  nk = 0;
581  tdata = NULL;
582  own_data = true;
583  }
584 
585  DenseTensor(int i, int j, int k)
586  : Mk(NULL, i, j)
587  {
588  nk = k;
589  tdata = new double[i*j*k];
590  own_data = true;
591  }
592 
593  int SizeI() const { return Mk.Height(); }
594  int SizeJ() const { return Mk.Width(); }
595  int SizeK() const { return nk; }
596 
597  void SetSize(int i, int j, int k)
598  {
599  if (own_data) { delete [] tdata; }
600  Mk.UseExternalData(NULL, i, j);
601  nk = k;
602  tdata = new double[i*j*k];
603  own_data = true;
604  }
605 
606  void UseExternalData(double *ext_data, int i, int j, int k)
607  {
608  if (own_data) { delete [] tdata; }
609  Mk.UseExternalData(NULL, i, j);
610  nk = k;
611  tdata = ext_data;
612  own_data = false;
613  }
614 
615  DenseMatrix &operator()(int k) { Mk.data = GetData(k); return Mk; }
616  const DenseMatrix &operator()(int k) const
617  { return const_cast<DenseTensor&>(*this)(k); }
618 
619  double &operator()(int i, int j, int k)
620  { return tdata[i+SizeI()*(j+SizeJ()*k)]; }
621  const double &operator()(int i, int j, int k) const
622  { return tdata[i+SizeI()*(j+SizeJ()*k)]; }
623 
624  double *GetData(int k) { return tdata+k*Mk.Height()*Mk.Width(); }
625 
626  double *Data() { return tdata; }
627 
630  void AddMult(const Table &elem_dof, const Vector &x, Vector &y) const;
631 
633  {
634  if (own_data) { delete [] tdata; }
635  }
636 };
637 
638 
639 // Inline methods
640 
641 inline double &DenseMatrix::operator()(int i, int j)
642 {
643  MFEM_ASSERT(data && i >= 0 && i < height && j >= 0 && j < width, "");
644  return data[i+j*height];
645 }
646 
647 inline const double &DenseMatrix::operator()(int i, int j) const
648 {
649  MFEM_ASSERT(data && i >= 0 && i < height && j >= 0 && j < width, "");
650  return data[i+j*height];
651 }
652 
653 } // namespace mfem
654 
655 #endif
virtual void PrintT(std::ostream &out=std::cout, int width_=4) const
Prints the transpose matrix to stream out.
Definition: densemat.cpp:2759
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:2327
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:3218
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:239
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Definition: densemat.cpp:3525
DenseMatrix & operator*=(double c)
Definition: densemat.cpp:537
void GetDiag(Vector &d) const
Returns the diagonal of the matrix.
Definition: densemat.cpp:2219
void UseExternalData(double *ext_data, int i, int j, int k)
Definition: densemat.hpp:606
void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
Definition: densemat.cpp:3503
DenseMatrix & operator+=(DenseMatrix &m)
Definition: densemat.cpp:512
void InvRightScaling(const Vector &s)
InvRightScaling: this = this * diag(1./s);.
Definition: densemat.cpp:326
const DenseMatrix & operator()(int k) const
Definition: densemat.hpp:616
void Eigenvalues(Vector &ev)
Definition: densemat.hpp:179
void SingularValues(Vector &sv) const
Definition: densemat.cpp:986
DenseMatrix & operator()(int k)
Definition: densemat.hpp:615
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:451
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:595
void BlockFactor(int m, int n, double *A12, double *A21, double *A22) const
Definition: densemat.cpp:3821
void BlockBackSolve(int m, int n, int r, const double *U12, const double *X2, double *Y1) const
Definition: densemat.cpp:3857
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:2904
void AddMult(const Table &elem_dof, const Vector &x, Vector &y) const
Definition: densemat.cpp:4068
void TestInversion()
Invert and print the numerical conditioning of the inversion.
Definition: densemat.cpp:2785
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:2438
void SetSize(int i, int j, int k)
Definition: densemat.hpp:597
void Eval(DenseMatrix &M)
Definition: densemat.cpp:4037
Abstract data type for matrix inverse.
Definition: matrix.hpp:58
void GetInverseMatrix(DenseMatrix &Ainv) const
Compute and return the inverse matrix in Ainv.
Definition: densemat.hpp:500
void Factor(int m)
Definition: densemat.cpp:3593
void Factor()
Factor the current DenseMatrix, *a.
Definition: densemat.cpp:3886
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:3739
void CalcOrtho(const DenseMatrix &J, Vector &n)
Definition: densemat.cpp:3134
DenseMatrix & operator=(double c)
Sets the matrix elements equal to constant c.
Definition: densemat.cpp:479
void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt = a * A * A^t.
Definition: densemat.cpp:3480
static void SubMult(int m, int n, int r, const double *A21, const double *X1, double *X2)
Definition: densemat.cpp:3804
const Vector & Eigenvector(int i)
Definition: densemat.hpp:535
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with the inverse of dense matrix.
Definition: densemat.cpp:3919
const double & operator()(int i, int j, int k) const
Definition: densemat.hpp:621
void Add(const DenseMatrix &A, const DenseMatrix &B, double alpha, DenseMatrix &C)
C = A + alpha*B.
Definition: densemat.cpp:2809
double & operator()(int i, int j)
Returns reference to a_{ij}.
Definition: densemat.hpp:641
double Weight() const
Definition: densemat.cpp:443
void USolve(int m, int n, double *X) const
Definition: densemat.cpp:3706
double FNorm() const
Compute the Frobenius norm of the matrix.
Definition: densemat.cpp:707
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:2976
double & operator()(int i, int j, int k)
Definition: densemat.hpp:619
void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A += B * C.
Definition: densemat.cpp:2872
double operator*(const DenseMatrix &m) const
Matrix inner product: tr(A^t B)
Definition: densemat.cpp:178
double Singularvalue(int i)
Definition: densemat.hpp:562
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:470
void AddMult_a_VWt(const double a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
Definition: densemat.cpp:3546
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:3848
DenseMatrixSVD(DenseMatrix &M)
Definition: densemat.cpp:4003
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:676
void Invert()
Replaces the current matrix with its inverse.
Definition: densemat.cpp:566
virtual ~DenseMatrixInverse()
Destroys dense inverse matrix.
Definition: densemat.cpp:3942
void LSolve(int m, int n, double *X) const
Definition: densemat.cpp:3681
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:2528
double * GetData(int k)
Definition: densemat.hpp:624
virtual void PrintMatlab(std::ostream &out=std::cout) const
Definition: densemat.cpp:2740
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
Definition: densemat.cpp:3568
void Neg()
(*this) = -(*this)
Definition: densemat.cpp:547
virtual void Print(std::ostream &out=std::cout, int width_=4) const
Prints matrix to stream out.
Definition: densemat.cpp:2714
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
Definition: densemat.cpp:3912
void Solve(int m, int n, double *X) const
Definition: densemat.cpp:3725
void SetRow(int r, const Vector &row)
Definition: densemat.cpp:2684
void Getl1Diag(Vector &l) const
Returns the l1 norm of the rows of the matrix v_i = sum_j |a_ij|.
Definition: densemat.cpp:2233
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:2619
void SetData(double *d)
Definition: vector.hpp:69
DenseMatrix & Eigenvectors()
Definition: densemat.hpp:533
void GetColumn(int c, Vector &col) const
Definition: densemat.cpp:2205
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:2700
int SizeI() const
Definition: densemat.hpp:593
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
Definition: densemat.cpp:3012
void TestInversion()
Print the numerical conditioning of the inversion: ||A^{-1} A - I||.
Definition: densemat.cpp:3931
double MaxMaxNorm() const
Compute the norm ||A|| = max_{ij} |A_{ij}|.
Definition: densemat.cpp:689
double * Data() const
Returns vector of the elements.
Definition: densemat.hpp:77
void Transpose()
(*this) = (*this)^t
Definition: densemat.cpp:2294
void MultVVt(const Vector &v, DenseMatrix &vvt)
Make a matrix from a vector V.Vt.
Definition: densemat.cpp:3494
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:3341
DenseTensor(int i, int j, int k)
Definition: densemat.hpp:585
void ClearExternalData()
Definition: densemat.hpp:65
int CheckFinite() const
Definition: densemat.hpp:281
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
Definition: densemat.cpp:3160
void GetColumnReference(int c, Vector &col)
Definition: densemat.hpp:201
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:2559
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:3095
void SetDataAndSize(double *d, int s)
Definition: vector.hpp:71
DenseMatrix & operator-=(DenseMatrix &m)
Definition: densemat.cpp:526
void MultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt = A D A^t, where D is diagonal.
Definition: densemat.cpp:3202
void CopyCols(const DenseMatrix &A, int col1, int col2)
Copy columns col1 through col2 from A to *this.
Definition: densemat.cpp:2449
int SizeJ() const
Definition: densemat.hpp:594
virtual MatrixInverse * Inverse() const
Returns a pointer to the inverse matrix.
Definition: densemat.cpp:411
virtual ~DenseMatrix()
Destroys dense matrix.
Definition: densemat.cpp:2799
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:2485
void Diag(double c, int n)
Creates n x n diagonal matrix with diagonal elements c.
Definition: densemat.cpp:2264
void Mult(int m, int n, double *X) const
Definition: densemat.cpp:3645
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:3301
static const int ipiv_base
Definition: densemat.hpp:382
void GradToCurl(DenseMatrix &curl)
Definition: densemat.cpp:2358
DenseMatrixInverse()
Default constructor.
Definition: densemat.hpp:473
double CalcSingularvalue(const int i) const
Return the i-th singular value (decreasing order) of NxN matrix, N=1,2,3.
Definition: densemat.cpp:1652
void GetRowSums(Vector &l) const
Compute the row sums of the DenseMatrix.
Definition: densemat.cpp:2250
void GetRow(int r, Vector &row)
Definition: densemat.cpp:2189
void CalcEigenvalues(double *lambda, double *vec) const
Definition: densemat.cpp:1949
void Eigenvalues(Vector &ev, DenseMatrix &evect)
Definition: densemat.hpp:182
DenseMatrixEigensystem(DenseMatrix &m)
Definition: densemat.cpp:3949
int Rank(double tol) const
Definition: densemat.cpp:1025
const double alpha
Definition: ex15.cpp:337
LUFactors(double *data_, int *ipiv_)
Definition: densemat.hpp:391
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:3398
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:3174
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:2630
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:2460
double * Data()
Definition: densemat.hpp:626
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 SetCol(int c, const Vector &col)
Definition: densemat.cpp:2692
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
Abstract operator.
Definition: operator.hpp:21
int Size() const
Get the size of the inverse matrix.
Definition: densemat.hpp:483
Vector & Singularvalues()
Definition: densemat.hpp:561
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:569
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:2641
void GradToDiv(Vector &div)
Definition: densemat.cpp:2417
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
Definition: densemat.cpp:3455
double * data
Definition: densemat.hpp:379