File: SylvMatrix.h

package info (click to toggle)
dynare 4.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,408 kB
  • sloc: cpp: 84,998; ansic: 29,058; pascal: 13,843; sh: 4,833; objc: 4,236; yacc: 3,622; makefile: 2,278; lex: 1,541; python: 236; lisp: 69; xml: 8
file content (109 lines) | stat: -rw-r--r-- 2,926 bytes parent folder | download
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
/* $Header: /var/lib/cvs/dynare_cpp/sylv/cc/SylvMatrix.h,v 1.1.1.1 2004/06/04 13:00:44 kamenik Exp $ */

/* Tag $Name:  $ */

#ifndef SYLV_MATRIX_H
#define SYLV_MATRIX_H

#include "GeneralMatrix.h"
#include "KronVector.h"

class SqSylvMatrix;

class SylvMatrix : public GeneralMatrix
{
public:
  SylvMatrix(int m, int n)
    : GeneralMatrix(m, n)
  {
  }
  SylvMatrix(const double *d, int m, int n)
    : GeneralMatrix(d, m, n)
  {
  }
  SylvMatrix(double *d, int m, int n)
    : GeneralMatrix(d, m, n)
  {
  }
  SylvMatrix(const GeneralMatrix &m)
    : GeneralMatrix(m)
  {
  }
  SylvMatrix(const GeneralMatrix &m, int i, int j, int nrows, int ncols)
    : GeneralMatrix(m, i, j, nrows, ncols)
  {
  }
  SylvMatrix(GeneralMatrix &m, int i, int j, int nrows, int ncols)
    : GeneralMatrix(m, i, j, nrows, ncols)
  {
  }
  SylvMatrix(const GeneralMatrix &a, const GeneralMatrix &b)
    : GeneralMatrix(a, b)
  {
  }

  /* this = |I 0|* this
     |0 m|         */
  void multLeftI(const SqSylvMatrix &m);
  /* this = |I  0|* this
     |0 m'|         */
  void multLeftITrans(const SqSylvMatrix &m);
  /* this = |0 a|*b, so that |0 a| is square */
  void multLeft(int zero_cols, const GeneralMatrix &a, const GeneralMatrix &b);
  /* this = this * (m\otimes m..\otimes m) */
  void multRightKron(const SqSylvMatrix &m, int order);
  /* this = this * (m'\otimes m'..\otimes m') */
  void multRightKronTrans(const SqSylvMatrix &m, int order);
  /* this = P*this, x = P*x, where P is gauss transformation setting
   * a given element to zero */
  void eliminateLeft(int row, int col, Vector &x);
  /* this = this*P, x = P'*x, where P is gauss transformation setting
   * a given element to zero */
  void eliminateRight(int row, int col, Vector &x);
};

class SqSylvMatrix : public SylvMatrix
{
public:
  SqSylvMatrix(int m) : SylvMatrix(m, m)
  {
  }
  SqSylvMatrix(const double *d, int m) : SylvMatrix(d, m, m)
  {
  }
  SqSylvMatrix(double *d, int m) : SylvMatrix(d, m, m)
  {
  }
  SqSylvMatrix(const SqSylvMatrix &m) : SylvMatrix(m)
  {
  }
  SqSylvMatrix(const GeneralMatrix &m, int i, int j, int nrows)
    : SylvMatrix(m, i, j, nrows, nrows)
  {
  }
  SqSylvMatrix(GeneralMatrix &m, int i, int j, int nrows)
    : SylvMatrix(m, i, j, nrows, nrows)
  {
  }
  SqSylvMatrix(const GeneralMatrix &a, const GeneralMatrix &b);
  const SqSylvMatrix &
  operator=(const SqSylvMatrix &m)
  {
    GeneralMatrix::operator=(m); return *this;
  }
  /* x = (this \otimes this..\otimes this)*d */
  void multVecKron(KronVector &x, const KronVector &d) const;
  /* x = (this' \otimes this'..\otimes this')*d */
  void multVecKronTrans(KronVector &x, const KronVector &d) const;
  /* a = inv(this)*a, b=inv(this)*b */
  void multInvLeft2(GeneralMatrix &a, GeneralMatrix &b,
                    double &rcond1, double &rcondinf) const;
  /* this = I */
  void setUnit();
};

#endif /* SYLV_MATRIX_H */

// Local Variables:
// mode:C++
// End: