1 #ifndef _SSCP_h_
2 #define _SSCP_h_
3 /* SSCP.h
4  *
5  * Copyright (C) 1993-2020 David Weenink
6  *
7  * This code 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 (at
10  * your option) any later version.
11  *
12  * This code is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this work. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "PCA.h"
22 #include "TableOfReal_extensions.h"
23 
24 #include "SSCP_def.h"
25 
26 #include "SSCP_enums.h"
27 
28 /*
29 	Ordered collection of SSCP's
30 	All SSCP's must have the same dimensions and labels.
31 */
Collection_define(SSCPList,OrderedOf,SSCP)32 Collection_define (SSCPList, OrderedOf, SSCP) {
33 };
34 
35 void SSCP_init (SSCP me, integer dimension, kSSCPstorage storage);
36 
37 autoSSCP SSCP_create (integer dimension);
38 
39 void SSCP_reset (SSCP me);
40 
41 void SSCP_drawTwoDimensionalEllipse_inside (SSCP me, Graphics g, double scale, conststring32 label, double fontSize);
42 
43 double SSCP_getEllipseScalefactor (SSCP me, double scale, bool confidence);
44 
45 void SSCP_drawConcentrationEllipse (SSCP me, Graphics g, double scale, int confidence,
46 	integer d1, integer d2, double xmin, double xmax, double ymin, double ymax, bool garnish);
47 
48 void SSCP_setNumberOfObservations (SSCP me, double numberOfObservations);
49 
50 void SSCP_setCentroid (SSCP me, integer component, double value); // only SSCP & Covariance
51 
52 void SSCP_setValue (SSCP me, integer row, integer col, double value); // only SSCP & Covariance
53 
54 double SSCP_getNumberOfObservations (SSCP me);
55 
56 double SSCP_getDegreesOfFreedom (SSCP me);
57 
58 double SSCP_getTotalVariance (SSCP me);
59 
60 double SSCP_getCumulativeContributionOfComponents (SSCP me, integer from, integer to);
61 
62 double SSCP_getLnDeterminant (SSCP me);
63 
64 double SSCP_getConcentrationEllipseArea(SSCP me, double scale, bool confidence, integer d1, integer d2);
65 
66 double SSCP_getFractionVariation (SSCP me, integer from, integer to);
67 
68 autoSSCP TableOfReal_to_SSCP (TableOfReal me, integer rowb, integer rowe, integer colb, integer cole);
69 autoSSCP TableOfReal_to_SSCP_rowWeights (TableOfReal me, integer rowb, integer rowe, integer colb, integer cole, integer weightColumnNumber);
70 
71 autoTableOfReal SSCP_TableOfReal_extractDistanceQuantileRange (SSCP me, TableOfReal thee, double qlow, double qhigh);
72 
73 autoTableOfReal SSCP_to_TableOfReal (SSCP me);
74 
75 autoTableOfReal SSCP_extractCentroid (SSCP me);
76 
77 autoSSCPList TableOfReal_to_SSCPList_byLabel (TableOfReal me);
78 
79 autoPCA SSCP_to_PCA (SSCP me);
80 
81 void SSCP_expandWithPCA (SSCP me);
82 
83 void SSCP_unExpandPCA (SSCP me);
84 
85 void SSCP_getDiagonality_bartlett (SSCP me, integer numberOfContraints, double *out_chisq, double *out_prob, double *out_df);
86 
87 autoSSCP SSCPList_to_SSCP_sum (SSCPList me);
88 /* Sum the sscp's and weigh each means with it's numberOfObservations. */
89 
90 autoSSCP SSCPList_to_SSCP_pool (SSCPList me);
91 
92 void SSCPList_getHomegeneityOfCovariances_box (SSCPList me, double *out_probability, double *out_chisq, double *out_df);
93 
94 autoSSCP SSCP_toTwoDimensions (SSCP me, constVECVU const& v1, constVECVU const& v2);
95 
96 autoSSCPList SSCPList_toTwoDimensions (SSCPList me, constVECVU const& v1, constVECVU const& v2);
97 
98 autoSSCPList SSCPList_extractTwoDimensions (SSCPList me, integer d1, integer d2);
99 
100 /* For inheritors */
101 
102 void SSCPList_drawConcentrationEllipses (SSCPList me, Graphics g, double scale,
103 	bool confidence, conststring32 label, integer d1, integer d2, double xmin, double xmax,
104 	double ymin, double ymax, double fontSize, bool garnish);
105 
106 void SSCPList_getEllipsesBoundingBoxCoordinates (SSCPList me, double scale, bool confidence,
107 	double *xmin, double *xmax, double *ymin, double *ymax);
108 
109 void SSCP_expand (SSCP me);
110 /*
111 	Expand a reduced storage SSCP. For efficiency reasons, the unexpanded matrix is also kept in memory.
112 	Successive calls to SSCP_expand don't change anything unless dataChanged is true.
113 */
114 
115 void SSCP_unExpand (SSCP me);
116 /* Use only if the memory is really needed! */
117 
118 void SSCP_expandWithLowerCholeskyInverse (SSCP me); // create lower square root of covariance matrix
119 
120 void SSCP_unExpandLowerCholesky (SSCP me);
121 
122 /* End of file SSCP.h */
123 #endif
124