| 1 |
/* Eigen_and_Procrustes.cpp |
| 2 |
* Copyright (C) 2004-2019 David Weenink |
| 3 |
* |
| 4 |
* This code is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 7 |
* your option) any later version. |
| 8 |
* |
| 9 |
* This code is distributed in the hope that it will be useful, but |
| 10 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
/* djmw 2004 Initial version */ |
| 19 |
|
| 20 |
#include "Eigen_and_Procrustes.h" |
| 21 |
#include "Configuration_and_Procrustes.h" |
| 22 |
#include "NUM2.h" |
| 23 |
|
| 24 |
autoProcrustes Eigens_to_Procrustes (Eigen me, Eigen thee, integer evec_from, integer evec_to) { |
| 25 |
try { |
| 26 |
const integer numberOfVectors = evec_to - evec_from + 1; |
| 27 |
const integer nmin = std::min (my numberOfEigenvalues, thy numberOfEigenvalues ); |
| 28 |
Melder_require (my dimension == thy dimension, |
| 29 |
U"The eigenvectors should have the same dimension."); |
| 30 |
Melder_require (evec_from <= evec_to && evec_from > 0 && evec_to <= nmin, |
| 31 |
U"Eigenvector range is too large."); |
| 32 |
|
| 33 |
autoProcrustes him = Procrustes_create (numberOfVectors); |
| 34 |
autoMAT rotation; |
| 35 |
NUMprocrustes (my eigenvectors.horizontalBand (evec_from, evec_to).transpose(), |
| 36 |
thy eigenvectors.horizontalBand (evec_from, evec_to).transpose(), & rotation, nullptr, nullptr); |
| 37 |
his r.all() <<= rotation.all(); |
| 38 |
return him; |
| 39 |
} catch (MelderError) { |
| 40 |
Melder_throw (U"Procrustes not created from Eigens."); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
/* End of file Eigen_and_Procrustes.cpp */ |