MyraMath
factor.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_MULTIFRONTAL_RCHOLESKY_FACTOR_H
7 #define MYRAMATH_MULTIFRONTAL_RCHOLESKY_FACTOR_H
8 
14 #include <myramath/multifrontal/detail/llt/factor.h>
15 
17 
18 #include <myramath/dense/Matrix.h>
22 #include <myramath/dense/trsm.h>
23 #include <myramath/dense/gemm.h>
24 #include <myramath/dense/syrk.h>
25 #include <myramath/dense/detail/nwork.h>
26 
27 namespace myra {
28 namespace multifrontal {
29 namespace rcholesky {
30 namespace factor {
31 
32 template<class Precision> class JobGraphBase : public ::myra::multifrontal::detail::llt::factor::JobGraphBase2< RCholeskyKernel<Precision> >
33  {
34  public:
35 
36  // Structural typedefs for base class.
37  typedef Precision Number;
39  typedef ::myra::multifrontal::detail::llt::factor::JobGraphBase2<Kernel> Base;
40 
41  // Typedefs related to numeric storage.
42  typedef ::myra::multifrontal::detail::llt::LContainer<Kernel> LContainer;
44  typedef Matrix<Number> Block;
45 
46  // Constructor - requires reference to LContainer under construction.
47  JobGraphBase(LContainer* in_lcontainer)
48  : Base(in_lcontainer), lcontainer(in_lcontainer) { }
49 
50  // Virtual copy constructor.
51  virtual ::myra::JobGraphBase* clone() const
52  { return new JobGraphBase(*this); }
53 
54  protected:
55 
56  // Factors An(k,k) = Ln(k,k)*Ln(k,k)'
57  virtual uint64_t factor(int n, int k)
58  {
59  // Assign internode contributions if on first k-iteration.
60  if (k == 0) this->assign_contributions(n,k);
61  return lcontainer->factor(n,k);
62  }
63 
64  // Solves Ln(i,k)*Ln(k,k)' = An(i,k)
65  virtual uint64_t trsm(int n, int k, int i)
66  {
67  // Assign internode contributions if on first k-iteration.
68  if (k == 0) this->assign_contributions(n,i,k);
69  const Kernel& Ln_kk = this->l(n,k);
70  MatrixRange<Number> An_ik = this->a(n,i,k);
71  return Ln_kk.solveL(An_ik,'R','T');
72  }
73 
74  // Downdates An(ij,ij) -= Ln(ij,k)*Ln(ij,k)'
75  virtual uint64_t rankk(int n, int k, int ij)
76  {
77  // Useful constants.
78  Number one(1);
79  Number zero(0);
80  // Downdate An(ij,ij) -= Ln(ij,k)*Ln(ij,k)' [syrk]
81  LowerMatrixRange<Number> An_ij = this->a(n,ij);
82  CMatrixRange<Number> Ln_ijk = this->l(n,ij,k);
83  // Carefully choose beta and order of steps to avoid workspace initialization.
84  Number beta = k ? one : zero;
85  uint64_t w = syrk_nwork(An_ij, Ln_ijk, 'N', -one, beta);
86  // Add internode contributions if on first k-iteration.
87  if (k == 0) this->add_contributions(n,ij);
88  return w;
89  }
90 
91  // Downdates An(i,j) -= Ln(i,k)*Ln(j,k)'
92  virtual uint64_t gemm(int n, int k, int i, int j)
93  {
94  // Useful constants.
95  Number one(1);
96  Number zero(0);
97  // Downdate An(i,j) -= Ln(i,k)*Ln(j,k)' [gemm]
98  MatrixRange<Number> An_ij = this->a(n,i,j);
99  CMatrixRange<Number> Ln_ik = this->l(n,i,k);
100  CMatrixRange<Number> Ln_jk = this->l(n,j,k);
101  // Carefully choose beta and order of steps to avoid workspace initialization.
102  Number beta = k ? one : zero;
103  uint64_t w = gemm_nwork(An_ij, Ln_ik, 'N', Ln_jk, 'T', -one, beta);
104  // Add internode contributions if on first k-iteration.
105  if (k == 0) this->add_contributions(n,i,j);
106  return w;
107  }
108 
109  private:
110 
111  // Reference to LContainer under construction.
112  LContainer* lcontainer;
113 
114  }; // class JobGraph
115 
116 } } } } // namespace
117 
118 #endif
Interface class for representing subranges of dense Matrix&#39;s.
Represents a mutable LowerMatrixRange.
Definition: conjugate.h:28
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
uint64_t solveL(const MatrixRange< Precision > &B, char side, char op) const
Solves op(L)*X=B or X*op(L)=B, overwrites B with X.
Definition: Kernel.h:61
Range construct for a lower triangular matrix stored in rectangular packed format.
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Routines for backsolving by a triangular Matrix or LowerMatrix.
Specialized container for a lower triangular matrix, O(N^2/2) storage. Used by symmetry exploiting ma...
Pivot factorization for SparseRCholeskySolver.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
General purpose dense matrix container, O(i*j) storage.
Factors A into L*L&#39;, presents solve methods.
Definition: Kernel.h:34
Stores a lower triangular matrix in rectangular packed format.
Definition: conjugate.h:22
Routines for symmetric rank-k updates, a specialized form of Matrix*Matrix multiplication.
Variety of routines all for dense Matrix*Matrix multiplies. Delegates to the BLAS.