Commit ebbe02cd2506f1ca553790bc1f1fe968ad119c12

Authored by knodlseder
1 parent dbd56b4e

Removed GSymSparseMatrix.hpp

Showing 1 changed file with 0 additions and 277 deletions
src/GSymSparseMatrix.hpp deleted
1   -/***************************************************************************
2   - * GSymMatrix.hpp - symmetric matrix class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2006 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -
14   -#ifndef GSYMMATRIX_HPP
15   -#define GSYMMATRIX_HPP
16   -
17   -/* __ Includes ___________________________________________________________ */
18   -#include "GException.hpp"
19   -#include "GVector.hpp"
20   -#include "GMatrix.hpp"
21   -
22   -/* __ Namespaces _________________________________________________________ */
23   -using namespace std;
24   -
25   -/* __ Enumerators ________________________________________________________ */
26   -
27   -/* __ Structures _________________________________________________________ */
28   -
29   -/* __ Prototypes _________________________________________________________ */
30   -
31   -
32   -/***************************************************************************
33   - * GSymMatrix class definition *
34   - ***************************************************************************/
35   -class GSymMatrix : public GMatrix {
36   - // Operator friends
37   - friend GSymMatrix operator* (const double &a, const GSymMatrix &b);
38   -
39   - // I/O friends
40   - // ...
41   -
42   - // Friend functions
43   - friend GSymMatrix transpose(const GSymMatrix &m);
44   - friend GSymMatrix cholesky_decompose(const GSymMatrix &m);
45   - friend GMatrix full(const GSymMatrix &m);
46   - friend GMatrix lower_triangle(const GSymMatrix &m);
47   - friend GMatrix upper_triangle(const GSymMatrix &m);
48   -public:
49   - // Constructors and destructors (not inherited)
50   - GSymMatrix(unsigned rows, unsigned cols);
51   - ~GSymMatrix() { }
52   -
53   - // Matrix element access operators
54   - double& operator() (unsigned row, unsigned col);
55   - const double& operator() (unsigned row, unsigned col) const;
56   -
57   - // Matrix assignment operators (not inherited)
58   - GSymMatrix& operator= (const GSymMatrix& m);
59   - GSymMatrix& operator= (const double& d);
60   -
61   - // Specific matrix operators (structure dependent)
62   - GSymMatrix operator+ (const GSymMatrix& m) const;
63   - GSymMatrix operator- (const GSymMatrix& m) const;
64   - GSymMatrix operator* (const GSymMatrix& m) const;
65   - GVector operator* (const GVector& v) const;
66   - GSymMatrix operator* (const double& d) const;
67   - GSymMatrix operator/ (const double& d) const;
68   - GSymMatrix operator- () const;
69   -
70   - // Specific matrix functions
71   - void transpose(); // Inplace transpose of matrix
72   - void cholesky_decompose(); // Inplace Cholesky decomposition
73   -
74   - // Exception: Matrix not symmetric
75   - class not_sym : public GException {
76   - public:
77   - not_sym(string origin, unsigned cols, unsigned rows);
78   - };
79   -
80   - // Exception: Matrix not positive definite
81   - class not_pos_definite : public GException {
82   - public:
83   - not_pos_definite(string origin, unsigned row, double sum);
84   - };
85   -private:
86   -};
87   -
88   -
89   -/***************************************************************************
90   - * Inline members that override base class members *
91   - ***************************************************************************/
92   -// Matrix assignment operator: GSymMatrix = GSymMatrix
93   -inline
94   -GSymMatrix& GSymMatrix::operator= (const GSymMatrix& m)
95   -{
96   - if (this != &m)
97   - this->GMatrix::operator=(m);
98   -}
99   -
100   -// Scalar assignment operator: GSymMatrix = double
101   -inline
102   -GSymMatrix& GSymMatrix::operator= (const double& d)
103   -{
104   - this->GMatrix::operator=(d);
105   -}
106   -
107   -// Matrix element access operator: GSymMatrix(row,col)
108   -inline
109   -double& GSymMatrix::operator() (unsigned row, unsigned col)
110   -{
111   - #if G_RANGE_CHECK
112   - if (row >= m_rows || col >= m_cols)
113   - throw out_of_range("GSymMatrix access", row, col, m_rows, m_cols);
114   - #endif
115   - unsigned inx = (row >= col) ? m_colstart[col]+(row-col) : m_colstart[row]+(col-row);
116   - return m_data[inx];
117   -}
118   -
119   -// Matrix element access operator (const version): GSymMatrix(row,col)
120   -inline
121   -const double& GSymMatrix::operator() (unsigned row, unsigned col) const
122   -{
123   - #if G_RANGE_CHECK
124   - if (row >= m_rows || col >= m_cols)
125   - throw out_of_range("GSymMatrix access", row, col, m_rows, m_cols);
126   - #endif
127   - unsigned inx = (row >= col) ? m_colstart[col]+(row-col) : m_colstart[row]+(col-row);
128   - return m_data[inx];
129   -}
130   -
131   -// Matrix addition: GSymMatrix + GSymMatrix
132   -inline
133   -GSymMatrix GSymMatrix::operator+ (const GSymMatrix& m) const
134   -{
135   - GSymMatrix result = *this;
136   - result += m;
137   - return result;
138   -}
139   -
140   -// Matrix subtraction: GSymMatrix - GSymMatrix
141   -inline
142   -GSymMatrix GSymMatrix::operator- (const GSymMatrix& m) const
143   -{
144   - GSymMatrix result = *this;
145   - result -= m;
146   - return result;
147   -}
148   -
149   -// Matrix multiplication: GSymMatrix * GSymMatrix
150   -inline
151   -GSymMatrix GSymMatrix::operator* (const GSymMatrix& m) const
152   -{
153   - #if G_RANGE_CHECK
154   - if (m_cols != m.m_rows)
155   - throw GMatrix::dim_mult_mismatch("GSymMatrix multiplication", m_cols, m.m_rows);
156   - #endif
157   - GSymMatrix result(m_rows,m.m_cols);
158   - for (unsigned row = 0; row < m_rows; ++row) {
159   - for (unsigned col = 0; col < m.m_cols; ++col) {
160   - double sum = 0.0;
161   - for (unsigned i = 0; i < m_cols; ++i)
162   - sum += (*this)(row,i)*m(i,col);
163   - result(row,col) = sum;
164   - }
165   - }
166   - return result;
167   -}
168   -
169   -// Matrix/Vector multiplication: GSymMatrix * GVector
170   -inline
171   -GVector GSymMatrix::operator* (const GVector& v) const
172   -{
173   - return (this->GMatrix::operator*(v));
174   -}
175   -
176   -// Matrix scaling: GSymMatrix * double
177   -inline
178   -GSymMatrix GSymMatrix::operator* (const double &d) const
179   -{
180   - GSymMatrix result = (*this);
181   - result *= d;
182   - return result;
183   -}
184   -
185   -// Matrix inverse scaling: GSymMatrix * double
186   -inline
187   -GSymMatrix GSymMatrix::operator/ (const double &d) const
188   -{
189   - GSymMatrix result = (*this);
190   - result /= d;
191   - return result;
192   -}
193   -
194   -// Unary minus operator
195   -inline
196   -GSymMatrix GSymMatrix::operator- ( ) const
197   -{
198   - GSymMatrix result = *this;
199   - for (unsigned i = 0; i < m_elements; ++i)
200   - result.m_data[i] = -result.m_data[i];
201   - return result;
202   -}
203   -
204   -// Matrix transpose
205   -inline
206   -void GSymMatrix::transpose()
207   -{
208   - return;
209   -}
210   -
211   -
212   -
213   -/***************************************************************************
214   - * Inline friends *
215   - ***************************************************************************/
216   -// Matrix scaling: double * GSymMatrix
217   -inline
218   -GSymMatrix operator* (const double& a, const GSymMatrix& b)
219   -{
220   - GSymMatrix result = b;
221   - result *= a;
222   - return result;
223   -}
224   -
225   -// Matrix transpose: transpose(GSymMatrix)
226   -inline
227   -GSymMatrix transpose(const GSymMatrix &m)
228   -{
229   - return m;
230   -}
231   -
232   -// Cholesky decomposition: cholesky_decompose(GSymMatrix)
233   -inline
234   -GSymMatrix cholesky_decompose(const GSymMatrix &m)
235   -{
236   - GSymMatrix result = m;
237   - result.cholesky_decompose();
238   - return result;
239   -}
240   -
241   -// Convert symmetric matrix into full matrix: full(GSymMatrix)
242   -inline
243   -GMatrix full(const GSymMatrix& m)
244   -{
245   - GMatrix result(m.m_rows,m.m_cols);
246   - for (unsigned row = 0; row < m.m_rows; ++row) {
247   - for (unsigned col = 0; col < m.m_cols; ++col)
248   - result(row,col) = m(row,col);
249   - }
250   - return result;
251   -}
252   -
253   -// Convert symmetric matrix into lower triangle full matrix: lower_triangle(GSymMatrix)
254   -inline
255   -GMatrix lower_triangle(const GSymMatrix &m)
256   -{
257   - GMatrix result(m.m_rows,m.m_cols);
258   - for (unsigned row = 0; row < m.m_rows; ++row) {
259   - for (unsigned col = 0; col <= row; ++col)
260   - result(row,col) = m.m_data[m.m_colstart[col]+(row-col)];
261   - }
262   - return result;
263   -}
264   -
265   -// Convert symmetric matrix into upper triangle full matrix: lower_triangle(GSymMatrix)
266   -inline
267   -GMatrix upper_triangle(const GSymMatrix &m)
268   -{
269   - GMatrix result(m.m_rows,m.m_cols);
270   - for (unsigned row = 0; row < m.m_rows; ++row) {
271   - for (unsigned col = row; col < m.m_cols; ++col)
272   - result(row,col) = m.m_data[m.m_colstart[row]+(col-row)];
273   - }
274   - return result;
275   -}
276   -
277   -#endif /* GSYMMATRIX_HPP */