Debian Codegraph @

dwsys/Eigen_def.h

raw symbols SCIP
1 /* Eigen_def.h
2 *
3 * Copyright (C) 1993-2018, 2026 David Weenink
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /*
20 Eigen represents the eigenvalues and eigenvectors of a square matrix.
21 For a general square matrix some of the eigenvalues will be complex numbers
22 and also some of the eigenvectors will be complex vectors.
23 Most matrices we use are symmetric, which means that the
24 eigenvalues and eigenvectors are real numbers.
25 For these cases we don't need the imaginary parts:
26 we don't read and write them.
27 */
28
29 #define ooSTRUCT Eigen
30 oo_DEFINE_CLASS (Eigen, Daata)
31
32 oo_INTEGER (numberOfEigenvalues)
33 oo_INTEGER (dimension)
34 oo_VEC (eigenvalues, numberOfEigenvalues)
35 oo_MAT (eigenvectors, numberOfEigenvalues, dimension)
36
37 #if oo_READING
38 oo_VERSION_UNTIL (1)
39 onlyReals = true;
40 oo_VERSION_ELSE
41 oo_BOOLEAN (onlyReals)
42 if (! onlyReals) {
43 oo_VEC (eigenvalues_im, numberOfEigenvalues)
44 oo_MAT (eigenvectors_im, numberOfEigenvalues, dimension)
45 }
46 oo_VERSION_END
47 #else
48 oo_BOOLEAN (onlyReals) // convenience
49 #if oo_WRITING || oo_COMPARING
50 if (! onlyReals) {
51 oo_VEC (eigenvalues_im, numberOfEigenvalues)
52 oo_MAT (eigenvectors_im, numberOfEigenvalues, dimension)
53 }
54 #else
55 oo_VEC (eigenvalues_im, numberOfEigenvalues)
56 oo_MAT (eigenvectors_im, numberOfEigenvalues, dimension)
57 #endif
58 #endif
59
60 oo_END_CLASS (Eigen)
61
62 #undef ooSTRUCT
63
64 #define ooSTRUCT Eigen2
65 oo_DEFINE_CLASS (Eigen2, Daata)
66
67 oo_INTEGER (numberOfEigenvalues)
68 oo_INTEGER (dimension)
69
70 #if oo_READING
71 oo_VERSION_UNTIL (1)
72 /*
73 Convert the real vector and matrix in the file to complex.
74 */
75 autoVEC evals = raw_VEC (numberOfEigenvalues);
76 autoMAT evecs = raw_MAT (numberOfEigenvalues, dimension);
77 #if oo_READING_BINARY
78 evals = vector_readBinary_r64 (numberOfEigenvalues, _filePointer_);
79 evecs = matrix_readBinary_r64 (numberOfEigenvalues, dimension, _filePointer_);
80 #else
81 evals = vector_readText_r64 (numberOfEigenvalues, _textSource_, "eigenvalues");
82 evecs = matrix_readText_r64 (numberOfEigenvalues, dimension, _textSource_, "eigenvectors");
83 #endif
84 for (integer i = 1; i <= numberOfEigenvalues; i ++) {
85 eigenvalues [i] .real (evals [i]);
86 for (integer j = 1; j <= dimension; j ++)
87 eigenvectors [i] [j] .real (evecs [i] [j]);
88 }
89 onlyReals = true;
90 oo_VERSION_ELSE
91 oo_COMPVEC (eigenvalues, numberOfEigenvalues)
92 oo_COMPMAT (eigenvectors, numberOfEigenvalues, dimension)
93 oo_BOOLEAN (onlyReals) // commodity
94 oo_VERSION_END
95 #else
96 oo_COMPVEC (eigenvalues, numberOfEigenvalues)
97 oo_COMPMAT (eigenvectors, numberOfEigenvalues, dimension)
98 oo_BOOLEAN (onlyReals) // commodity
99 #endif
100
101 oo_END_CLASS (Eigen2)
102 #undef ooSTRUCT
103
104 /* End of file Eigen_def.h */