GMatrixSymmetric.i
5.76 KB
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
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
/***************************************************************************
* GMatrixSymmetric.i - Symmetric matrix class *
* ----------------------------------------------------------------------- *
* copyright (C) 2008-2016 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
/**
* @file GMatrixSymmetric.i
* @brief Symmetric matrix class definition.
* @author Juergen Knoedlseder
*/
%{
/* Put headers and other declarations here that are needed for compilation */
#include "GMatrixSymmetric.hpp"
#include "GTools.hpp"
%}
/* __ Includes ___________________________________________________________ */
%include "GTypemaps.i"
/***********************************************************************//**
* @class GMatrixSymmetric
*
* @brief Symmetric matrix class definition
***************************************************************************/
class GMatrixSymmetric : public GMatrixBase {
public:
// Constructors and destructors
GMatrixSymmetric(void);
explicit GMatrixSymmetric(const int& rows, const int& columns);
GMatrixSymmetric(const GMatrix& matrix);
GMatrixSymmetric(const GMatrixSparse& matrix);
GMatrixSymmetric(const GMatrixSymmetric& matrix);
virtual ~GMatrixSymmetric(void);
// Other operators
virtual GMatrixSymmetric operator+(const GMatrixSymmetric& matrix) const;
virtual GMatrixSymmetric operator-(const GMatrixSymmetric& matrix) const;
virtual GMatrixSymmetric operator-(void) const;
virtual GMatrixSymmetric& operator+=(const GMatrixSymmetric& matrix);
virtual GMatrixSymmetric& operator-=(const GMatrixSymmetric& matrix);
virtual GMatrixSymmetric& operator*=(const double& scaler);
// Implemented pure virtual base class methods
virtual void clear(void);
virtual GMatrixSymmetric* clone(void) const;
virtual std::string classname(void) const;
virtual double& at(const int& row, const int& column);
virtual GVector row(const int& row) const;
virtual void row(const int& row, const GVector& vector);
virtual GVector column(const int& column) const;
virtual void column(const int& column, const GVector& vector);
virtual void add_to_row(const int& row, const GVector& vector);
virtual void add_to_column(const int& column,
const GVector& vector);
virtual double fill(void) const;
virtual double min(void) const;
virtual double max(void) const;
virtual double sum(void) const;
// Other methods
GMatrixSymmetric transpose(void) const;
GMatrixSymmetric invert(void) const;
GVector solve(const GVector& vector) const;
GMatrixSymmetric abs(void) const;
GMatrix extract_lower_triangle(void) const;
GMatrix extract_upper_triangle(void) const;
GMatrixSymmetric cholesky_decompose(const bool& compress = true) const;
GVector cholesky_solver(const GVector& vector,
const bool& compress = true) const;
GMatrixSymmetric cholesky_invert(const bool& compress = true) const;
};
/***********************************************************************//**
* @brief GMatrixSymmetric class extension
***************************************************************************/
%extend GMatrixSymmetric {
double __getitem__(int GTuple[2]) {
return (*self)(GTuple[0], GTuple[1]);
}
void __setitem__(int GTuple[2], double value) {
(*self)(GTuple[0], GTuple[1]) = value;
}
GVector __mul__(const GVector& vector) {
return ((*self) * vector);
}
GMatrixSymmetric __mul__(const GMatrixSymmetric& matrix) {
return ((*self) * matrix);
}
GMatrixSymmetric __mul__(const double &scalar) {
return ((*self) * scalar);
}
// Python 2.x
GMatrixSymmetric __div__(const double &scalar) {
return ((*self) / scalar);
}
// Python 3.x
GMatrixSymmetric __truediv__(const double& scalar) const {
return ((*self) / scalar);
}
// Python 2.x operator/=
GMatrixSymmetric __idiv__(const double& scalar) {
self->operator/=(scalar);
return (*self);
}
// Python 3.x operator/=
GMatrixSymmetric __itruediv__(const double& scalar) {
self->operator/=(scalar);
return (*self);
}
GMatrixSymmetric copy() {
return (*self);
}
GMatrixSymmetric set(const double& value) {
(*self) = value;
return (*self);
}
};