| 1 | #pragma once |
| 2 | /* MAT_numerics.h |
| 3 | * |
| 4 | * Copyright (C) 2018-2019, 2026 David Weenink |
| 5 | * |
| 6 | * This code is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or (at |
| 9 | * your option) any later version. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | * See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "melder.h" |
| 21 | #include "MATTypes_enums.h" |
| 22 | #include "Eigen.h" |
| 23 | |
| 24 | void MAT_into_Eigen (constMATVU const& mat, kMAT_TYPE matType, Eigen me, bool sortAscending); |
| 25 | |
| 26 | void MAT_getEigenSystemFromSymmetricMatrix (constMAT a, autoMAT *out_eigenvectors, autoVEC *out_eigenvalues, bool sortAscending); |
| 27 | /* |
| 28 | Calculates the eigenvectors and eigenvalues of a symmetric matrix; |
| 29 | Input: |
| 30 | a, a symmetric matrix of size nrow x nrow (a.ncol == a.nrow) |
| 31 | only the upper-half of the matrix is used in the calculation |
| 32 | sortAscending if true eigenvalues (and corresponding eigenvectors) are sorted ascending |
| 33 | Output: |
| 34 | if (out_eigenvalues) eigenvalues sorted |
| 35 | if (out_eigenvectors) eigenvectors corresponding to the eigenvalues, stored as row-wise vectors. |
| 36 | */ |
| 37 | |
| 38 | void MAT_getEigenSystemFromSymmetricMatrix_preallocated (MAT eigenvectors, VEC eigenvalues, constMATVU const& a, bool sortAscending); |
| 39 | /* |
| 40 | Input: |
| 41 | a, a symmetric a.ncol x a.ncol matrix |
| 42 | only the upper-half of the matrix is used in the calculation |
| 43 | eigenvalues, a vector of size ncol |
| 44 | eigenvectors, a matrix a.ncol x a.ncol |
| 45 | sortAscending if true eigenvalues (and corresponding eigenvectors) will be sorted ascending |
| 46 | Output: |
| 47 | eigenvectors, stored row-wise |
| 48 | eigenvalues, eigenvalues sorted according to sortAscending |
| 49 | */ |
| 50 | |
| 51 | void MAT_asPrincipalComponents_preallocated (MATVU pc, constMATVU const& m, integer numberOfComponents); |
| 52 | autoMAT MAT_asPrincipalComponents (constMATVU m, integer numberOfComponents); |
| 53 | |
| 54 | void MATpseudoInverse (MATVU const& target, constMATVU const& mat, double tolerance); |
| 55 | autoMAT newMATpseudoInverse (constMATVU const& mat, double tolerance); |
| 56 | /* |
| 57 | Determines the pseudo-inverse Y^-1 of Y [1..nrow] [1..ncol] via s.v.d. |
| 58 | Alternative notation for pseudo-inverse: (Y'.Y)^-1.Y' |
| 59 | Returns a [1..ncol] [1..nrow] matrix |
| 60 | */ |
| 61 | |
| 62 | /* End of file MAT_numerics.h */ |