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_LU_FACTOR_H
7 #define MYRAMATH_MULTIFRONTAL_LU_FACTOR_H
8 
14 #include <myramath/multifrontal/detail/lu/factor.h>
15 
16 namespace myra {
17 namespace multifrontal {
18 namespace lu {
19 namespace factor {
20 
21 template<class Number> class JobGraphBase : public ::myra::multifrontal::detail::lu::factor::JobGraphBase2<LUKernel<Number> >
22  {
23  public:
24 
25  // Structural typedefs for base class.
26  typedef ::myra::multifrontal::detail::lu::factor::JobGraphBase2<LUKernel<Number> > Base;
27 
28  // Typedefs related to numeric storage.
29  typedef LUKernel<Number> Kernel;
30  typedef ::myra::multifrontal::detail::lu::LUContainer<Kernel> LUContainer;
31 
32  // Constructor - requires reference to LUContainer under construction.
33  JobGraphBase(LUContainer* in_lucontainer)
34  : Base(in_lucontainer), lucontainer(in_lucontainer) { }
35 
36  // Virtual copy constructor.
37  virtual ::myra::JobGraphBase* clone() const
38  { return new JobGraphBase(*this); }
39 
40  protected:
41 
42  // Factors An(k,k) = Ln(k,k)*Un(k,k)
43  virtual uint64_t factor(int n, int k)
44  {
45  // Assign internode contributions if on first k-iteration.
46  if (k == 0) this->assign_contributions(n,k,k);
47  return lucontainer->factor(n,k);
48  }
49 
50  // Solves Ln(i,k)*Un(k,k) = An(i,k)
51  virtual uint64_t backsolveL(int n, int k, int i)
52  {
53  // Assign internode contributions if on first k-iteration.
54  if (k == 0) this->assign_contributions(n,i,k);
55  const Kernel& Un_kk = this->lu(n,k);
56  MatrixRange<Number> An_ik = this->a(n,i,k);
57  return Un_kk.solveU(An_ik,'R','N');
58  }
59 
60  // Solves Ln(k,k)*Un(k,j) = An(k,j)
61  virtual uint64_t backsolveU(int n, int k, int j)
62  {
63  // Assign internode contributions if on first k-iteration.
64  if (k == 0) this->assign_contributions(n,k,j);
65  const Kernel& Ln_kk = this->lu(n,k);
66  MatrixRange<Number> An_kj = this->a(n,k,j);
67  return Ln_kk.solveL(An_kj,'L','N');
68  }
69 
70  // Downdates An(i,j) -= Ln(i,k)*Un(k,j)
71  virtual uint64_t downdate(int n, int k, int i, int j)
72  {
73  // Useful constants.
74  Number one(1);
75  Number zero(0);
76  // Downdate An(i,j) -= Ln(i,k)*Un(k,j) [gemm]
77  MatrixRange<Number> An_ij = this->a(n,i,j);
78  CMatrixRange<Number> Ln_ik = this->lu(n,i,k);
79  CMatrixRange<Number> Un_kj = this->lu(n,k,j);
80  // Carefully choose beta and order of steps to avoid workspace initialization.
81  Number beta = k ? one : zero;
82  uint64_t w = gemm_nwork(An_ij, Ln_ik, 'N', Un_kj, 'N', -one, beta);
83  // Add internode contributions if on first k-iteration.
84  if (k == 0) this->add_contributions(n,i,j);
85  return w;
86  }
87 
88  private:
89 
90  // Reference to LUContainer under construction.
91  LUContainer* lucontainer;
92 
93  }; // class JobGraph
94 
95 } } } } // namespace
96 
97 #endif
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Factors A into L*U, presents solve methods.
Definition: Kernel.h:35
Represents a mutable MatrixRange.
Definition: conjugate.h:26
uint64_t solveL(const MatrixRange< Number > &B, char side, char op) const
Solves op(L)*X=B or X*op(L)=B, overwrites B with X.
Definition: Kernel.h:66
uint64_t solveU(const MatrixRange< Number > &B, char side, char op) const
Solves op(U)*X=B or X*op(U)=B, overwrites B with X.
Definition: Kernel.h:135
Definition: partialsolve.h:32