gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
Gambit::Cholesky Class Reference

#include <cholesky.hpp>

Collaboration diagram for Gambit::Cholesky:

Public Member Functions

 Cholesky ()
 
 Cholesky (const int num)
 
bool EnterMat (std::vector< std::vector< double >> &a)
 
void ElMult (std::vector< double > &y) const
 
double Square (const std::vector< double > &y, const std::vector< double > &y0)
 
double DetSqrt ()
 

Private Attributes

std::vector< std::vector< double > > el
 

Detailed Description

Definition at line 26 of file cholesky.hpp.

Constructor & Destructor Documentation

◆ Cholesky() [1/2]

Gambit::Cholesky::Cholesky ( )
inline

Definition at line 32 of file cholesky.hpp.

32 {}

◆ Cholesky() [2/2]

Gambit::Cholesky::Cholesky ( const int  num)
inline

Definition at line 34 of file cholesky.hpp.

34 : el(num, std::vector<double>(num)) {}
std::vector< std::vector< double > > el
Definition: cholesky.hpp:29

Member Function Documentation

◆ DetSqrt()

double Gambit::Cholesky::DetSqrt ( )
inline

Definition at line 107 of file cholesky.hpp.

Referenced by Gambit::Priors::Cauchy::operator()(), Gambit::Priors::Gaussian::operator()(), and Gambit::Priors::LogNormal::operator()().

108  {
109  double temp = 1.0;
110  int num = el.size();
111  for (int i = 0; i < num; i++)
112  temp *= el[i][i];
113  return temp;
114  }
std::vector< std::vector< double > > el
Definition: cholesky.hpp:29
Here is the caller graph for this function:

◆ ElMult()

void Gambit::Cholesky::ElMult ( std::vector< double > &  y) const
inline

Definition at line 69 of file cholesky.hpp.

References b.

Referenced by Gambit::Priors::Cauchy::transform(), Gambit::Priors::Gaussian::transform(), and Gambit::Priors::LogNormal::transform().

70  {
71  int i, j;
72  int num = el.size();
73  std::vector<double> b(num);
74  for(i = 0; i < num; i++)
75  {
76  b[i] = 0.0;
77  for (j = 0; j <= i; j++)
78  {
79  b[i] += el[i][j]*y[j];
80  }
81  }
82 
83  y = b;
84  }
START_MODEL b
Definition: demo.hpp:235
std::vector< std::vector< double > > el
Definition: cholesky.hpp:29
Here is the caller graph for this function:

◆ EnterMat()

bool Gambit::Cholesky::EnterMat ( std::vector< std::vector< double >> &  a)
inline

Definition at line 36 of file cholesky.hpp.

Referenced by Gambit::Priors::Cauchy::Cauchy(), Gambit::Priors::Gaussian::Gaussian(), Gambit::Priors::LogNormal::LogNormal(), and objective_plugin().

37  {
38  el = a;
39  int num = el.size();
40  double sum = 0;
41  int i, j, k;
42 
43  for (i = 0; i < num; i++)
44  {
45  for (j = i; j < num; j++)
46  {
47  for(sum = el[i][j], k = i - 1; k >= 0; k--)
48  sum -= el[i][k]*el[j][k];
49  if(i == j)
50  {
51  if(sum <= 0.0)
52  {
53  return false;
54  }
55  el[i][i] = std::sqrt(sum);
56  }
57  else
58  el[j][i] = sum/el[i][i];
59  }
60  }
61 
62  for (i = 0; i < num; i++)
63  for (j = 0; j < i; j++)
64  el[j][i] = 0.0;
65 
66  return true;
67  }
std::vector< std::vector< double > > el
Definition: cholesky.hpp:29
Here is the caller graph for this function:

◆ Square()

double Gambit::Cholesky::Square ( const std::vector< double > &  y,
const std::vector< double > &  y0 
)
inline

Definition at line 86 of file cholesky.hpp.

Referenced by objective_plugin(), Gambit::Priors::Cauchy::operator()(), Gambit::Priors::Gaussian::operator()(), and Gambit::Priors::LogNormal::operator()().

87  {
88  int i, j, num = y.size();
89  double sum;
90  std::vector<double> x(num);
91 
92  for (i = 0; i < num; i++)
93  {
94  for (sum = (y[i]-y0[i]), j=0; j < i; j++)
95  sum -= el[i][j]*x[j];
96 
97  x[i]=sum/el[i][i];
98  }
99 
100  sum = 0.0;
101  for (i = 0; i < num; i++)
102  sum += x[i]*x[i];
103 
104  return sum;
105  }
std::vector< std::vector< double > > el
Definition: cholesky.hpp:29
Here is the caller graph for this function:

Member Data Documentation

◆ el

std::vector<std::vector<double> > Gambit::Cholesky::el
private

Definition at line 29 of file cholesky.hpp.


The documentation for this class was generated from the following file: