MyraMath
schursolvel.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_SCHURSOLVEL_H
7 #define MYRAMATH_MULTIFRONTAL_LU_SCHURSOLVEL_H
8 
14 #include <myramath/multifrontal/detail/schursolve.h>
15 
16 namespace myra {
17 namespace multifrontal {
18 namespace lu {
19 namespace schursolvel {
20 
21 template<class Number> class JobGraphBase : public ::myra::multifrontal::detail::schursolve::JobGraphBase2<Number>
22  {
23  public:
24 
25  // Structural typedefs for base class.
26  typedef LUKernel<Number> Kernel;
27  typedef ::myra::multifrontal::detail::schursolve::JobGraphBase2<Number> Base;
28 
29  // Typedefs related to numeric storage.
30  typedef ::myra::multifrontal::detail::lu::LUContainer<Kernel> LUContainer;
31  typedef ::myra::multifrontal::detail::XContainer<Number> XContainer;
32  typedef ::myra::multifrontal::detail::XContributor<Number> XContributor;
33 
34  // Constructor - requires const reference to LuContainer, mutable reference to XContainer
35  JobGraphBase(const LUContainer* in_lucontainer, XContainer* in_xcontainer, const XContributor* in_xcontributor)
36  : Base(&in_xcontainer->tree(), in_xcontainer, in_xcontributor), lucontainer(in_lucontainer), xcontainer(in_xcontainer), xcontributor(in_xcontributor) { }
37 
38  // Virtual copy constructor.
39  virtual ::myra::JobGraphBase* clone() const
40  { return new JobGraphBase(*this); }
41 
42  protected:
43 
44  // Accessors for L Kernel's / Block's
45  const Kernel& l(int n, int ij) const
46  { return lucontainer->lu(this->s2a(n),ij); }
47  CMatrixRange<Number> l(int n, int i, int j) const
48  { return lucontainer->lu(this->s2a(n),i,j); }
49 
50  // Solves Ln(k,k)*Xn(k,j) = Bn(k,j)
51  virtual uint64_t backsolve(int n, int k, int j)
52  {
53  // Assign internode contributions on first k-iteration.
54  if (k == 0) this->assign_contributions(n,k,j);
55  const Kernel& Ln_kk = this->l(n,k);
56  MatrixRange<Number> Bn_kj = this->b(n,k,j);
57  return Ln_kk.solveL(Bn_kj,'L','N');
58  }
59 
60  // Downdates Bn(i,j) -= Ln(i,k)*Xn(k,j)
61  virtual uint64_t downdate(int n, int k, int i, int j)
62  {
63  // Useful constants.
64  Number one(1);
65  Number zero(0);
66  // Downdate Bn(i,j) -= Ln(i,k)*Xn(k,j) [gemm]
67  MatrixRange<Number> Bn_ij = this->b(n,i,j);
68  CMatrixRange<Number> Ln_ik = this->l(n,i,k);
69  CMatrixRange<Number> Xn_kj = this->x(n,k,j);
70  // Carefully choose beta and order of steps to avoid workspace initialiation.
71  Number beta = k ? one : zero;
72  uint64_t w = gemm_nwork(Bn_ij, Ln_ik, 'N', Xn_kj, 'N', -one, beta);
73  // Add internode contributions if on first k-iteration.
74  if (k == 0) this->add_contributions(n,i,j);
75  return w;
76  }
77 
78  private:
79 
80  // Reference to LUContainer (const).
81  const LUContainer* lucontainer;
82 
83  // Reference to XContainer (mutable)
84  XContainer* xcontainer;
85  const XContributor* xcontributor;
86 
87  }; // class JobGraph
88 
89 } } } } // namespace
90 
91 #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
Definition: partialsolve.h:32
Definition: schurgemm.h:25