1 /* Eigen_and_SSCP.c
2  *
3  * Copyright (C) 1993-2019 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  djmw 20020327
21  djmw 20020813 GPL header
22  djmw 20040219 Eigen_and_Covariance_project added.
23 */
Eigens_to_Procrustes(Eigen me,Eigen thee,integer evec_from,integer evec_to)24 
25 #include "Eigen_and_SSCP.h"
26 
27 autoSSCP Eigen_SSCP_project (Eigen me, SSCP thee) {
28 	try {
29 		Melder_require (thy numberOfRows == my dimension,
30 			U"Dimensions don't agree.");
31 		autoSSCP him = SSCP_create (my numberOfEigenvalues);
32 		//Eigen_SSCP_into_SSCP_project (me, thee, him.get());
33 		MATmul3_XYsXt (his data.get(), my eigenvectors.get(), thy data.get());
34 		mul_VEC_out (his centroid.get(), my eigenvectors.get(), thy centroid.get());
35 		his numberOfObservations = SSCP_getNumberOfObservations (thee);
36 		return him;
37 	} catch (MelderError) {
38 		Melder_throw (U"SSCP not projected.");
39 	}
40 }
41 
42 autoCovariance Eigen_Covariance_project (Eigen me, Covariance thee) {
43 	try {
44 		Melder_require (thy numberOfRows == my dimension,
45 			U"Dimensions should agree.");
46 		autoCovariance him = Covariance_create (my numberOfEigenvalues);
47 		MATmul3_XYsXt (his data.get(), my eigenvectors.get(), thy data.get());
48 		mul_VEC_out (his centroid.get(), my eigenvectors.get(), thy centroid.get());
49 		his numberOfObservations = SSCP_getNumberOfObservations (thee);
50 		return him;
51 	} catch (MelderError) {
52 		Melder_throw (U"Covariance not projected.");
53 	}
54 }
55 
56 /* End of file Eigen_and_SSCP.cpp */
57