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