korder_stoch.cc 4.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// Copyright 2005, Ondra Kamenik

#include "korder_stoch.hh"

/* Same as |@<|MatrixA| constructor code@>|, but the submatrix |gss_ys| is
   passed directly. */

MatrixAA::MatrixAA(const FSSparseTensor &f, const IntSequence &ss,
                   const TwoDMatrix &gss_ys, const PartitionY &ypart)
  : PLUMatrix(ypart.ny())
{
  zeros();

  IntSequence c(1); c[0] = 1;
  FGSTensor f_y(f, ss, c, TensorDimens(ss, c));
  add(1.0, f_y);

  c[0] = 0;
  FGSTensor f_yss(f, ss, c, TensorDimens(ss, c));
  TwoDMatrix sub(*this, ypart.nstat, ypart.nys());
  sub.multAndAdd(f_yss, gss_ys);

  calcPLU();
}

// |KOrderStoch| folded constructor code
KOrderStoch::KOrderStoch(const PartitionY &yp, int nu,
                         const TensorContainer<FSSparseTensor> &fcont,
                         const FGSContainer &hh, Journal &jr)
  : nvs(4), ypart(yp), journal(jr),
    _ug(4), _fg(4), _ugs(4), _fgs(4), _uG(4), _fG(4),
32
    _uh(nullptr), _fh(&hh),
33 34 35 36 37
    _uZstack(&_uG, ypart.nyss(), &_ug, ypart.ny(), ypart.nys(), nu),
    _fZstack(&_fG, ypart.nyss(), &_fg, ypart.ny(), ypart.nys(), nu),
    _uGstack(&_ugs, ypart.nys(), nu),
    _fGstack(&_fgs, ypart.nys(), nu),
    f(fcont),
38
    matA(*(fcont.get(Symmetry{1})), _uZstack.getStackSizes(), *(hh.get(Symmetry{1, 0, 0, 0})),
39 40 41 42 43 44 45 46 47 48 49 50 51 52
         ypart)
{
  nvs[0] = ypart.nys();
  nvs[1] = nu;
  nvs[2] = nu;
  nvs[3] = 1;
}

// |KOrderStoch| unfolded constructor code
KOrderStoch::KOrderStoch(const PartitionY &yp, int nu,
                         const TensorContainer<FSSparseTensor> &fcont,
                         const UGSContainer &hh, Journal &jr)
  : nvs(4), ypart(yp), journal(jr),
    _ug(4), _fg(4), _ugs(4), _fgs(4), _uG(4), _fG(4),
53
    _uh(&hh), _fh(nullptr),
54 55 56 57 58
    _uZstack(&_uG, ypart.nyss(), &_ug, ypart.ny(), ypart.nys(), nu),
    _fZstack(&_fG, ypart.nyss(), &_fg, ypart.ny(), ypart.nys(), nu),
    _uGstack(&_ugs, ypart.nys(), nu),
    _fGstack(&_fgs, ypart.nys(), nu),
    f(fcont),
59
    matA(*(fcont.get(Symmetry{1})), _uZstack.getStackSizes(), *(hh.get(Symmetry{1, 0, 0, 0})),
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
         ypart)
{
  nvs[0] = ypart.nys();
  nvs[1] = nu;
  nvs[2] = nu;
  nvs[3] = 1;
}

// |KOrderStoch| convenience method specializations
template<>
ctraits<KOrder::unfold>::Tg& KOrderStoch::g<KOrder::unfold>()
{
  return _ug;
}
template<>
const ctraits<KOrder::unfold>::Tg& KOrderStoch::g<KOrder::unfold>() const
{ return _ug;}
template<>
ctraits<KOrder::fold>::Tg& KOrderStoch::g<KOrder::fold>()
{
  return _fg;
}
template<>
const ctraits<KOrder::fold>::Tg& KOrderStoch::g<KOrder::fold>() const
{ return _fg;}
template<>
ctraits<KOrder::unfold>::Tgs& KOrderStoch::gs<KOrder::unfold>()
{
  return _ugs;
}
template<>
const ctraits<KOrder::unfold>::Tgs& KOrderStoch::gs<KOrder::unfold>() const
{ return _ugs;}
template<>
ctraits<KOrder::fold>::Tgs& KOrderStoch::gs<KOrder::fold>()
{
  return _fgs;
}
template<>
const ctraits<KOrder::fold>::Tgs& KOrderStoch::gs<KOrder::fold>() const
{ return _fgs;}
template<>
const ctraits<KOrder::unfold>::Tgss& KOrderStoch::h<KOrder::unfold>() const
{ return *_uh;}
template<>
const ctraits<KOrder::fold>::Tgss& KOrderStoch::h<KOrder::fold>() const
{ return *_fh;}
template<>
ctraits<KOrder::unfold>::TG& KOrderStoch::G<KOrder::unfold>()
{
  return _uG;
}
template<>
const ctraits<KOrder::unfold>::TG& KOrderStoch::G<KOrder::unfold>() const
{ return _uG;}
template<>
ctraits<KOrder::fold>::TG& KOrderStoch::G<KOrder::fold>()
{
  return _fG;
}
template<>
const ctraits<KOrder::fold>::TG& KOrderStoch::G<KOrder::fold>() const
{ return _fG;}
template<>
ctraits<KOrder::unfold>::TZXstack& KOrderStoch::Zstack<KOrder::unfold>()
{
  return _uZstack;
}
template<>
const ctraits<KOrder::unfold>::TZXstack& KOrderStoch::Zstack<KOrder::unfold>() const
{ return _uZstack;}
template<>
ctraits<KOrder::fold>::TZXstack& KOrderStoch::Zstack<KOrder::fold>()
{
  return _fZstack;
}
template<>
const ctraits<KOrder::fold>::TZXstack& KOrderStoch::Zstack<KOrder::fold>() const
{ return _fZstack;}
template<>
ctraits<KOrder::unfold>::TGXstack& KOrderStoch::Gstack<KOrder::unfold>()
{
  return _uGstack;
}
template<>
const ctraits<KOrder::unfold>::TGXstack& KOrderStoch::Gstack<KOrder::unfold>() const
{ return _uGstack;}
template<>
ctraits<KOrder::fold>::TGXstack& KOrderStoch::Gstack<KOrder::fold>()
{
  return _fGstack;
}
template<>
const ctraits<KOrder::fold>::TGXstack& KOrderStoch::Gstack<KOrder::fold>() const
{ return _fGstack;}