| 1 | /* MDS.cpp |
| 2 | * |
| 3 | * Copyright (C) 1993-2020,2026 David Weenink, 2015,2017 Paul Boersma |
| 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 3 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 20020408 GPL |
| 21 | djmw 20020513 Applied TableOfReal_setSequential{Column/Row}Labels |
| 22 | djmw 20040309 Extra tests for empty objects. |
| 23 | djmw 20061218 Changed to Melder_information<x> format. |
| 24 | djmw 20071022 Removed unused code. |
| 25 | djmw 20071106 drawSplines: to wchar |
| 26 | djmw 20071201 Melder_warning<n> |
| 27 | djmw 20071213 Removed Preference. |
| 28 | djmw 20080724 Thing_classNameW ->Thing_className |
| 29 | djmw 20110304 Thing_new |
| 30 | */ |
| 31 | |
| 32 | #include "SVD.h"cxx . . $ `<file>/dwsys/SVD.h`/ |
| 33 | #include "Matrix_extensions.h"cxx . . $ `<file>/dwtools/Matrix_extensions.h`/ |
| 34 | #include "TableOfReal_extensions.h"cxx . . $ `<file>/dwtools/TableOfReal_extensions.h`/ |
| 35 | #include "MDS.h"cxx . . $ `<file>/dwtools/MDS.h`/ |
| 36 | #include "Proximity_and_Distance.h"cxx . . $ `<file>/dwtools/Proximity_and_Distance.h`/ |
| 37 | #include "SSCP.h"cxx . . $ `<file>/dwtools/SSCP.h`/ |
| 38 | #include "PCA.h"cxx . . $ `<file>/dwtools/PCA.h`/ |
| 39 | |
| 40 | #include "enums_getText.h"cxx . . $ `<file>/melder/enums_getText.h`/ |
| 41 | #undef _MDS_enums_h_cxx . . $ `./MDS_enums.h:2:9`! |
| 42 | #include "MDS_enums.h"cxx . . $ `<file>/dwtools/MDS_enums.h`/ |
| 43 | #include "enums_getValue.h"cxx . . $ `<file>/melder/enums_getValue.h`/ |
| 44 | #undef _MDS_enums_h_cxx . . $ `dwtools/MDS_enums.h:2:9`! |
| 45 | #include "MDS_enums.h"cxx . . $ `<file>/dwtools/MDS_enums.h`/ |
| 46 | |
| 47 | #define TINYcxx . . $ `dwtools/MDS.cpp:47:9`! 1e-30 |
| 48 | |
| 49 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Kruskal, Thing, 0); |
| 50 | |
| 51 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Transformator, Thing, 0); |
| 52 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (RatioTransformator, Transformator, 0); |
| 53 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (MonotoneTransformator, Transformator, 0); |
| 54 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ISplineTransformator, Transformator, 0); |
| 55 | |
| 56 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Weight, TableOfReal, 0); |
| 57 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Salience, TableOfReal, 0); |
| 58 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ScalarProduct, TableOfReal, 0); |
| 59 | |
| 60 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ConfusionList, TableOfRealList, 0); |
| 61 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ProximityList, TableOfRealList, 0); |
| 62 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ScalarProductList, TableOfRealList, 0); |
| 63 | |
| 64 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (DissimilarityList, ProximityList, 0); |
| 65 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Similarity, Proximity, 0); |
| 66 | |
| 67 | |
| 68 | /********************** NUMERICAL STUFF **************************************/ |
| 69 | |
| 70 | |
| 71 | static void MATfromVEC_inplacecxx . . $ MATfromVEC_inplace(16d8a87020bfd1b1). (MATVUcxx . . $ MATVU# const& m, VECVUcxx . . $ VECVU# v) { |
| 72 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (m.nrow * m.ncol == v.size); |
| 73 | integercxx . . $ integer# k = 1; |
| 74 | for (integercxx . . $ integer# irow = 1; irow <= m.nrowcxx . . $ matrixview#nrow.; irow ++) |
| 75 | for (integercxx . . $ integer# icol = 1; icol <= m.ncolcxx . . $ matrixview#ncol.; icol ++) |
| 76 | m [cxx . . $ matrixview#`operator[]`(a8b9553e85c2b1fc).irow] [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).icol] = v [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).k ++]; |
| 77 | } |
| 78 | |
| 79 | static void MAT_divideRowByRowsum_inplacecxx . . $ MAT_divideRowByRowsum_inplace(a810c3355071c044). (MATVUcxx . . $ MATVU# const& m) { |
| 80 | for (integercxx . . $ integer# i = 1; i <= m.nrowcxx . . $ matrixview#nrow.; i ++) { |
| 81 | const longdoublecxx . . $ longdouble# rowSum = NUMsumcxx . . $ NUMsum(4bb9c3e3a8dd5442). (mcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..rowcxx . . $ matrixview#row(a8b9553e85c2b1fc). (i)); |
| 82 | if (rowSum != 0.0) |
| 83 | m.rowcxx . . $ matrixview#row(a8b9553e85c2b1fc). (i) *=cxx . . $ `operator*=`(c555d170d72ff256). double (1.0 / rowSum); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static integercxx . . $ integer# NUMcountZeroscxx . . $ NUMcountZeros(f49a0b798c9b6ef3). (constMATVUcxx . . $ constMATVU# const& m) { |
| 88 | integercxx . . $ integer# numberOfZeros = 0; |
| 89 | for (integercxx . . $ integer# i = 1; i <= m.nrowcxx . . $ constmatrixview#nrow.; i ++) |
| 90 | for (integercxx . . $ integer# j = 1; j <= m.ncolcxx . . $ constmatrixview#ncol.; j ++) |
| 91 | if (m [cxx . . $ constmatrixview#`operator[]`(7a6174ed67b49158).i] [cxx . . $ constvectorview#`operator[]`(e616e229aa94bfcf).j] == 0.0) |
| 92 | numberOfZeros ++; |
| 93 | return numberOfZeros; |
| 94 | } |
| 95 | |
| 96 | /************ ConfigurationList & Similarity **************************/ |
| 97 | |
| 98 | autoDistanceListcxx . . $ autoDistanceList# ConfigurationList_to_DistanceListcxx . . $ ConfigurationList_to_DistanceList(861c510da5ebddfa). (ConfigurationListcxx . . $ ConfigurationList# me) { |
| 99 | try { |
| 100 | autoDistanceListcxx . . $ autoDistanceList# thee = DistanceList_createcxx . . $ DistanceList_create(dea20e937b1fc8dd). (); |
| 101 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 102 | const Configurationcxx . . $ Configuration# conf = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 103 | autoDistancecxx . . $ autoDistance# d = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (conf); |
| 104 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (conf)); |
| 105 | thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (dcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 106 | } |
| 107 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 108 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 109 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"DistanceList not created form Configurations."); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | autoSimilaritycxx . . $ autoSimilarity# ConfigurationList_to_Similarity_cccxx . . $ ConfigurationList_to_Similarity_cc(e1c1dc3055f6b84e). (ConfigurationListcxx . . $ ConfigurationList# me, Weightcxx . . $ Weight# weight) { |
| 114 | try { |
| 115 | autoDistanceListcxx . . $ autoDistanceList# d = ConfigurationList_to_DistanceListcxx . . $ ConfigurationList_to_DistanceList(861c510da5ebddfa). (me); |
| 116 | autoSimilaritycxx . . $ autoSimilarity# thee = DistanceList_to_Similarity_cccxx . . $ DistanceList_to_Similarity_cc(8e19e6e437a2f924). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight); |
| 117 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 118 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 119 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Similarity not created form Configurations."); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | autoSimilaritycxx . . $ autoSimilarity# DistanceList_to_Similarity_cccxx . . $ DistanceList_to_Similarity_cc(8e19e6e437a2f924). (DistanceListcxx . . $ DistanceList# me, Weightcxx . . $ Weight# w) { |
| 124 | try { |
| 125 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! size > 0, |
| 126 | U"DistanceList should not be empty."); |
| 127 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfRealList_haveIdenticalDimensions (mycxx . . $ `melder/melder.h:44:9`! asTableOfRealList()), |
| 128 | U"All matrices should have the same dimensions."); |
| 129 | |
| 130 | autoWeightcxx . . $ autoWeight# awcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 131 | if (! w) { |
| 132 | aw =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1] -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 133 | w = aw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 134 | } |
| 135 | |
| 136 | autoSimilaritycxx . . $ autoSimilarity# thee = Similarity_createcxx . . $ Similarity_create(32730dd5c8f6d644). (mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.); |
| 137 | |
| 138 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 139 | const Distancecxx . . $ Distance# di = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 140 | const conststring32cxx . . $ conststring32# name = Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (di); |
| 141 | TableOfReal_setRowLabelcxx . . $ TableOfReal_setRowLabel(7bba53c4f5b398fa). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i, name); |
| 142 | TableOfReal_setColumnLabelcxx . . $ TableOfReal_setColumnLabel(7bba53c4f5b398fa). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i, name); |
| 143 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 1; |
| 144 | for (integercxx . . $ integer# j = i + 1; j <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; j ++) { |
| 145 | const Distancecxx . . $ Distance# dj = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).j]; |
| 146 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = Distance_Weight_congruenceCoefficientcxx . . $ Distance_Weight_congruenceCoefficient(ec87364adc15653a). (di, dj, w); |
| 147 | } |
| 148 | } |
| 149 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 150 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 151 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Similarity not created from DistanceList."); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |
| 156 | /***************** Transformator **********************************************/ |
| 157 | |
| 158 | autoDistancecxx . . $ autoDistance# structTransformatorcxx . . $ structTransformator# :: v_transformcxx . . $ structTransformator#v_transform(21627586301fa62a). (MDSVeccxx . . $ MDSVec# vec, Distancecxx . . $ Distance# dist, Weightcxx . . $ Weight# /* w */) { |
| 159 | try { |
| 160 | autoDistancecxx . . $ autoDistance# thee = Distance_createcxx . . $ Distance_create(93683ff7a95ab9fe). (numberOfPointscxx . . $ structTransformator#numberOfPoints.); |
| 161 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (dist, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 162 | |
| 163 | // Absolute scaling |
| 164 | |
| 165 | for (integercxx . . $ integer# i = 1; i <= vec -> numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 166 | const integercxx . . $ integer# ii = vec -> rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 167 | const integercxx . . $ integer# jj = vec -> columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 168 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).jj] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).ii] = vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 169 | } |
| 170 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 171 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 172 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Distance not created."); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | void Transformator_initcxx . . $ Transformator_init(c49ee9e0c361ef6). (Transformatorcxx . . $ Transformator# me, integercxx . . $ integer# numberOfPoints) { |
| 177 | mycxx . . $ `melder/melder.h:44:9`! numberOfPointscxx . . $ structTransformator#numberOfPoints. = numberOfPoints; |
| 178 | mycxx . . $ `melder/melder.h:44:9`! normalizationcxx . . $ structTransformator#normalization. = 1; |
| 179 | } |
| 180 | |
| 181 | autoTransformatorcxx . . $ autoTransformator# Transformator_createcxx . . $ Transformator_create(59a7737283154f8a). (integercxx . . $ integer# numberOfPoints) { |
| 182 | try { |
| 183 | autoTransformatorcxx . . $ autoTransformator# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Transformator); |
| 184 | Transformator_initcxx . . $ Transformator_init(c49ee9e0c361ef6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints); |
| 185 | mycxx . . $ `melder/melder.h:44:9`! normalizationcxx . . $ structTransformator#normalization. = 0; |
| 186 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 187 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 188 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No Transformator created."); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | autoDistancecxx . . $ autoDistance# Transformator_transformcxx . . $ Transformator_transform(3e516a08078d98a0). (Transformatorcxx . . $ Transformator# me, MDSVeccxx . . $ MDSVec# vec, Distancecxx . . $ Distance# d, Weightcxx . . $ Weight# w) { |
| 193 | try { |
| 194 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfPoints == vec -> numberOfPoints && mycxx . . $ `melder/melder.h:44:9`! numberOfPoints == d -> numberOfRows && |
| 195 | d -> numberOfRows == w -> numberOfRows, |
| 196 | U"Dimensions should agree."); |
| 197 | return mycxx . . $ `melder/melder.h:44:9`! v_transformcxx . . $ structTransformator#v_transform(21627586301fa62a). (vec, d, w); |
| 198 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 199 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U"Distance not created."); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | autoDistancecxx . . $ autoDistance# structRatioTransformatorcxx . . $ structRatioTransformator# :: v_transformcxx . . $ structRatioTransformator#v_transform(21627586301fa62a). (MDSVeccxx . . $ MDSVec# vec, Distancecxx . . $ Distance# d, Weightcxx . . $ Weight# w) { |
| 204 | autoDistancecxx . . $ autoDistance# thee = Distance_createcxx . . $ Distance_create(93683ff7a95ab9fe). (numberOfPointscxx . . $ structTransformator#numberOfPoints.); |
| 205 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (d, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 206 | |
| 207 | // Determine ratio (eq. 9.4) |
| 208 | |
| 209 | longdoublecxx . . $ longdouble# etaSq = 0.0, rho = 0.0; |
| 210 | for (integercxx . . $ integer# i = 1; i <= vec -> numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 211 | const integercxx . . $ integer# ii = vec -> rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 212 | const integercxx . . $ integer# jj = vec -> columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 213 | const double delta_ij = vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 214 | const double d_ij = d -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj]; |
| 215 | const double tmp = w -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] * delta_ij * delta_ij; |
| 216 | etaSq += tmp; |
| 217 | rho += tmp * d_ij * d_ij; |
| 218 | } |
| 219 | |
| 220 | // transform |
| 221 | |
| 222 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (etaSq > 0.0, |
| 223 | U"Eta squared should not be zero."); |
| 224 | |
| 225 | ourcxx . . $ `melder/melder.h:42:9`! ratiocxx . . $ structRatioTransformator#ratio. = rho / etaSq; |
| 226 | for (integercxx . . $ integer# i = 1; i <= vec -> numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 227 | const integercxx . . $ integer# ii = vec -> rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 228 | const integercxx . . $ integer# jj = vec -> columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 229 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).jj] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).ii] = ourcxx . . $ `melder/melder.h:42:9`! ratiocxx . . $ structRatioTransformator#ratio. * vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 230 | } |
| 231 | |
| 232 | if (ourcxx . . $ `melder/melder.h:42:9`! normalizationcxx . . $ structTransformator#normalization.) |
| 233 | Distance_Weight_smacofNormalizecxx . . $ Distance_Weight_smacofNormalize(c2d60f06b518eb4f). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 234 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 235 | } |
| 236 | |
| 237 | autoRatioTransformatorcxx . . $ autoRatioTransformator# RatioTransformator_createcxx . . $ RatioTransformator_create(bfd0554b6ddec263). (integercxx . . $ integer# numberOfPoints) { |
| 238 | try { |
| 239 | autoRatioTransformatorcxx . . $ autoRatioTransformator# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (RatioTransformator); |
| 240 | Transformator_initcxx . . $ Transformator_init(c49ee9e0c361ef6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints); |
| 241 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 242 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 243 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"RatioTransformator not created."); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | autoDistancecxx . . $ autoDistance# structMonotoneTransformatorcxx . . $ structMonotoneTransformator# :: v_transformcxx . . $ structMonotoneTransformator#v_transform(21627586301fa62a). (MDSVeccxx . . $ MDSVec# vec, Distancecxx . . $ Distance# d, Weightcxx . . $ Weight# w) { |
| 248 | try { |
| 249 | autoDistancecxx . . $ autoDistance# thee = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (vec, d, tiesHandlingcxx . . $ structMonotoneTransformator#tiesHandling.); |
| 250 | if (normalizationcxx . . $ structTransformator#normalization.) |
| 251 | Distance_Weight_smacofNormalizecxx . . $ Distance_Weight_smacofNormalize(c2d60f06b518eb4f). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 252 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 253 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 254 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Distance not created."); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | autoMonotoneTransformatorcxx . . $ autoMonotoneTransformator# MonotoneTransformator_createcxx . . $ MonotoneTransformator_create(695d2932d7073386). (integercxx . . $ integer# numberOfPoints) { |
| 259 | try { |
| 260 | autoMonotoneTransformatorcxx . . $ autoMonotoneTransformator# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (MonotoneTransformator); |
| 261 | Transformator_initcxx . . $ Transformator_init(c49ee9e0c361ef6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints); |
| 262 | mycxx . . $ `melder/melder.h:44:9`! tiesHandlingcxx . . $ structMonotoneTransformator#tiesHandling. = kMDS_TiesHandling::PRIMARY_APPROACH; |
| 263 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 264 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 265 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"MonotoneTransformator not created."); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | void MonotoneTransformator_setTiesProcessingcxx . . $ MonotoneTransformator_setTiesProcessing(dcdd256c093f1b38). (MonotoneTransformatorcxx . . $ MonotoneTransformator# me, kMDS_TiesHandling tiesHandling) { |
| 270 | mycxx . . $ `melder/melder.h:44:9`! tiesHandlingcxx . . $ structMonotoneTransformator#tiesHandling. = tiesHandling; |
| 271 | } |
| 272 | |
| 273 | autoDistancecxx . . $ autoDistance# structISplineTransformatorcxx . . $ structISplineTransformator# :: v_transformcxx . . $ structISplineTransformator#v_transform(21627586301fa62a). (MDSVeccxx . . $ MDSVec# vec, Distancecxx . . $ Distance# dist, Weightcxx . . $ Weight# w) { |
| 274 | const double tol = 1e-6; |
| 275 | const integercxx . . $ integer# itermax = 20, numberOfProximities = vec -> numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; |
| 276 | const integercxx . . $ integer# nKnots = numberOfInteriorKnotscxx . . $ structISplineTransformator#numberOfInteriorKnots. + ordercxx . . $ structISplineTransformator#order. + ordercxx . . $ structISplineTransformator#order. + 2; |
| 277 | |
| 278 | autoDistancecxx . . $ autoDistance# thee = Distance_createcxx . . $ Distance_create(93683ff7a95ab9fe). (dist -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 279 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (dist, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, -1); |
| 280 | |
| 281 | autoVECcxx . . $ autoVEC# d = zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfProximities); |
| 282 | |
| 283 | for (integercxx . . $ integer# i = 1; i <= numberOfProximities; i ++) |
| 284 | d [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = dist -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).vec -> rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).vec -> columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]]; |
| 285 | /* |
| 286 | Process knots. Put interior knots at quantiles. |
| 287 | Guarantee that for each proximity x [i]: knot [j] <= x [i] < knot [j+1] |
| 288 | */ |
| 289 | for (integercxx . . $ integer# i = 1; i <= ordercxx . . $ structISplineTransformator#order. + 1; i ++) { |
| 290 | knotcxx . . $ structISplineTransformator#knot. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]; |
| 291 | knotcxx . . $ structISplineTransformator#knot. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nKnots - i + 1] = vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfProximities] * 1.000001; |
| 292 | } |
| 293 | for (integercxx . . $ integer# i = 1; i <= numberOfInteriorKnotscxx . . $ structISplineTransformator#numberOfInteriorKnots.; i ++) { |
| 294 | const double fraction = (double) i / (numberOfInteriorKnotscxx . . $ structISplineTransformator#numberOfInteriorKnots. + 1); |
| 295 | knotcxx . . $ structISplineTransformator#knot. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ordercxx . . $ structISplineTransformator#order. + 1 + i] = NUMquantilecxx . . $ NUMquantile(885a97927582bd48). (veccxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> proximitycxx . . $ structMDSVec#proximity..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), fraction); |
| 296 | } |
| 297 | /* |
| 298 | Calculate data matrix m. |
| 299 | */ |
| 300 | for (integercxx . . $ integer# iprox = 1; iprox <= numberOfProximities; iprox ++) { |
| 301 | const double x = vec -> proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iprox]; |
| 302 | mcxx . . $ structISplineTransformator#m. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).iprox] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 1.0; |
| 303 | double y; |
| 304 | for (integercxx . . $ integer# ipar = 2; ipar <= numberOfParameterscxx . . $ structISplineTransformator#numberOfParameters.; ipar ++) { |
| 305 | try { |
| 306 | y = NUMisplinecxx . . $ NUMispline(55addd8cdfddff3d). (knotcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), ordercxx . . $ structISplineTransformator#order., ipar - 1, x); |
| 307 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 308 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"I-spline [", ipar - 1, U"], data [", iprox, U"d] = ", x); |
| 309 | } |
| 310 | mcxx . . $ structISplineTransformator#m. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).iprox] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).ipar] = y; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | ourcxx . . $ `melder/melder.h:42:9`! bcxx . . $ structISplineTransformator#b. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). solveNonnegativeLeastSquaresRegression_VECcxx . . $ solveNonnegativeLeastSquaresRegression_VEC(bc0ba5999309359e). (mcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), dcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), itermax, tol, 0); |
| 315 | |
| 316 | for (integercxx . . $ integer# iprox = 1; iprox <= numberOfProximities; iprox ++) { |
| 317 | const integercxx . . $ integer# ii = vec->rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iprox]; |
| 318 | const integercxx . . $ integer# jj = vec->columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iprox]; |
| 319 | const double r = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (mcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (iprox), bcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).()); |
| 320 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).jj] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).ii] = r; |
| 321 | } |
| 322 | if (normalizationcxx . . $ structTransformator#normalization.) |
| 323 | Distance_Weight_smacofNormalizecxx . . $ Distance_Weight_smacofNormalize(c2d60f06b518eb4f). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 324 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 325 | } |
| 326 | |
| 327 | autoISplineTransformatorcxx . . $ autoISplineTransformator# ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (integercxx . . $ integer# numberOfPoints, integercxx . . $ integer# numberOfInteriorKnots, integercxx . . $ integer# order) { |
| 328 | try { |
| 329 | autoISplineTransformatorcxx . . $ autoISplineTransformator# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (ISplineTransformator); |
| 330 | const integercxx . . $ integer# nData = (numberOfPoints - 1) * numberOfPoints / 2; |
| 331 | |
| 332 | Transformator_initcxx . . $ Transformator_init(c49ee9e0c361ef6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints); |
| 333 | /* |
| 334 | 1 extra parameter for the intercept. |
| 335 | 2 extra knots for the I-spline. |
| 336 | */ |
| 337 | mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structISplineTransformator#numberOfParameters. = numberOfInteriorKnots + order + 1; |
| 338 | const integercxx . . $ integer# numberOfKnots = numberOfInteriorKnots + order + order + 2; |
| 339 | |
| 340 | mycxx . . $ `melder/melder.h:44:9`! bcxx . . $ structISplineTransformator#b. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structISplineTransformator#numberOfParameters.); |
| 341 | mycxx . . $ `melder/melder.h:44:9`! knotcxx . . $ structISplineTransformator#knot. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfKnots); |
| 342 | mycxx . . $ `melder/melder.h:44:9`! mcxx . . $ structISplineTransformator#m. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). zero_MATcxx . . $ zero_MAT(3d09731056d2b97d). (nData, mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structISplineTransformator#numberOfParameters.); |
| 343 | |
| 344 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structISplineTransformator#numberOfParameters.; i ++) |
| 345 | mycxx . . $ `melder/melder.h:44:9`! bcxx . . $ structISplineTransformator#b. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.0, 1.0); |
| 346 | |
| 347 | mycxx . . $ `melder/melder.h:44:9`! numberOfInteriorKnotscxx . . $ structISplineTransformator#numberOfInteriorKnots. = numberOfInteriorKnots; |
| 348 | mycxx . . $ `melder/melder.h:44:9`! ordercxx . . $ structISplineTransformator#order. = order; |
| 349 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 350 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 351 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"ISplineTransformator not created."); |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | /***************** CONTINGENCYTABLE **************************************/ |
| 356 | |
| 357 | autoConfigurationcxx . . $ autoConfiguration# ContingencyTable_to_Configuration_cacxx . . $ ContingencyTable_to_Configuration_ca(cafab2423bf87f69). (ContingencyTablecxx . . $ ContingencyTable# me, integercxx . . $ integer# numberOfDimensions, integercxx . . $ integer# scaling) { |
| 358 | try { |
| 359 | const integercxx . . $ integer# nrow = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., ncol = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 360 | const integercxx . . $ integer# dimmin = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (nrow, ncol); |
| 361 | |
| 362 | autoMATcxx . . $ autoMAT# h = copy_MATcxx . . $ copy_MAT(a392b09ce3fc3972). (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 363 | autoVECcxx . . $ autoVEC# rowsum = rowSums_VECcxx . . $ rowSums_VEC(81359d2d5440d947). (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 364 | autoVECcxx . . $ autoVEC# colsum = columnSums_VECcxx . . $ columnSums_VEC(81359d2d5440d947). (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 365 | autoConfigurationcxx . . $ autoConfiguration# thee = Configuration_createcxx . . $ Configuration_create(312218706738bb63). (nrow + ncol, numberOfDimensions); |
| 366 | |
| 367 | if (numberOfDimensions == 0) |
| 368 | numberOfDimensions = dimmin - 1; |
| 369 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfDimensions < dimmin, |
| 370 | U"Dimension should be lower than ", dimmin, U"."); |
| 371 | /* |
| 372 | Ref: A. Gifi (1990), Nonlinear Multivariate Analysis, Wiley & Sons, reprinted 1996, |
| 373 | Chapter 8, Multidimensional scaling and Correspondence Analysis. |
| 374 | |
| 375 | Get row and column marginals |
| 376 | */ |
| 377 | longdoublecxx . . $ longdouble# sum = 0.0;; |
| 378 | for (integercxx . . $ integer# irow = 1; irow <= nrow; irow ++) { |
| 379 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (rowsum [irow] > 0.0, |
| 380 | U"Row number ", irow, U" should not be empty."); |
| 381 | sum += rowsum [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).irow]; |
| 382 | } |
| 383 | |
| 384 | for (integercxx . . $ integer# icol = 1; icol <= ncol; icol ++) |
| 385 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (colsum [icol] > 0.0, |
| 386 | U"Column number ", icol, U" should not be empty."); |
| 387 | /* |
| 388 | Remove trivial singular vectors (Eq. 8.24), |
| 389 | construct Dr^(-1/2) H Dc^(-1/2) - Dr^(1/2) uu' Dc^(1/2) / N |
| 390 | */ |
| 391 | for (integercxx . . $ integer# irow = 1; irow <= nrow; irow ++) { |
| 392 | for (integercxx . . $ integer# icol = 1; icol <= ncol; icol ++) { |
| 393 | const double rc = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (rowsum [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).irow] * colsum [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icol]); |
| 394 | h [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = h [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] / rc - rc / (double) sum; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | autoSVDcxx . . $ autoSVD# svd = SVD_createFromGeneralMatrixcxx . . $ SVD_createFromGeneralMatrix(35acab982e3981c8). (hcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 399 | SVD_zeroSmallSingularValuescxx . . $ SVD_zeroSmallSingularValues(3c6b93a29a648e9a). (svd.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0); |
| 400 | /* |
| 401 | Scale row vectors and column vectors to configuration. |
| 402 | */ |
| 403 | for (integercxx . . $ integer# j = 1; j <= numberOfDimensions; j ++) { |
| 404 | const double rootsum = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). ((double) sum), lambda = svd ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). dcxx . . $ structSVD#d. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j]; |
| 405 | double xfactor, yfactor; |
| 406 | if (scaling == 1) { |
| 407 | /* |
| 408 | Scale row points in the centre of gravity of column points (eq 8.5.a) |
| 409 | */ |
| 410 | xfactor = rootsum * lambda; |
| 411 | yfactor = rootsum; |
| 412 | } else if (scaling == 2) { |
| 413 | /* |
| 414 | Scale column points in the centre of gravity of row points (8.5.b) |
| 415 | */ |
| 416 | xfactor = rootsum; |
| 417 | yfactor = rootsum * lambda; |
| 418 | } else if (scaling == 3) { |
| 419 | /* |
| 420 | Treat row and columns symmetrically (8.5.c). |
| 421 | */ |
| 422 | xfactor = yfactor = rootsum * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (lambda); |
| 423 | } else { |
| 424 | break; |
| 425 | } |
| 426 | for (integercxx . . $ integer# irow = 1; irow <= nrow; irow ++) |
| 427 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = svd ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). ucxx . . $ structSVD#u. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * xfactor / sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (rowsum [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).irow]); |
| 428 | for (integercxx . . $ integer# icol = 1; icol <= ncol; icol ++) |
| 429 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).nrow + icol] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = svd ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). vcxx . . $ structSVD#v. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).icol] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * yfactor / sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (colsum [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icol]); |
| 430 | } |
| 431 | |
| 432 | TableOfReal_setSequentialColumnLabelscxx . . $ TableOfReal_setSequentialColumnLabels(8dc3139cdc86d712). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, 0, nullptr, 1, 1); |
| 433 | thycxx . . $ `melder/melder.h:45:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..partcxx . . $ _autostringautovector#part(862ae67a684f15c7). (1, nrow) <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 434 | thycxx . . $ `melder/melder.h:45:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..partcxx . . $ _autostringautovector#part(862ae67a684f15c7). (nrow + 1, nrow + ncol) <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 435 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 436 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 437 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created."); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | autoDissimilaritycxx . . $ autoDissimilarity# TableOfReal_to_Dissimilaritycxx . . $ TableOfReal_to_Dissimilarity(91f131f6f1a8fb97). (TableOfRealcxx . . $ TableOfReal# me) { |
| 442 | try { |
| 443 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfColumns, |
| 444 | U"The TableOfReal should be square."); |
| 445 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfReal_isNonNegative (me), |
| 446 | U"No cell in the table should be negative."); |
| 447 | autoDissimilaritycxx . . $ autoDissimilarity# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Dissimilarity); |
| 448 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 449 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 450 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 451 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Dissimilarity."); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | autoSimilaritycxx . . $ autoSimilarity# TableOfReal_to_Similaritycxx . . $ TableOfReal_to_Similarity(7b06bb12e1b76ae6). (TableOfRealcxx . . $ TableOfReal# me) { |
| 456 | try { |
| 457 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfColumns, |
| 458 | U"The TableOfReal should be square."); |
| 459 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfReal_isNonNegative (me), |
| 460 | U"No cell in the table should be negative."); |
| 461 | autoSimilaritycxx . . $ autoSimilarity# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Similarity); |
| 462 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 463 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 464 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 465 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Similarity."); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | autoDistancecxx . . $ autoDistance# TableOfReal_to_Distancecxx . . $ TableOfReal_to_Distance(c961ba94c61b100). (TableOfRealcxx . . $ TableOfReal# me) { |
| 470 | try { |
| 471 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfColumns, |
| 472 | U"The TableOfReal should be square."); |
| 473 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfReal_isNonNegative (me), |
| 474 | U"No cell in the table should be negative."); |
| 475 | autoDistancecxx . . $ autoDistance# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Distance); |
| 476 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 477 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 478 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 479 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Distance."); |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | autoSaliencecxx . . $ autoSalience# TableOfReal_to_Saliencecxx . . $ TableOfReal_to_Salience(e458fe2dbde96b9d). (TableOfRealcxx . . $ TableOfReal# me) { |
| 484 | try { |
| 485 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfReal_isNonNegative (me), |
| 486 | U"No cell in the table should be negative."); |
| 487 | autoSaliencecxx . . $ autoSalience# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Salience); |
| 488 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 489 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 490 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 491 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Salience."); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | autoWeightcxx . . $ autoWeight# TableOfReal_to_Weightcxx . . $ TableOfReal_to_Weight(98ad4c9cfdbd1f1). (TableOfRealcxx . . $ TableOfReal# me) { |
| 496 | try { |
| 497 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (TableOfReal_isNonNegative (me), |
| 498 | U"No cell in the table should be negative."); |
| 499 | autoWeightcxx . . $ autoWeight# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Weight); |
| 500 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 501 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 502 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 503 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Weight."); |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | autoScalarProductcxx . . $ autoScalarProduct# TableOfReal_to_ScalarProductcxx . . $ TableOfReal_to_ScalarProduct(1e4a7429f53546e8). (TableOfRealcxx . . $ TableOfReal# me) { |
| 508 | try { |
| 509 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfColumns, |
| 510 | U"TableOfReal should be a square table."); |
| 511 | autoScalarProductcxx . . $ autoScalarProduct# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (ScalarProduct); |
| 512 | mycxx . . $ `melder/melder.h:44:9`! structTableOfRealcxx . . $ structTableOfReal# :: v1_copycxx . . $ structTableOfReal#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 513 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 514 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 515 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to ScalarProduct."); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /**************** Covariance & Correlation to Configuration *****************/ |
| 520 | |
| 521 | autoConfigurationcxx . . $ autoConfiguration# SSCP_to_Configurationcxx . . $ SSCP_to_Configuration(99ba0dac11aebc82). (SSCPcxx . . $ SSCP# me, integercxx . . $ integer# numberOfDimensions) { |
| 522 | try { |
| 523 | autoConfigurationcxx . . $ autoConfiguration# thee = Configuration_createcxx . . $ Configuration_create(312218706738bb63). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfDimensions); |
| 524 | autoPCAcxx . . $ autoPCA# a = SSCP_to_PCAcxx . . $ SSCP_to_PCA(67c2aab67f958214). (me); |
| 525 | TableOfReal_setSequentialColumnLabelscxx . . $ TableOfReal_setSequentialColumnLabels(8dc3139cdc86d712). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, 0, nullptr, 1, 1); |
| 526 | |
| 527 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) { |
| 528 | for (integercxx . . $ integer# j = 1; j <= numberOfDimensions; j ++) |
| 529 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (i), acxx . . $ constvectorview#constvectorview(5c6f246bf1d99401). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). eigenvectorscxx . . $ structEigen#eigenvectors..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (j)); |
| 530 | } |
| 531 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 532 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 533 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created."); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | autoConfigurationcxx . . $ autoConfiguration# Covariance_to_Configurationcxx . . $ Covariance_to_Configuration(8c380fac6a4b562b). (Covariancecxx . . $ Covariance# me, integercxx . . $ integer# numberOfDimensions) { |
| 538 | return SSCP_to_Configurationcxx . . $ SSCP_to_Configuration(99ba0dac11aebc82). (me, numberOfDimensions); |
| 539 | } |
| 540 | |
| 541 | autoConfigurationcxx . . $ autoConfiguration# Correlation_to_Configurationcxx . . $ Correlation_to_Configuration(fd8dc904fc4feaa1). (Correlationcxx . . $ Correlation# me, integercxx . . $ integer# numberOfDimensions) { |
| 542 | return SSCP_to_Configurationcxx . . $ SSCP_to_Configuration(99ba0dac11aebc82). (me, numberOfDimensions); |
| 543 | } |
| 544 | |
| 545 | /**************************** Weight *****************************************/ |
| 546 | |
| 547 | autoWeightcxx . . $ autoWeight# Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (integercxx . . $ integer# numberOfPoints) { |
| 548 | try { |
| 549 | autoWeightcxx . . $ autoWeight# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Weight); |
| 550 | TableOfReal_initcxx . . $ TableOfReal_init(cfadf70b559ed315). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints, numberOfPoints); |
| 551 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 1.0; |
| 552 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 553 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 554 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Weight not created."); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | |
| 559 | /**************** Salience *****************************************/ |
| 560 | |
| 561 | autoSaliencecxx . . $ autoSalience# Salience_createcxx . . $ Salience_create(c072d15a45b2e699). (integercxx . . $ integer# numberOfSources, integercxx . . $ integer# numberOfDimensions) { |
| 562 | try { |
| 563 | autoSaliencecxx . . $ autoSalience# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Salience); |
| 564 | TableOfReal_initcxx . . $ TableOfReal_init(cfadf70b559ed315). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfSources, numberOfDimensions); |
| 565 | Salience_setDefaultscxx . . $ Salience_setDefaults(1120f0269e41a951). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 566 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 567 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 568 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Salience not created."); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | integercxx . . $ integer# Salience_correctNegativescxx . . $ Salience_correctNegatives(7df1617a502ef6e2). (Saliencecxx . . $ Salience# me) { |
| 573 | /* |
| 574 | The weights might be negative. |
| 575 | We correct this by simply making them positive. |
| 576 | */ |
| 577 | integercxx . . $ integer# nNegatives = 0; |
| 578 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) { |
| 579 | for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) { |
| 580 | if (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] < 0.0) { |
| 581 | nNegatives ++; |
| 582 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = - mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 583 | } |
| 584 | } |
| 585 | } |
| 586 | return nNegatives; |
| 587 | } |
| 588 | |
| 589 | void Salience_setDefaultscxx . . $ Salience_setDefaults(1120f0269e41a951). (Saliencecxx . . $ Salience# me) { |
| 590 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 1.0 / sqrtcxx . . $ sqrt(7759b11ec49fe502). (mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 591 | for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 592 | TableOfReal_setColumnLabelcxx . . $ TableOfReal_setColumnLabel(7bba53c4f5b398fa). (me, j, Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"dimension ", j)); |
| 593 | } |
| 594 | |
| 595 | void Salience_drawcxx . . $ Salience_draw(388105c4618b1f2b). (Saliencecxx . . $ Salience# me, Graphicscxx . . $ Graphics# g, integercxx . . $ integer# ix, integercxx . . $ integer# iy, bool garnish) { |
| 596 | integercxx . . $ integer# nc2, nc1 = ( ix < iy ? (nc2 = iy, ix) : (nc2 = ix, iy) ); |
| 597 | |
| 598 | if (ix < 1 || ix > mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. || iy < 1 || iy > mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.) |
| 599 | return; |
| 600 | |
| 601 | double wmax = 1.0; |
| 602 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) { |
| 603 | for (integercxx . . $ integer# j = nc1; j <= nc2; j ++) |
| 604 | if (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] > wmax) |
| 605 | wmax = mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 606 | } |
| 607 | const double xmin = 0.0, ymin = 0.0; |
| 608 | double ymax, xmax = ymax = wmax; |
| 609 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g); |
| 610 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, xmin, xmax, ymin, ymax); |
| 611 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 612 | |
| 613 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) |
| 614 | if (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i]) |
| 615 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (g, mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).ix], mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).iy], mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 616 | |
| 617 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 618 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, xmin, ymax, xmin, ymin); |
| 619 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, xmin, ymin, xmax, ymin); |
| 620 | /* Graphics_arc (g, xmin, ymin, xmax - xmin, 0, 90); */ |
| 621 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g); |
| 622 | |
| 623 | if (garnish) { |
| 624 | if (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).ix]) |
| 625 | Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, false, mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).ix].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 626 | if (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).iy]) |
| 627 | Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, false, mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).iy].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /************************** COonfusionList **************************************/ |
| 632 | |
| 633 | autoConfusioncxx . . $ autoConfusion# ConfusionList_sumcxx . . $ ConfusionList_sum(80f7ce9e6b5ef2a8). (ConfusionListcxx . . $ ConfusionList# me) { |
| 634 | try { |
| 635 | autoTableOfRealcxx . . $ autoTableOfReal# sum = TableOfRealList_sumcxx . . $ TableOfRealList_sum(73aaa73563b681a). (mycxx . . $ `melder/melder.h:44:9`! asTableOfRealListcxx . . $ structConfusionList#asTableOfRealList(9c68c8bbffc2a364).()); |
| 636 | autoConfusioncxx . . $ autoConfusion# thee = TableOfReal_to_Confusioncxx . . $ TableOfReal_to_Confusion(98d4fd466ea95203). (sum.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 637 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 638 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 639 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": sum not created."); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | /***************** ScalarProduct ***************************************/ |
| 644 | |
| 645 | autoScalarProductcxx . . $ autoScalarProduct# ScalarProduct_createcxx . . $ ScalarProduct_create(b2f6d4a7191477d). (integercxx . . $ integer# numberOfPoints) { |
| 646 | try { |
| 647 | autoScalarProductcxx . . $ autoScalarProduct# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (ScalarProduct); |
| 648 | TableOfReal_initcxx . . $ TableOfReal_init(cfadf70b559ed315). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfPoints, numberOfPoints); |
| 649 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 650 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 651 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"ScalarProduct not created."); |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | autoSimilaritycxx . . $ autoSimilarity# Confusion_to_Similaritycxx . . $ Confusion_to_Similarity(18b69050a8560a82). (Confusioncxx . . $ Confusion# me, bool normalize, integercxx . . $ integer# symmetrizeMethod) { |
| 656 | try { |
| 657 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfColumns == mycxx . . $ `melder/melder.h:44:9`! numberOfRows, |
| 658 | U"Confusion should be a square table."); |
| 659 | |
| 660 | const integercxx . . $ integer# nxy = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 661 | autoSimilaritycxx . . $ autoSimilarity# thee = Similarity_createcxx . . $ Similarity_create(32730dd5c8f6d644). (nxy); |
| 662 | |
| 663 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 664 | |
| 665 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 666 | |
| 667 | if (normalize) |
| 668 | MAT_divideRowByRowsum_inplacecxx . . $ MAT_divideRowByRowsum_inplace(a810c3355071c044). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 669 | |
| 670 | if (symmetrizeMethod == 1) |
| 671 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 672 | |
| 673 | if (symmetrizeMethod == 2) { // average data |
| 674 | for (integercxx . . $ integer# i = 1; i <= nxy - 1; i ++) |
| 675 | for (integercxx . . $ integer# j = i + 1; j <= nxy; j ++) |
| 676 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] + thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]) / 2; |
| 677 | } else if (symmetrizeMethod == 3) { // method Houtgast |
| 678 | autoMATcxx . . $ autoMAT# p = copy_MATcxx . . $ copy_MAT(a392b09ce3fc3972). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 679 | for (integercxx . . $ integer# i = 1; i <= nxy; i ++) { |
| 680 | for (integercxx . . $ integer# j = i; j <= nxy; j ++) { |
| 681 | longdoublecxx . . $ longdouble# tmp = 0; |
| 682 | for (integercxx . . $ integer# k = 1; k <= nxy; k ++) |
| 683 | tmp += stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (p [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k], p [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]); |
| 684 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = (double) tmp; |
| 685 | } |
| 686 | } |
| 687 | } |
| 688 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 689 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 690 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Similarity created."); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | autoDissimilaritycxx . . $ autoDissimilarity# Similarity_to_Dissimilaritycxx . . $ Similarity_to_Dissimilarity(f23e23cad1941d28). (Similaritycxx . . $ Similarity# me, double maximumDissimilarity) { |
| 695 | try { |
| 696 | const integercxx . . $ integer# nxy = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 697 | autoDissimilaritycxx . . $ autoDissimilarity# thee = Dissimilarity_createcxx . . $ Dissimilarity_create(cdd51d9389725cda). (nxy); |
| 698 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 699 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 700 | |
| 701 | double max = 0.0; |
| 702 | for (integercxx . . $ integer# i = 1; i <= nxy; i ++) { |
| 703 | for (integercxx . . $ integer# j = 1; j <= nxy; j ++) { |
| 704 | if (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] > max) { |
| 705 | max = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | if (maximumDissimilarity <= 0.0) |
| 711 | maximumDissimilarity = max; |
| 712 | |
| 713 | if (maximumDissimilarity < max) |
| 714 | Melder_warningcxx . . $ Melder_warning(6298c93241566110). (U"Your maximumDissimilarity is smaller than the maximum similarity. Some data may be lost."); |
| 715 | |
| 716 | for (integercxx . . $ integer# i = 1; i <= nxy; i ++) { |
| 717 | for (integercxx . . $ integer# j = 1; j <= nxy; j ++) { |
| 718 | const double d = maximumDissimilarity - thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 719 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (d, 0.0); |
| 720 | } |
| 721 | } |
| 722 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 723 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 724 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Dissimilarity created."); |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | |
| 729 | autoWeightcxx . . $ autoWeight# Dissimilarity_to_Weightcxx . . $ Dissimilarity_to_Weight(e4df10b5aa41a7e5). (Dissimilaritycxx . . $ Dissimilarity# me) { |
| 730 | try { |
| 731 | autoWeightcxx . . $ autoWeight# thee = Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 732 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 733 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) { |
| 734 | for (integercxx . . $ integer# j = i; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; j ++) { |
| 735 | if (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] > 0.0) |
| 736 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = 1.0; |
| 737 | } |
| 738 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = 0.0; |
| 739 | } |
| 740 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 741 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 742 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Weight created."); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | |
| 747 | autoDissimilaritycxx . . $ autoDissimilarity# Confusion_to_Dissimilarity_pdfcxx . . $ Confusion_to_Dissimilarity_pdf(5b870dd6da889f86). (Confusioncxx . . $ Confusion# me, double minimumConfusionLevel) { |
| 748 | try { |
| 749 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfColumns == mycxx . . $ `melder/melder.h:44:9`! numberOfRows, |
| 750 | U"Confusion should be a square table."); |
| 751 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (minimumConfusionLevel > 0.0 && minimumConfusionLevel < 1.0, |
| 752 | U"The minimum confusion level should be positive and smaller than 1.0."); |
| 753 | |
| 754 | autoDissimilaritycxx . . $ autoDissimilarity# thee = Dissimilarity_createcxx . . $ Dissimilarity_create(cdd51d9389725cda). (mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 755 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 756 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 757 | /* |
| 758 | Set all zero responses to the minimumConfusionLevel. |
| 759 | */ |
| 760 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; i ++) |
| 761 | for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 762 | if (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] == 0.0) |
| 763 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = minimumConfusionLevel; |
| 764 | |
| 765 | MAT_divideRowByRowsum_inplacecxx . . $ MAT_divideRowByRowsum_inplace(a810c3355071c044). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 766 | |
| 767 | /* |
| 768 | Consider the fraction as the fraction overlap between two gaussians with unequal sigmas (1 & s). |
| 769 | We have two matrix elements p [i] [j] && p [j] [i] |
| 770 | |
| 771 | N (x, m, s) = 1 / (s * sqrt(2 pi)) exp(-((x - m) / s)^2 / 2) |
| 772 | N1 (x) = N (x, 0, 1) |
| 773 | N2 (x) = N (x, m, s) |
| 774 | These two gaussians cross each other at a point X that can be found |
| 775 | by solving N1 (x) == N2 (x). |
| 776 | The solution that is important to us is: |
| 777 | X = (- m + s sqrt (m^2 - 2 (s^2 - 1) ln(s))) / (s^2 - 1) (1) |
| 778 | |
| 779 | This point X must be the solution of F (X, 0, 1) == p [i] [j], where |
| 780 | F (x, m, s) = P (x>X, m, s) = Integral (x, infinity, N (x, m, s) dx) |
| 781 | |
| 782 | We can solve for m and obtain: |
| 783 | m = X + s sqrt (X^2 + 2 ln (s)) (2) |
| 784 | |
| 785 | We also have |
| 786 | Integral (-Infinity, X, N2 (x) dx) == p [j] [i]; |
| 787 | By changing integration variables, (x - m) / s = y, we get |
| 788 | Integral ((x-m)/s, Infinity, N (y, 0, 1) dy) == p [j] [i] |
| 789 | Let this equation result in a value Y, i.e., (X - m) / s = Y (3) |
| 790 | |
| 791 | (2) and (3) together and solve for m: |
| 792 | |
| 793 | m = X + Y * exp ((Y * Y - X * X) / 2); |
| 794 | |
| 795 | Make maximum dissimilarity equal to 4sigma. |
| 796 | */ |
| 797 | |
| 798 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; i ++) { |
| 799 | for (integercxx . . $ integer# j = i + 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) { |
| 800 | const double px = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j], thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]); |
| 801 | const double py = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j], thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]); |
| 802 | const double x = NUMinvGaussQcxx . . $ NUMinvGaussQ(447c67c6676f75c3). (px); |
| 803 | const double y = NUMinvGaussQcxx . . $ NUMinvGaussQ(447c67c6676f75c3). (py); |
| 804 | const double d = x + y * expcxx . . $ exp(fee4f1d22bc8e617). ((y * y - x * x) / 2.0); |
| 805 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = d; |
| 806 | } |
| 807 | } |
| 808 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 809 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 810 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Dissimilarity created from pdf."); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | void Distance_Configuration_drawScatterDiagramcxx . . $ Distance_Configuration_drawScatterDiagram(c5c2a9080cb82b7c). (Distancecxx . . $ Distance# me, Configurationcxx . . $ Configuration# him, Graphicscxx . . $ Graphics# g, double xmin, double xmax, double ymin, double ymax, double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 815 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (him); |
| 816 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (me, dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 817 | } |
| 818 | |
| 819 | autoConfigurationcxx . . $ autoConfiguration# Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (Distancecxx . . $ Distance# me, integercxx . . $ integer# numberOfDimensions) { |
| 820 | try { |
| 821 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfDimensions <= mycxx . . $ `melder/melder.h:44:9`! numberOfRows, |
| 822 | U"Number of dimensions should not exceed ", mycxx . . $ `melder/melder.h:44:9`! numberOfRows, U"."); |
| 823 | autoScalarProductcxx . . $ autoScalarProduct# sp = Distance_to_ScalarProductcxx . . $ Distance_to_ScalarProduct(af226fe7231506a). (me, false); |
| 824 | autoConfigurationcxx . . $ autoConfiguration# thee = Configuration_createcxx . . $ Configuration_create(312218706738bb63). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfDimensions); |
| 825 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 0); |
| 826 | MAT_asPrincipalComponents_preallocatedcxx . . $ MAT_asPrincipalComponents_preallocated(128fc74062131bcf). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), spcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), numberOfDimensions); |
| 827 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 828 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 829 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (torsca method)."); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | autoScalarProductcxx . . $ autoScalarProduct# Distance_to_ScalarProductcxx . . $ Distance_to_ScalarProduct(af226fe7231506a). (Distancecxx . . $ Distance# me, bool normalize) { |
| 834 | try { |
| 835 | autoScalarProductcxx . . $ autoScalarProduct# thee = ScalarProduct_createcxx . . $ ScalarProduct_create(b2f6d4a7191477d). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 836 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 837 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) { |
| 838 | for (integercxx . . $ integer# j = i + 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) { |
| 839 | /* |
| 840 | Force symmetry by averaging! |
| 841 | */ |
| 842 | const double d = 0.5 * (mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] + mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]); |
| 843 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = - 0.5 * d * d; |
| 844 | } |
| 845 | // thy data [i] [i] = 0.0; // redundant |
| 846 | } |
| 847 | TableOfReal_doubleCentrecxx . . $ TableOfReal_doubleCentre(683412d750813a40). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 848 | |
| 849 | if (mycxx . . $ `melder/melder.h:44:9`! namecxx . . $ structThing#name.) |
| 850 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 851 | if (normalize) |
| 852 | TableOfReal_normalizeTablecxx . . $ TableOfReal_normalizeTable(9b898dd61a6a2e72). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0); |
| 853 | |
| 854 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 855 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 856 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no ScalarProduct created."); |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | /********** Configuration & ..... ***********************************/ |
| 861 | |
| 862 | |
| 863 | |
| 864 | void Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (Proximitycxx . . $ Proximity# me, Distancecxx . . $ Distance# thee, Graphicscxx . . $ Graphics# g, |
| 865 | double xmin, double xmax, double ymin, double ymax, double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 866 | const integercxx . . $ integer# n = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. * (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1) / 2; |
| 867 | |
| 868 | if (n == 0) |
| 869 | return; |
| 870 | |
| 871 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (NUMequal (mycxx . . $ `melder/melder.h:44:9`! rowLabels.get(), thycxx . . $ `melder/melder.h:45:9`! rowLabels.get()) && |
| 872 | NUMequal (mycxx . . $ `melder/melder.h:44:9`! columnLabels.get(), thycxx . . $ `melder/melder.h:45:9`! columnLabels.get()), |
| 873 | U"The labels should be the same."); |
| 874 | |
| 875 | constMATcxx . . $ constMAT# x = mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), y = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(); |
| 876 | if (xmax <= xmin) { |
| 877 | MelderExtremaWithInitcxx . . $ MelderExtremaWithInit# extrema; |
| 878 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) |
| 879 | for (integercxx . . $ integer# j = i + 1; j <= thycxx . . $ `melder/melder.h:45:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 880 | extrema.updatecxx . . $ MelderExtremaWithInit#update(ba8836b59fb42830). (x [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]); |
| 881 | xmin = extrema.mincxx . . $ MelderExtremaWithInit#min.; |
| 882 | xmax = extrema.maxcxx . . $ MelderExtremaWithInit#max.; |
| 883 | } |
| 884 | if (ymax <= ymin) { |
| 885 | MelderExtremaWithInitcxx . . $ MelderExtremaWithInit# extrema; |
| 886 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) |
| 887 | for (integercxx . . $ integer# j = i + 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 888 | extrema.updatecxx . . $ MelderExtremaWithInit#update(ba8836b59fb42830). (y [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]); |
| 889 | ymin = extrema.mincxx . . $ MelderExtremaWithInit#min.; |
| 890 | ymax = extrema.maxcxx . . $ MelderExtremaWithInit#max.; |
| 891 | } |
| 892 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, xmin, xmax, ymin, ymax); |
| 893 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g); |
| 894 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) |
| 895 | for (integercxx . . $ integer# j = i + 1; j <= thycxx . . $ `melder/melder.h:45:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 896 | if (x [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] >= xmin && x [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] <= xmax && y [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] >= ymin && y [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] <= ymax) |
| 897 | Graphics_markcxx . . $ Graphics_mark(406417efd31feba3). (g, x [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j], y [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j], size_mm, mark); |
| 898 | |
| 899 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g); |
| 900 | if (garnish) { |
| 901 | Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g); |
| 902 | Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, true, U"Distance"); |
| 903 | Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, true, U"Dissimilarity"); |
| 904 | Graphics_marksBottomcxx . . $ Graphics_marksBottom(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 905 | Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | autoDistanceListcxx . . $ autoDistanceList# MDSVecList_Distance_monotoneRegressioncxx . . $ MDSVecList_Distance_monotoneRegression(6f415ec2024c02ff). (MDSVecListcxx . . $ MDSVecList# me, Distancecxx . . $ Distance# thee, kMDS_TiesHandling tiesHandling) { |
| 910 | try { |
| 911 | autoDistanceListcxx . . $ autoDistanceList# him = DistanceList_createcxx . . $ DistanceList_create(dea20e937b1fc8dd). (); |
| 912 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 913 | const MDSVeccxx . . $ MDSVec# vec = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 914 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (vec -> numberOfPoints == thycxx . . $ `melder/melder.h:45:9`! numberOfRows, |
| 915 | U"Dimension of MDSVec and Distance should be equal."); |
| 916 | autoDistancecxx . . $ autoDistance# fit = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (vec, thee, tiesHandling); |
| 917 | hiscxx . . $ `melder/melder.h:47:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (fitcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 918 | } |
| 919 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 920 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 921 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No DistanceList created from MDSVecList and Distance."); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | autoDistancecxx . . $ autoDistance# MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (MDSVeccxx . . $ MDSVec# me, Distancecxx . . $ Distance# thee, kMDS_TiesHandling tiesHandling) { |
| 926 | try { |
| 927 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfPoints == thycxx . . $ `melder/melder.h:45:9`! numberOfColumns, |
| 928 | U"The dimensions of the Distance and the MDSVec should agree."); |
| 929 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (thycxx . . $ `melder/melder.h:45:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfPoints, |
| 930 | U"Distance and MDSVVec dimensions should agreee."); |
| 931 | const integercxx . . $ integer# numberOfProximities = mycxx . . $ `melder/melder.h:44:9`! numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; |
| 932 | autoVECcxx . . $ autoVEC# distances = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfProximities); |
| 933 | autoDistancecxx . . $ autoDistance# him = Distance_createcxx . . $ Distance_create(93683ff7a95ab9fe). (thycxx . . $ `melder/melder.h:45:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 934 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (thee, him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 1); |
| 935 | |
| 936 | for (integercxx . . $ integer# i = 1; i <= numberOfProximities; i ++) |
| 937 | distances [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]]; |
| 938 | |
| 939 | if (tiesHandling == kMDS_TiesHandling::PRIMARY_APPROACH || tiesHandling == kMDS_TiesHandling::SECONDARY_APPROACH) { |
| 940 | /* |
| 941 | Kruskal's primary approach to tie-blocks: |
| 942 | Sort corresponding distances, with rowIndex, and columnIndex. |
| 943 | Kruskal's secondary approach: |
| 944 | Substitute average distance in each tie block |
| 945 | */ |
| 946 | integercxx . . $ integer# ib = 1; |
| 947 | for (integercxx . . $ integer# i = 2; i <= numberOfProximities; i ++) { |
| 948 | if (mycxx . . $ `melder/melder.h:44:9`! proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] == mycxx . . $ `melder/melder.h:44:9`! proximitycxx . . $ structMDSVec#proximity. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i - 1]) |
| 949 | continue; |
| 950 | if (i - ib > 1) { |
| 951 | if (tiesHandling == kMDS_TiesHandling::PRIMARY_APPROACH) { |
| 952 | // all equal |
| 953 | } else if (tiesHandling == kMDS_TiesHandling::SECONDARY_APPROACH) { |
| 954 | const double mean = NUMmeancxx . . $ NUMmean(4bb9c3e3a8dd5442). (distancescxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..partcxx . . $ autovector#part(2d8d48654ca64e70). (ib, i - 1)); |
| 955 | distancescxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd)..partcxx . . $ autovector#part(2d8d48654ca64e70). (ib, i - 1) <<=cxx . . $ `operator<<=`(c555d170d72ff256). mean; |
| 956 | } |
| 957 | } |
| 958 | ib = i; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | autoVECcxx . . $ autoVEC# fit = newVECmonotoneRegressioncxx . . $ newVECmonotoneRegression(9f611ce50d479c14). (distancescxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 963 | /* |
| 964 | Fill Distance with monotone regressed distances |
| 965 | */ |
| 966 | for (integercxx . . $ integer# i = 1; i <= numberOfProximities; i ++) { |
| 967 | const integercxx . . $ integer# irow = mycxx . . $ `melder/melder.h:44:9`! rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], icol = mycxx . . $ `melder/melder.h:44:9`! columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 968 | hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).icol] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).irow] = fit [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 969 | } |
| 970 | /* |
| 971 | Make rest of distances equal to the maximum fit. |
| 972 | */ |
| 973 | for (integercxx . . $ integer# i = 1; i <= hiscxx . . $ `melder/melder.h:47:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) { |
| 974 | for (integercxx . . $ integer# j = i + 1; j <= hiscxx . . $ `melder/melder.h:47:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) { |
| 975 | if (hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] == 0.0) |
| 976 | hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = fit [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).numberOfProximities]; |
| 977 | } |
| 978 | } |
| 979 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 980 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 981 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Distance not created."); |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | |
| 986 | autoDistancecxx . . $ autoDistance# Dissimilarity_Distance_monotoneRegressioncxx . . $ Dissimilarity_Distance_monotoneRegression(e9e5a5eae5929b57). (Dissimilaritycxx . . $ Dissimilarity# me, Distancecxx . . $ Distance# thee, kMDS_TiesHandling tiesHandling) { |
| 987 | try { |
| 988 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (thycxx . . $ `melder/melder.h:45:9`! numberOfRows == mycxx . . $ `melder/melder.h:44:9`! numberOfRows, U"Dimensions should agree."); |
| 989 | autoMDSVeccxx . . $ autoMDSVec# vec = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (me); |
| 990 | autoDistancecxx . . $ autoDistance# him = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (vec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thee, tiesHandling); |
| 991 | return himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 992 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 993 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Distance not created."); |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | /*************** class Proximities **************************************/ |
| 998 | |
| 999 | autoScalarProductListcxx . . $ autoScalarProductList# DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (DistanceListcxx . . $ DistanceList# me, bool normalize) { |
| 1000 | try { |
| 1001 | autoScalarProductListcxx . . $ autoScalarProductList# thee = ScalarProductList_createcxx . . $ ScalarProductList_create(fe12af95446590cc). (); |
| 1002 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 1003 | autoScalarProductcxx . . $ autoScalarProduct# sp = Distance_to_ScalarProductcxx . . $ Distance_to_ScalarProduct(af226fe7231506a). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i], normalize); |
| 1004 | thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (spcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 1005 | } |
| 1006 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1007 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1008 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no ScalarProducts created."); |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | void DistanceList_to_Configuration_ytlcxx . . $ DistanceList_to_Configuration_ytl(48811c2fdfd82138). (DistanceListcxx . . $ DistanceList# me, integercxx . . $ integer# numberOfDimensions, integercxx . . $ integer# normalizeScalarProducts, autoConfigurationcxx . . $ autoConfiguration# *out1, autoSaliencecxx . . $ autoSalience# *out2) { |
| 1013 | try { |
| 1014 | autoScalarProductListcxx . . $ autoScalarProductList# sp = DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (me, normalizeScalarProducts); |
| 1015 | ScalarProductList_to_Configuration_ytlcxx . . $ ScalarProductList_to_Configuration_ytl(7a9a1a1aefca16a9). (sp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions, out1, out2); |
| 1016 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1017 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (ytl method)."); |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | /* |
| 1022 | Algorithm : F. Young, Y. Takane & R. Lewyckyj (1978), "Three notes on ALSCAL", |
| 1023 | Psychometrika 43, 433-435. |
| 1024 | */ |
| 1025 | void ScalarProductList_to_Configuration_ytlcxx . . $ ScalarProductList_to_Configuration_ytl(7a9a1a1aefca16a9). (ScalarProductListcxx . . $ ScalarProductList# me, integercxx . . $ integer# numberOfDimensions, autoConfigurationcxx . . $ autoConfiguration# *out1, autoSaliencecxx . . $ autoSalience# *out2) { |
| 1026 | try { |
| 1027 | const integercxx . . $ integer# numberOfSources = mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; |
| 1028 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfSources > 1, |
| 1029 | U"The number of sources should exceed one."); |
| 1030 | const integercxx . . $ integer# nPoints = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1] -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1031 | |
| 1032 | autoConfigurationcxx . . $ autoConfiguration# thee = Configuration_createcxx . . $ Configuration_create(312218706738bb63). (nPoints, numberOfDimensions); |
| 1033 | autoSaliencecxx . . $ autoSalience# mdsw = Salience_createcxx . . $ Salience_create(c072d15a45b2e699). (numberOfSources, numberOfDimensions); |
| 1034 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1], thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 0); |
| 1035 | |
| 1036 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (mdsw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"ytl"); |
| 1037 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"ytl"); |
| 1038 | TableOfReal_setLabelsFromCollectionItemNamescxx . . $ TableOfReal_setLabelsFromCollectionItemNames(ab1514337d93b725). (mdsw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), (Collectioncxx . . $ Collection#) me, true, false); // FIXME cast |
| 1039 | |
| 1040 | /* |
| 1041 | Determine the average scalar product matrix (Pmean) of dimension [1..nPoints] [1..nPoints]. |
| 1042 | */ |
| 1043 | autoMATcxx . . $ autoMAT# pmean = zero_MATcxx . . $ zero_MAT(3d09731056d2b97d). (nPoints, nPoints); |
| 1044 | |
| 1045 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 1046 | ScalarProductcxx . . $ ScalarProduct# sp = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 1047 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (sp -> numberOfRows == nPoints, |
| 1048 | U"The dimension of ScalarProduct ", i, U" does not conform."); |
| 1049 | pmean.allcxx . . $ automatrix#all(2114117ba8ed4224).() +=cxx . . $ `operator+=`(a7d93ba40fe22fe0). spcxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). -> datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 1050 | } |
| 1051 | |
| 1052 | pmean.allcxx . . $ automatrix#all(2114117ba8ed4224).() *=cxx . . $ `operator*=`(50b469ae42a42f64). 1.0 / numberOfSources; |
| 1053 | |
| 1054 | /* |
| 1055 | Up to a rotation K, the initial configuration can be found by |
| 1056 | extracting the first 'numberOfDimensions' principal components of Pmean. |
| 1057 | */ |
| 1058 | |
| 1059 | autoMATcxx . . $ autoMAT# y = MAT_asPrincipalComponentscxx . . $ MAT_asPrincipalComponents(4987e7f027662247). (pmeancxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66). (), numberOfDimensions); |
| 1060 | |
| 1061 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). ycxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58)..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 1062 | |
| 1063 | /* |
| 1064 | Calculate the C [i] matrices [1..numberOfDimensions] [1..numberOfDimensions] |
| 1065 | from the P [i] by: C [i] = (y'.y)^-1 . y' . P [i] . y . (y'.y)^-1 == yinv P [i] yinv' |
| 1066 | */ |
| 1067 | |
| 1068 | autoMATcxx . . $ autoMAT# yinv = newMATpseudoInversecxx . . $ newMATpseudoInverse(d05068067bdbbf5a). (ycxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), 1e-14); |
| 1069 | autoTEN3cxx . . $ autoTEN3# ci = raw_TEN3cxx . . $ raw_TEN3(80a4e4dae4df97ba). (numberOfSources, numberOfDimensions, numberOfDimensions); |
| 1070 | |
| 1071 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 1072 | const ScalarProductcxx . . $ ScalarProduct# sp = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 1073 | MATmul3_XYXtcxx . . $ MATmul3_XYXt(9e368e0da0f1874a). (ci [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).i], yinvcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), spcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d). -> datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); //yinv.Data.yinv' |
| 1074 | } |
| 1075 | |
| 1076 | /* |
| 1077 | Calculate the A [1..numberOfSources] [1..numberOfSources] matrix by (eq.12): |
| 1078 | a [i] [j] = trace (C [i]*C [j]) - trace (C [i]) * trace (C [j]) / numberOfDimensions; |
| 1079 | Get the first eigenvector and form matrix cl from a linear combination of the C [i]'s |
| 1080 | */ |
| 1081 | |
| 1082 | autoMATcxx . . $ autoMAT# a = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (numberOfSources, numberOfSources); |
| 1083 | |
| 1084 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 1085 | for (integercxx . . $ integer# j = i; j <= numberOfSources; j ++) { |
| 1086 | a [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = a [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = NUMtrace2cxx . . $ NUMtrace2(8213cc2c710f3dcb). (cicxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).i], cicxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).j]) |
| 1087 | - NUMtracecxx . . $ NUMtrace(7a3744b654164b28). (cicxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).i]) * NUMtracecxx . . $ NUMtrace(7a3744b654164b28). (cicxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).j]) / numberOfDimensions; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | autoMATcxx . . $ autoMAT# eveccxx . . $ automatrix#automatrix(49f6e7a06ebc5aa8).; |
| 1092 | |
| 1093 | MAT_getEigenSystemFromSymmetricMatrixcxx . . $ MAT_getEigenSystemFromSymmetricMatrix(5c0054344d6d0394). (acxx . . $ constmatrix#constmatrix(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), & evec, nullptr, false); |
| 1094 | |
| 1095 | autoMATcxx . . $ autoMAT# cl = zero_MATcxx . . $ zero_MAT(3d09731056d2b97d). (numberOfDimensions, numberOfDimensions); |
| 1096 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 1097 | for (integercxx . . $ integer# j = 1; j <= numberOfDimensions; j ++) { |
| 1098 | for (integercxx . . $ integer# k = 1; k <= numberOfDimensions; k ++) { |
| 1099 | cl [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] += ci [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).i] [cxx . . $ matrixview#`operator[]`(a8b9553e85c2b1fc).j] [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).k] * evec [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; /* eq. (7) TODO first column??*/ |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | /* |
| 1105 | The rotation K is obtained from the eigenvectors of cl |
| 1106 | Is the following still correct??? eigensystem was not sorted?? |
| 1107 | */ |
| 1108 | |
| 1109 | autoMATcxx . . $ autoMAT# Kcxx . . $ automatrix#automatrix(49f6e7a06ebc5aa8).; |
| 1110 | MAT_getEigenSystemFromSymmetricMatrixcxx . . $ MAT_getEigenSystemFromSymmetricMatrix(5c0054344d6d0394). (clcxx . . $ constmatrix#constmatrix(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), & K, nullptr, false); |
| 1111 | |
| 1112 | mul_MAT_outcxx . . $ mul_MAT_out(9e368e0da0f1874a). (thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), ycxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), Kcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); // Y.K |
| 1113 | |
| 1114 | Configuration_normalizecxx . . $ Configuration_normalize(d5cde0c5e772706a). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, true); |
| 1115 | |
| 1116 | /* |
| 1117 | And finally the weights: W [i] = K' C [i] K (eq. (5)). |
| 1118 | We are only interested in the diagonal of the resulting matrix W [i]. |
| 1119 | */ |
| 1120 | |
| 1121 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 1122 | for (integercxx . . $ integer# j = 1; j <= numberOfDimensions; j ++) { |
| 1123 | longdoublecxx . . $ longdouble# wt = 0.0; |
| 1124 | for (integercxx . . $ integer# k = 1; k <= numberOfDimensions; k ++) { |
| 1125 | if (K [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] != 0.0) { |
| 1126 | for (integercxx . . $ integer# l = 1; l <= numberOfDimensions; l ++) { |
| 1127 | wt += K [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * ci [cxx . . $ tensor3#`operator[]`(7cecab99a14fb313).i] [cxx . . $ matrixview#`operator[]`(a8b9553e85c2b1fc).k] [cxx . . $ vectorview#`operator[]`(8a4599b8835d1ce1).l] * K [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1128 | } |
| 1129 | } |
| 1130 | } |
| 1131 | mdsw ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = (double) wt; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | if (out1) |
| 1136 | *out1 =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). thee.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1137 | if (out2) |
| 1138 | *out2 =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). mdsw.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1139 | |
| 1140 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1141 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration (ytl) created."); |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | autoDissimilarityListcxx . . $ autoDissimilarityList# DistanceList_to_DissimilarityListcxx . . $ DistanceList_to_DissimilarityList(1a68362756057a60). (DistanceListcxx . . $ DistanceList# me) { |
| 1146 | try { |
| 1147 | autoDissimilarityListcxx . . $ autoDissimilarityList# thee = DissimilarityList_createcxx . . $ DissimilarityList_create(a3af885d9aaef8bb). (); |
| 1148 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 1149 | const conststring32cxx . . $ conststring32# name = Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]); |
| 1150 | autoDissimilaritycxx . . $ autoDissimilarity# him = Distance_to_Dissimilaritycxx . . $ Distance_to_Dissimilarity(3ef1c2fefce3b7fd). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]); |
| 1151 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (him.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), ( name ? name : U"untitled" )); |
| 1152 | thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (himcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 1153 | } |
| 1154 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1155 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1156 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no DissimilaryList created."); |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | /***************** Kruskal *****************************************/ |
| 1161 | |
| 1162 | static void smacof_guttmanTransformcxx . . $ smacof_guttmanTransform(d098afc9a7a2303d). (Configurationcxx . . $ Configuration# cx, Configurationcxx . . $ Configuration# cz, Distancecxx . . $ Distance# disp, Weightcxx . . $ Weight# weight, constMATcxx . . $ constMAT# vplus) { |
| 1163 | const integercxx . . $ integer# nPoints = cx -> numberOfRowscxx . . $ structTableOfReal#numberOfRows., nDimensions = cx -> numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 1164 | |
| 1165 | autoMATcxx . . $ autoMAT# b = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (nPoints, nPoints); |
| 1166 | autoDistancecxx . . $ autoDistance# distZ = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (cz); |
| 1167 | /* |
| 1168 | compute B(Z) (eq. 8.25) |
| 1169 | */ |
| 1170 | for (integercxx . . $ integer# i = 1; i <= nPoints; i ++) { |
| 1171 | longdoublecxx . . $ longdouble# sum = 0.0; |
| 1172 | for (integercxx . . $ integer# j = 1; j <= nPoints; j ++) { |
| 1173 | const double dzij = distZ ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1174 | if (i == j || dzij == 0.0) |
| 1175 | continue; |
| 1176 | b [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = - weight -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * disp -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] / dzij; |
| 1177 | sum += b [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1178 | } |
| 1179 | b [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] = - (double) sum; |
| 1180 | } |
| 1181 | /* |
| 1182 | Guttman transform: Xu = (V+)B(Z)Z (eq. 8.29) |
| 1183 | */ |
| 1184 | for (integercxx . . $ integer# i = 1; i <= nPoints; i ++) { |
| 1185 | for (integercxx . . $ integer# j = 1; j <= nDimensions; j ++) { |
| 1186 | longdoublecxx . . $ longdouble# xij = 0.0; |
| 1187 | for (integercxx . . $ integer# k = 1; k <= nPoints; k ++) { |
| 1188 | for (integercxx . . $ integer# l = 1; l <= nPoints; l ++) { |
| 1189 | xij += vplus [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).i] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).k] * b [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).l] * cz -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1190 | } |
| 1191 | } |
| 1192 | cx -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = (double) xij; |
| 1193 | } |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | double Distance_Weight_stresscxx . . $ Distance_Weight_stress(aff51d8706f3295b). (Distancecxx . . $ Distance# fit, Distancecxx . . $ Distance# conf, Weightcxx . . $ Weight# weight, kMDS_stressMeasure stressMeasure) { |
| 1198 | double stress = undefinedcxx . . $ undefined.; |
| 1199 | |
| 1200 | double eta_fit, eta_conf, rho; |
| 1201 | Distance_Weight_rawStressComponentscxx . . $ Distance_Weight_rawStressComponents(6045f99fcd72df8f). (fit, conf, weight, & eta_fit, & eta_conf, & rho); |
| 1202 | |
| 1203 | /* |
| 1204 | All formulas for stress, except for raw stress, are independent of the |
| 1205 | scale of the configuration, i.e., the distances conf [i] [j]. |
| 1206 | */ |
| 1207 | |
| 1208 | if (stressMeasure == kMDS_stressMeasure::NORMALIZED) { |
| 1209 | const double denum = eta_fit * eta_conf; |
| 1210 | if (denum > 0.0) |
| 1211 | stress = 1.0 - rho * rho / denum; |
| 1212 | } else if (stressMeasure == kMDS_stressMeasure::KRUSKAL_1) { |
| 1213 | const double denum = eta_fit * eta_conf; |
| 1214 | if (denum > 0.0) { |
| 1215 | const double tmp = 1.0 - rho * rho / denum; |
| 1216 | if (tmp > 0.0) |
| 1217 | stress = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (tmp); |
| 1218 | } |
| 1219 | } else if (stressMeasure == kMDS_stressMeasure::KRUSKAL_2) { |
| 1220 | /* |
| 1221 | Get average distance. |
| 1222 | */ |
| 1223 | const integercxx . . $ integer# nPoints = conf -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1224 | longdoublecxx . . $ longdouble# m = 0.0, wsum = 0.0; |
| 1225 | for (integercxx . . $ integer# i = 1; i <= nPoints - 1; i ++) { |
| 1226 | m += NUMinnercxx . . $ NUMinner(5e5adb47f563a3e3). (weightcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i).partcxx . . $ vector#part(ae267db9e2c04be7). (i + 1, nPoints), |
| 1227 | confcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i).partcxx . . $ vector#part(ae267db9e2c04be7). (i + 1, nPoints)); |
| 1228 | wsum += NUMsumcxx . . $ NUMsum(4bb9c3e3a8dd5442). (weightcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i).partcxx . . $ vector#part(ae267db9e2c04be7). (i + 1, nPoints)); |
| 1229 | } |
| 1230 | m /= wsum; |
| 1231 | if (m > 0.0) { |
| 1232 | /* |
| 1233 | Get variance. |
| 1234 | */ |
| 1235 | longdoublecxx . . $ longdouble# var = 0.0; |
| 1236 | for (integercxx . . $ integer# i = 1; i <= nPoints - 1; i ++) { |
| 1237 | for (integercxx . . $ integer# j = i + 1; j <= nPoints; j ++) { |
| 1238 | const longdoublecxx . . $ longdouble# tmp = conf -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] - m; |
| 1239 | var += weight -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * tmp * tmp; |
| 1240 | } |
| 1241 | } |
| 1242 | const double denum = double (var) * eta_fit; |
| 1243 | if (denum > 0.0) |
| 1244 | stress = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). ((eta_fit * eta_conf - rho * rho) / denum); |
| 1245 | } |
| 1246 | } else if (stressMeasure == kMDS_stressMeasure::RAW) { |
| 1247 | stress = eta_fit + eta_conf - 2.0 * rho; |
| 1248 | } |
| 1249 | return stress; |
| 1250 | } |
| 1251 | |
| 1252 | void Distance_Weight_rawStressComponentscxx . . $ Distance_Weight_rawStressComponents(6045f99fcd72df8f). (Distancecxx . . $ Distance# fit, Distancecxx . . $ Distance# conf, Weightcxx . . $ Weight# weight, double *out_etafit, double *out_etaconf, double *out_rho) |
| 1253 | { |
| 1254 | const integercxx . . $ integer# nPoints = conf -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1255 | longdoublecxx . . $ longdouble# etafit = 0.0, etaconf = 0.0, rho = 0.0; |
| 1256 | for (integercxx . . $ integer# i = 1; i <= nPoints - 1; i ++) { |
| 1257 | constVECcxx . . $ constVEC# wi = weightcxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1258 | constVECcxx . . $ constVEC# fiti = fitcxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1259 | constVECcxx . . $ constVEC# confi = confcxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1260 | for (integercxx . . $ integer# j = i + 1; j <= nPoints; j ++) { |
| 1261 | etafit += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * fiti [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * fiti [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1262 | etaconf += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * confi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * confi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1263 | rho += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * fiti [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * confi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1264 | } |
| 1265 | } |
| 1266 | if (out_etafit) |
| 1267 | *out_etafit = (double) etafit; |
| 1268 | if (out_etaconf) |
| 1269 | *out_etaconf = (double) etaconf; |
| 1270 | if (out_rho) |
| 1271 | *out_rho = (double) rho; |
| 1272 | } |
| 1273 | |
| 1274 | double Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Transformatorcxx . . $ Transformator# t, Weightcxx . . $ Weight# w, kMDS_stressMeasure stressMeasure) { |
| 1275 | const integercxx . . $ integer# nPoints = d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1276 | double stress = undefinedcxx . . $ undefined.; |
| 1277 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (nPoints > 0 && nPoints == c -> numberOfRows && nPoints == t -> numberOfPoints || |
| 1278 | (w && nPoints == w -> numberOfRows), |
| 1279 | U"Dimensions should agree."); |
| 1280 | |
| 1281 | autoWeightcxx . . $ autoWeight# awcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 1282 | if (! w) { |
| 1283 | aw =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (nPoints); |
| 1284 | w = aw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 1285 | } |
| 1286 | autoDistancecxx . . $ autoDistance# cdist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (c); |
| 1287 | autoMDSVeccxx . . $ autoMDSVec# mdsvec = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (d); |
| 1288 | autoDistancecxx . . $ autoDistance# fit = Transformator_transformcxx . . $ Transformator_transform(3e516a08078d98a0). (t, mdsvec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1289 | |
| 1290 | stress = Distance_Weight_stresscxx . . $ Distance_Weight_stress(aff51d8706f3295b). (fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1291 | return stress; |
| 1292 | } |
| 1293 | |
| 1294 | double Dissimilarity_Configuration_Weight_absolute_stresscxx . . $ Dissimilarity_Configuration_Weight_absolute_stress(b3f814738c955394). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, kMDS_stressMeasure stressMeasure) { |
| 1295 | autoTransformatorcxx . . $ autoTransformator# t = Transformator_createcxx . . $ Transformator_create(59a7737283154f8a). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1296 | double stress = Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1297 | return stress; |
| 1298 | } |
| 1299 | |
| 1300 | double Dissimilarity_Configuration_Weight_ratio_stresscxx . . $ Dissimilarity_Configuration_Weight_ratio_stress(b3f814738c955394). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, kMDS_stressMeasure stressMeasure) { |
| 1301 | autoRatioTransformatorcxx . . $ autoRatioTransformator# t = RatioTransformator_createcxx . . $ RatioTransformator_create(bfd0554b6ddec263). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1302 | const double stress = Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1303 | return stress; |
| 1304 | } |
| 1305 | |
| 1306 | double Dissimilarity_Configuration_Weight_interval_stresscxx . . $ Dissimilarity_Configuration_Weight_interval_stress(b3f814738c955394). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, kMDS_stressMeasure stressMeasure) { |
| 1307 | autoISplineTransformatorcxx . . $ autoISplineTransformator# t = ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows., 0, 1); |
| 1308 | const double stress = Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1309 | return stress; |
| 1310 | } |
| 1311 | |
| 1312 | double Dissimilarity_Configuration_Weight_monotone_stresscxx . . $ Dissimilarity_Configuration_Weight_monotone_stress(4749923a339d1c8d). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, kMDS_TiesHandling tiesHandling, kMDS_stressMeasure stressMeasure) { |
| 1313 | autoMonotoneTransformatorcxx . . $ autoMonotoneTransformator# t = MonotoneTransformator_createcxx . . $ MonotoneTransformator_create(695d2932d7073386). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1314 | MonotoneTransformator_setTiesProcessingcxx . . $ MonotoneTransformator_setTiesProcessing(dcdd256c093f1b38). (t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1315 | const double stress = Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1316 | return stress; |
| 1317 | } |
| 1318 | |
| 1319 | double Dissimilarity_Configuration_Weight_ispline_stresscxx . . $ Dissimilarity_Configuration_Weight_ispline_stress(75baa9a73a633506). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfInteriorKnots, integercxx . . $ integer# order, kMDS_stressMeasure stressMeasure) { |
| 1320 | autoISplineTransformatorcxx . . $ autoISplineTransformator# t = ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfInteriorKnots, order); |
| 1321 | const double stress = Dissimilarity_Configuration_Transformator_Weight_stresscxx . . $ Dissimilarity_Configuration_Transformator_Weight_stress(f323e5621caaf5b). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, stressMeasure); |
| 1322 | return stress; |
| 1323 | } |
| 1324 | |
| 1325 | void Distance_Weight_smacofNormalizecxx . . $ Distance_Weight_smacofNormalize(c2d60f06b518eb4f). (Distancecxx . . $ Distance# me, Weightcxx . . $ Weight# w) { |
| 1326 | longdoublecxx . . $ longdouble# sumsq = 0.0; |
| 1327 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; i ++) |
| 1328 | for (integercxx . . $ integer# j = i + 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; j ++) |
| 1329 | sumsq += w -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1330 | |
| 1331 | const double scale = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. * (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1) / double (2.0 * sumsq)); |
| 1332 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() *=cxx . . $ `operator*=`(50b469ae42a42f64). scale; |
| 1333 | } |
| 1334 | |
| 1335 | double Distance_Weight_congruenceCoefficientcxx . . $ Distance_Weight_congruenceCoefficient(ec87364adc15653a). (Distancecxx . . $ Distance# x, Distancecxx . . $ Distance# y, Weightcxx . . $ Weight# w) { |
| 1336 | const integercxx . . $ integer# nPoints = x -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1337 | if (y -> numberOfRowscxx . . $ structTableOfReal#numberOfRows. != nPoints || w -> numberOfRowscxx . . $ structTableOfReal#numberOfRows. != nPoints) |
| 1338 | return 0.0; |
| 1339 | |
| 1340 | double xy = 0.0, x2 = 0.0, y2 = 0.0; |
| 1341 | for (integercxx . . $ integer# i = 1; i <= nPoints - 1; i ++) { |
| 1342 | constVECcxx . . $ constVEC# xi = xcxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1343 | constVECcxx . . $ constVEC# yi = ycxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1344 | constVECcxx . . $ constVEC# wi = wcxx . . $ constvector#constvector(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 1345 | for (integercxx . . $ integer# j = i + 1; j <= nPoints - 1; j ++) { |
| 1346 | xy += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * xi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * yi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1347 | x2 += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * xi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * xi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1348 | y2 += wi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * yi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j] * yi [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).j]; |
| 1349 | } |
| 1350 | } |
| 1351 | return xy / (sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (x2) * sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (y2)); |
| 1352 | } |
| 1353 | |
| 1354 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_Transformator_smacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_smacof(f00ebdfe08480ec8). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# conf, Weightcxx . . $ Weight# weight, Transformatorcxx . . $ Transformator# t, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, double *out_stress) { |
| 1355 | try { |
| 1356 | const integercxx . . $ integer# nPoints = conf -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1357 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! numberOfRows == nPoints && t -> numberOfPoints == nPoints || |
| 1358 | (weight && weight -> numberOfRows == nPoints), |
| 1359 | U"Dimensions should agree."); |
| 1360 | |
| 1361 | autoWeightcxx . . $ autoWeight# awcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 1362 | if (! weight) { |
| 1363 | aw =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (nPoints); |
| 1364 | weight = aw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 1365 | } |
| 1366 | autoMATcxx . . $ autoMAT# v = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (nPoints, nPoints); |
| 1367 | autoConfigurationcxx . . $ autoConfiguration# z = Data_copycxx . . $ Data_copy(97a542a26794c80e). (conf); |
| 1368 | autoMDSVeccxx . . $ autoMDSVec# vec = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (me); |
| 1369 | |
| 1370 | if (showProgress) |
| 1371 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"MDS analysis"); |
| 1372 | |
| 1373 | // Get V (eq. 8.19). |
| 1374 | |
| 1375 | for (integercxx . . $ integer# irow = 1; irow <= nPoints; irow ++) { |
| 1376 | longdoublecxx . . $ longdouble# wsum = 0.0; |
| 1377 | for (integercxx . . $ integer# icol = 1; icol <= nPoints; icol ++) { |
| 1378 | if (irow != icol) { |
| 1379 | v [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = - weight -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]; |
| 1380 | wsum += weight -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]; |
| 1381 | } |
| 1382 | } |
| 1383 | v [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).irow] = (double) wsum; |
| 1384 | } |
| 1385 | |
| 1386 | /* |
| 1387 | V is row and column centered and therefore: rank(V) <= nPoints-1. |
| 1388 | V^-1 does not exist -> get Moore-Penrose inverse. |
| 1389 | */ |
| 1390 | constexpr double tol = 1e-6; |
| 1391 | autoMATcxx . . $ autoMAT# vplus = newMATpseudoInversecxx . . $ newMATpseudoInverse(d05068067bdbbf5a). (vcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), tol); |
| 1392 | double stressp = 1e308, stress = 0.0; |
| 1393 | for (integercxx . . $ integer# iter = 1; iter <= numberOfIterations; iter ++) { |
| 1394 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (conf); |
| 1395 | /* |
| 1396 | transform & normalization |
| 1397 | */ |
| 1398 | autoDistancecxx . . $ autoDistance# fit = Transformator_transformcxx . . $ Transformator_transform(3e516a08078d98a0). (t, vec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight); |
| 1399 | /* |
| 1400 | Make conf the Guttman transform of z |
| 1401 | */ |
| 1402 | smacof_guttmanTransformcxx . . $ smacof_guttmanTransform(d098afc9a7a2303d). (conf, z.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight, vpluscxx . . $ constmatrix#constmatrix(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 1403 | /* |
| 1404 | Compute stress |
| 1405 | */ |
| 1406 | autoDistancecxx . . $ autoDistance# cdist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (conf); |
| 1407 | |
| 1408 | stress = Distance_Weight_stresscxx . . $ Distance_Weight_stress(aff51d8706f3295b). (fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight, kMDS_stressMeasure::NORMALIZED); |
| 1409 | /* |
| 1410 | Check stop criterium |
| 1411 | */ |
| 1412 | if (fabscxx . . $ fabs(fee4f1d22bc8e617). (stress - stressp) / stressp < tolerance) break; |
| 1413 | /* |
| 1414 | Make Z = X |
| 1415 | */ |
| 1416 | z ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). confcxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). -> datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 1417 | |
| 1418 | stressp = stress; |
| 1419 | if (showProgress) |
| 1420 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). ((double) iter / (numberOfIterations + 1), U"kruskal: stress ", stress); |
| 1421 | } |
| 1422 | if (showProgress) |
| 1423 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1424 | if (out_stress) |
| 1425 | *out_stress = stress; |
| 1426 | return zcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1427 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1428 | if (showProgress) |
| 1429 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1430 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (smacof method)."); |
| 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# conf, Weightcxx . . $ Weight# w, Transformatorcxx . . $ Transformator# t, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1435 | bool showMulti = showProgress && numberOfRepetitions > 1; |
| 1436 | try { |
| 1437 | const bool showSingle = showProgress && numberOfRepetitions == 1; |
| 1438 | autoConfigurationcxx . . $ autoConfiguration# cstart = Data_copycxx . . $ Data_copy(97a542a26794c80e). (conf); |
| 1439 | autoConfigurationcxx . . $ autoConfiguration# cbest = Data_copycxx . . $ Data_copy(97a542a26794c80e). (conf); |
| 1440 | |
| 1441 | if (showMulti) |
| 1442 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"MDS many times"); |
| 1443 | |
| 1444 | double stress, stressmax = 1e308; |
| 1445 | for (integercxx . . $ integer# i = 1; i <= numberOfRepetitions; i ++) { |
| 1446 | autoConfigurationcxx . . $ autoConfiguration# cresult = Dissimilarity_Configuration_Weight_Transformator_smacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_smacof(f00ebdfe08480ec8). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, t, tolerance, numberOfIterations, showSingle, & stress); |
| 1447 | if (stress < stressmax) { |
| 1448 | stressmax = stress; |
| 1449 | cbest =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). cresult.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1450 | } |
| 1451 | Configuration_randomizecxx . . $ Configuration_randomize(4cfce9233baadf27). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 1452 | TableOfReal_centreColumnscxx . . $ TableOfReal_centreColumns(683412d750813a40). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 1453 | |
| 1454 | if (showMulti) |
| 1455 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). ((double) i / (numberOfRepetitions + 1), i, U" from ", numberOfRepetitions); |
| 1456 | } |
| 1457 | if (showMulti) |
| 1458 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1459 | return cbestcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1460 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1461 | if (showMulti) |
| 1462 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1463 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (smacodf method)."); |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_absolute_mdscxx . . $ Dissimilarity_Configuration_Weight_absolute_mds(c56b518efa1482e9). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# cstart, Weightcxx . . $ Weight# w, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1468 | try { |
| 1469 | autoTransformatorcxx . . $ autoTransformator# t = Transformator_createcxx . . $ Transformator_create(59a7737283154f8a). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1470 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (me, cstart, w, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1471 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1472 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1473 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (absolute mds method)."); |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_ratio_mdscxx . . $ Dissimilarity_Configuration_Weight_ratio_mds(c56b518efa1482e9). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# cstart, Weightcxx . . $ Weight# w, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1478 | try { |
| 1479 | autoRatioTransformatorcxx . . $ autoRatioTransformator# t = RatioTransformator_createcxx . . $ RatioTransformator_create(bfd0554b6ddec263). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1480 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (me, cstart, w, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1481 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1482 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1483 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (ratio mds method)."); |
| 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_interval_mdscxx . . $ Dissimilarity_Configuration_Weight_interval_mds(c56b518efa1482e9). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# cstart, Weightcxx . . $ Weight# w, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1488 | try { |
| 1489 | autoISplineTransformatorcxx . . $ autoISplineTransformator# t = ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., 0, 1); |
| 1490 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (me, cstart, w, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1491 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1492 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1493 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (interval mds method)."); |
| 1494 | } |
| 1495 | } |
| 1496 | |
| 1497 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_monotone_mdscxx . . $ Dissimilarity_Configuration_Weight_monotone_mds(ff6ef7fc7a12f81f). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# cstart, Weightcxx . . $ Weight# w, kMDS_TiesHandling tiesHandling, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1498 | try { |
| 1499 | autoMonotoneTransformatorcxx . . $ autoMonotoneTransformator# t = MonotoneTransformator_createcxx . . $ MonotoneTransformator_create(695d2932d7073386). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1500 | MonotoneTransformator_setTiesProcessingcxx . . $ MonotoneTransformator_setTiesProcessing(dcdd256c093f1b38). (t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1501 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (me, cstart, w, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1502 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1503 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1504 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (monotone mds method)."); |
| 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_Weight_ispline_mdscxx . . $ Dissimilarity_Configuration_Weight_ispline_mds(65c1ca0631515641). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# cstart, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfInteriorKnots, integercxx . . $ integer# order, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1509 | try { |
| 1510 | autoISplineTransformatorcxx . . $ autoISplineTransformator# t = ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfInteriorKnots, order); |
| 1511 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_Transformator_multiSmacofcxx . . $ Dissimilarity_Configuration_Weight_Transformator_multiSmacof(58ebc36f61912abc). (me, cstart, w, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1512 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1513 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1514 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no improved Configuration created (ispline mds method)."); |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Weight_absolute_mdscxx . . $ Dissimilarity_Weight_absolute_mds(4461e3653e5a4480). (Dissimilaritycxx . . $ Dissimilarity# me, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfDimensions, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1519 | try { |
| 1520 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::ABSOLUTE_); |
| 1521 | autoConfigurationcxx . . $ autoConfiguration# cstart = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1522 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_absolute_mdscxx . . $ Dissimilarity_Configuration_Weight_absolute_mds(c56b518efa1482e9). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1523 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1524 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1525 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (absolute mds method)."); |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Weight_interval_mdscxx . . $ Dissimilarity_Weight_interval_mds(4461e3653e5a4480). (Dissimilaritycxx . . $ Dissimilarity# me, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfDimensions, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1530 | try { |
| 1531 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::RATIO); |
| 1532 | autoConfigurationcxx . . $ autoConfiguration# cstart = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1533 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_interval_mdscxx . . $ Dissimilarity_Configuration_Weight_interval_mds(c56b518efa1482e9). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1534 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1535 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1536 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (interval mds method)."); |
| 1537 | } |
| 1538 | } |
| 1539 | |
| 1540 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Weight_monotone_mdscxx . . $ Dissimilarity_Weight_monotone_mds(a75b55af50cc43fa). (Dissimilaritycxx . . $ Dissimilarity# me, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfDimensions, kMDS_TiesHandling tiesHandling, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1541 | try { |
| 1542 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::ORDINAL); |
| 1543 | autoConfigurationcxx . . $ autoConfiguration# cstart = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1544 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_monotone_mdscxx . . $ Dissimilarity_Configuration_Weight_monotone_mds(ff6ef7fc7a12f81f). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, tiesHandling, tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1545 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1546 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1547 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (monotone mds method)."); |
| 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Weight_ratio_mdscxx . . $ Dissimilarity_Weight_ratio_mds(4461e3653e5a4480). (Dissimilaritycxx . . $ Dissimilarity# me, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfDimensions, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1552 | try { |
| 1553 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::RATIO); |
| 1554 | autoConfigurationcxx . . $ autoConfiguration# cstart = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1555 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_ratio_mdscxx . . $ Dissimilarity_Configuration_Weight_ratio_mds(c56b518efa1482e9). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, tolerance, |
| 1556 | numberOfIterations, numberOfRepetitions, showProgress); |
| 1557 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1558 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1559 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (ratio mds method)."); |
| 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Weight_ispline_mdscxx . . $ Dissimilarity_Weight_ispline_mds(8a4a87ad01a306e9). (Dissimilaritycxx . . $ Dissimilarity# me, Weightcxx . . $ Weight# w, integercxx . . $ integer# numberOfDimensions, integercxx . . $ integer# numberOfInteriorKnots, integercxx . . $ integer# order, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress) { |
| 1564 | try { |
| 1565 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::ORDINAL); |
| 1566 | autoConfigurationcxx . . $ autoConfiguration# cstart = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1567 | autoConfigurationcxx . . $ autoConfiguration# c = Dissimilarity_Configuration_Weight_ispline_mdscxx . . $ Dissimilarity_Configuration_Weight_ispline_mds(65c1ca0631515641). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w, |
| 1568 | numberOfInteriorKnots, order, tolerance, numberOfIterations, numberOfRepetitions, showProgress); |
| 1569 | return ccxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1570 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1571 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (ispline mds method)."); |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | /***** classical **/ |
| 1576 | |
| 1577 | static void MDSVec_Distances_getStressValuescxx . . $ MDSVec_Distances_getStressValues(554152236f601307). (MDSVeccxx . . $ MDSVec# me, Distancecxx . . $ Distance# ddist, Distancecxx . . $ Distance# dfit, kMDS_KruskalStress stress_formula, double *out_stress, double *out_s, double *out_t, double *out_dbar) { |
| 1578 | |
| 1579 | longdoublecxx . . $ longdouble# s = 0.0, t = 0.0, dbar = 0.0; |
| 1580 | |
| 1581 | if (stress_formula == kMDS_KruskalStress::KRUSKAL_1) { |
| 1582 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 1583 | dbar += ddist -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]]; |
| 1584 | } |
| 1585 | dbar /= mycxx . . $ `melder/melder.h:44:9`! numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; |
| 1586 | } |
| 1587 | |
| 1588 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 1589 | const integercxx . . $ integer# ii = mycxx . . $ `melder/melder.h:44:9`! rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], jj = mycxx . . $ `melder/melder.h:44:9`! columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 1590 | const double st = ddist -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] - dfit -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj]; |
| 1591 | const double tt = ddist -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] - dbar; |
| 1592 | s += st * st; |
| 1593 | t += tt * tt; |
| 1594 | } |
| 1595 | |
| 1596 | if (out_stress) |
| 1597 | *out_stress = ( t > 0.0 ? sqrtcxx . . $ sqrt(cd6880bb7604d12e). (s / t) : 0.0 ); |
| 1598 | if (out_s) |
| 1599 | *out_s = s; |
| 1600 | if (out_t) |
| 1601 | *out_t = t; |
| 1602 | if (out_dbar) |
| 1603 | *out_dbar = dbar; |
| 1604 | } |
| 1605 | |
| 1606 | autoKruskalcxx . . $ autoKruskal# Kruskal_createcxx . . $ Kruskal_create(84a8221d5fc17b10). (integercxx . . $ integer# numberOfPoints, integercxx . . $ integer# numberOfDimensions) { |
| 1607 | try { |
| 1608 | autoKruskalcxx . . $ autoKruskal# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Kruskal); |
| 1609 | mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Configuration_createcxx . . $ Configuration_create(312218706738bb63). (numberOfPoints, numberOfDimensions); |
| 1610 | mycxx . . $ `melder/melder.h:44:9`! proximitiescxx . . $ structKruskal#proximities. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). ProximityList_createcxx . . $ ProximityList_create(dd608ec6324dfc5e). (); |
| 1611 | mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structKruskal#dx. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (numberOfPoints, numberOfDimensions); |
| 1612 | mycxx . . $ `melder/melder.h:44:9`! tiesHandlingcxx . . $ structKruskal#tiesHandling. = kMDS_TiesHandling::PRIMARY_APPROACH; |
| 1613 | mycxx . . $ `melder/melder.h:44:9`! stress_formulacxx . . $ structKruskal#stress_formula. = kMDS_KruskalStress::KRUSKAL_1; |
| 1614 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1615 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1616 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Kruskal not created."); |
| 1617 | } |
| 1618 | } |
| 1619 | |
| 1620 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_to_Configuration_kruskalcxx . . $ Dissimilarity_to_Configuration_kruskal(ed0ae891faafbf4b). (Dissimilaritycxx . . $ Dissimilarity# me, integercxx . . $ integer# numberOfDimensions, integercxx . . $ integer# /* metric */, kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions) { |
| 1621 | try { |
| 1622 | //autoDistance d = Dissimilarity_to_Distance (me, kMDS_AnalysisScale::RATIO); |
| 1623 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_to_Distancecxx . . $ Dissimilarity_to_Distance(db1d1bec99f5a21b). (me, kMDS_AnalysisScale::ORDINAL); |
| 1624 | autoConfigurationcxx . . $ autoConfiguration# c = Distance_to_Configuration_torscacxx . . $ Distance_to_Configuration_torsca(cb197680767b373b). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions); |
| 1625 | Configuration_normalizecxx . . $ Configuration_normalize(d5cde0c5e772706a). (c.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0, false); |
| 1626 | autoConfigurationcxx . . $ autoConfiguration# thee = Dissimilarity_Configuration_kruskalcxx . . $ Dissimilarity_Configuration_kruskal(c0ef0cd66200370d). (me, c.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling, stress_formula, tolerance, numberOfIterations, numberOfRepetitions); |
| 1627 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1628 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1629 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created (kruskal method)."); |
| 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | void Dissimilarity_Configuration_drawShepardDiagramcxx . . $ Dissimilarity_Configuration_drawShepardDiagram(9d4ae5a9669745c5). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# him, Graphicscxx . . $ Graphics# g, |
| 1634 | double xmin, double xmax, double ymin, double ymax, |
| 1635 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1636 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (him); |
| 1637 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (me, dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1638 | } |
| 1639 | |
| 1640 | autoDistancecxx . . $ autoDistance# Dissimilarity_Configuration_monotoneRegressioncxx . . $ Dissimilarity_Configuration_monotoneRegression(d611f3e09278819d). (Dissimilaritycxx . . $ Dissimilarity# dissimilarity, Configurationcxx . . $ Configuration# configuration, kMDS_TiesHandling tiesHandling) { |
| 1641 | try { |
| 1642 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (configuration); |
| 1643 | autoDistancecxx . . $ autoDistance# result = Dissimilarity_Distance_monotoneRegressioncxx . . $ Dissimilarity_Distance_monotoneRegression(e9e5a5eae5929b57). (dissimilarity, dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1644 | return resultcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1645 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1646 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No Distance created (monotone regression)."); |
| 1647 | } |
| 1648 | } |
| 1649 | |
| 1650 | autoDistanceListcxx . . $ autoDistanceList# DissimilarityList_Configuration_monotoneRegressioncxx . . $ DissimilarityList_Configuration_monotoneRegression(ae8bd1dfb1080b7f). (DissimilarityListcxx . . $ DissimilarityList# me, Configurationcxx . . $ Configuration# configuration, kMDS_TiesHandling tiesHandling) { |
| 1651 | try { |
| 1652 | autoDistanceListcxx . . $ autoDistanceList# thee = DistanceList_createcxx . . $ DistanceList_create(dea20e937b1fc8dd). (); |
| 1653 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (configuration); |
| 1654 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 1655 | autoDistancecxx . . $ autoDistance# d = Dissimilarity_Distance_monotoneRegressioncxx . . $ Dissimilarity_Distance_monotoneRegression(e9e5a5eae5929b57). (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i], dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1656 | thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (dcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 1657 | } |
| 1658 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1659 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1660 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No DistanceList created (monotone regression)."); |
| 1661 | } |
| 1662 | } |
| 1663 | |
| 1664 | void Dissimilarity_Configuration_drawMonotoneRegressioncxx . . $ Dissimilarity_Configuration_drawMonotoneRegression(758544bbf5ebdda9). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# him, Graphicscxx . . $ Graphics# g, kMDS_TiesHandling tiesHandling, double xmin, double xmax, double ymin, double ymax, double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) |
| 1665 | { |
| 1666 | /* obsolete replace by transformator */ |
| 1667 | autoDistancecxx . . $ autoDistance# fit = Dissimilarity_Configuration_monotoneRegressioncxx . . $ Dissimilarity_Configuration_monotoneRegression(d611f3e09278819d). (me, him, tiesHandling); |
| 1668 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (me, fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1669 | } |
| 1670 | |
| 1671 | void Dissimilarity_Configuration_Weight_drawAbsoluteRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawAbsoluteRegression(1dbdf1893d04c428). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, Graphicscxx . . $ Graphics# g, |
| 1672 | double xmin, double xmax, double ymin, double ymax, |
| 1673 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1674 | autoTransformatorcxx . . $ autoTransformator# t = Transformator_createcxx . . $ Transformator_create(59a7737283154f8a). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1675 | autoDistancecxx . . $ autoDistance# fit = Dissimilarity_Configuration_Transformator_Weight_transformcxx . . $ Dissimilarity_Configuration_Transformator_Weight_transform(f80ed23d2096fb61). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1676 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (d, fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1677 | } |
| 1678 | |
| 1679 | void Dissimilarity_Configuration_Weight_drawRatioRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawRatioRegression(1dbdf1893d04c428). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, Graphicscxx . . $ Graphics# g, |
| 1680 | double xmin, double xmax, double ymin, double ymax, |
| 1681 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1682 | autoRatioTransformatorcxx . . $ autoRatioTransformator# t = RatioTransformator_createcxx . . $ RatioTransformator_create(bfd0554b6ddec263). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1683 | autoDistancecxx . . $ autoDistance# fit = Dissimilarity_Configuration_Transformator_Weight_transformcxx . . $ Dissimilarity_Configuration_Transformator_Weight_transform(f80ed23d2096fb61). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1684 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (d, fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1685 | } |
| 1686 | |
| 1687 | void Dissimilarity_Configuration_Weight_drawIntervalRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawIntervalRegression(1dbdf1893d04c428). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, Graphicscxx . . $ Graphics# g, |
| 1688 | double xmin, double xmax, double ymin, double ymax, |
| 1689 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1690 | Dissimilarity_Configuration_Weight_drawISplineRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawISplineRegression(c1f59f696e3777ae). (d, c, w, g, 0.0, 1.0, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1691 | } |
| 1692 | |
| 1693 | void Dissimilarity_Configuration_Weight_drawMonotoneRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawMonotoneRegression(a3caef64c3314073). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, Graphicscxx . . $ Graphics# g, |
| 1694 | kMDS_TiesHandling tiesHandling, double xmin, double xmax, double ymin, double ymax, |
| 1695 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1696 | autoMonotoneTransformatorcxx . . $ autoMonotoneTransformator# t = MonotoneTransformator_createcxx . . $ MonotoneTransformator_create(695d2932d7073386). (d->numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1697 | MonotoneTransformator_setTiesProcessingcxx . . $ MonotoneTransformator_setTiesProcessing(dcdd256c093f1b38). (t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1698 | autoDistancecxx . . $ autoDistance# fit = Dissimilarity_Configuration_Transformator_Weight_transformcxx . . $ Dissimilarity_Configuration_Transformator_Weight_transform(f80ed23d2096fb61). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1699 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (d, fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1700 | } |
| 1701 | |
| 1702 | void Dissimilarity_Configuration_Weight_drawISplineRegressioncxx . . $ Dissimilarity_Configuration_Weight_drawISplineRegression(c1f59f696e3777ae). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Weightcxx . . $ Weight# w, Graphicscxx . . $ Graphics# g, |
| 1703 | integercxx . . $ integer# numberOfInternalKnots, integercxx . . $ integer# order, double xmin, double xmax, double ymin, double ymax, |
| 1704 | double size_mm, conststring32cxx . . $ conststring32# mark, bool garnish) { |
| 1705 | autoISplineTransformatorcxx . . $ autoISplineTransformator# t = ISplineTransformator_createcxx . . $ ISplineTransformator_create(84c3d3cc258fa3ed). (d->numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfInternalKnots, order); |
| 1706 | autoDistancecxx . . $ autoDistance# fit = Dissimilarity_Configuration_Transformator_Weight_transformcxx . . $ Dissimilarity_Configuration_Transformator_Weight_transform(f80ed23d2096fb61). (d, c, t.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1707 | Proximity_Distance_drawScatterDiagramcxx . . $ Proximity_Distance_drawScatterDiagram(7dea12c736bfe01). (d, fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), g, xmin, xmax, ymin, ymax, size_mm, mark, garnish); |
| 1708 | } |
| 1709 | |
| 1710 | autoDistancecxx . . $ autoDistance# Dissimilarity_Configuration_Transformator_Weight_transformcxx . . $ Dissimilarity_Configuration_Transformator_Weight_transform(f80ed23d2096fb61). (Dissimilaritycxx . . $ Dissimilarity# d, Configurationcxx . . $ Configuration# c, Transformatorcxx . . $ Transformator# t, Weightcxx . . $ Weight# w) { |
| 1711 | try { |
| 1712 | autoWeightcxx . . $ autoWeight# awcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 1713 | if (! w) { |
| 1714 | aw =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Weight_createcxx . . $ Weight_create(1aa410d7f32a10c0). (d -> numberOfRowscxx . . $ structTableOfReal#numberOfRows.); |
| 1715 | w = aw.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 1716 | } |
| 1717 | autoDistancecxx . . $ autoDistance# cdist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (c); |
| 1718 | autoMDSVeccxx . . $ autoMDSVec# v = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (d); |
| 1719 | autoDistancecxx . . $ autoDistance# thee = Transformator_transformcxx . . $ Transformator_transform(3e516a08078d98a0). (t, v.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), w); |
| 1720 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 1721 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1722 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Distance not created."); |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | double Dissimilarity_Configuration_Weight_Transformator_normalizedStresscxx . . $ Dissimilarity_Configuration_Weight_Transformator_normalizedStress(b8eca6c5ed5fb7f6). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# conf, Weightcxx . . $ Weight# weight, Transformatorcxx . . $ Transformator# t) { |
| 1727 | autoDistancecxx . . $ autoDistance# cdist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (conf); |
| 1728 | autoMDSVeccxx . . $ autoMDSVec# vec = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (me); |
| 1729 | autoDistancecxx . . $ autoDistance# fdist = Transformator_transformcxx . . $ Transformator_transform(3e516a08078d98a0). (t, vec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight); |
| 1730 | const double stress = Distance_Weight_stresscxx . . $ Distance_Weight_stress(aff51d8706f3295b). (fdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), cdist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), weight, kMDS_stressMeasure::NORMALIZED); |
| 1731 | return stress; |
| 1732 | } |
| 1733 | |
| 1734 | double Dissimilarity_Configuration_getStresscxx . . $ Dissimilarity_Configuration_getStress(202d2c8ac0be20a3). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# him, kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula) { |
| 1735 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (him); |
| 1736 | autoMDSVeccxx . . $ autoMDSVec# vec = Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (me); |
| 1737 | autoDistancecxx . . $ autoDistance# fit = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (vec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1738 | double stress; |
| 1739 | MDSVec_Distances_getStressValuescxx . . $ MDSVec_Distances_getStressValues(554152236f601307). (vec.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), stress_formula, & stress, nullptr, nullptr, nullptr); |
| 1740 | return stress; |
| 1741 | } |
| 1742 | |
| 1743 | static double funccxx . . $ func(798b806ccf84f768). (Daatacxx . . $ Daata# object, VECcxx . . $ VEC# const& p) { |
| 1744 | Kruskalcxx . . $ Kruskal# me = (Kruskalcxx . . $ Kruskal#) object; |
| 1745 | const MDSVeccxx . . $ MDSVec# him = mycxx . . $ `melder/melder.h:44:9`! veccxx . . $ structKruskal#vec..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 1746 | const MATcxx . . $ MAT# x = mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).(); |
| 1747 | double s, t, dbar, stress; |
| 1748 | const integercxx . . $ integer# numberOfDimensions = mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 1749 | const integercxx . . $ integer# numberOfPoints = mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 1750 | /* |
| 1751 | Substitute results of minimizer into configuration and |
| 1752 | normalize the configuration |
| 1753 | */ |
| 1754 | MATfromVEC_inplacecxx . . $ MATfromVEC_inplace(16d8a87020bfd1b1). (xcxx . . $ matrixview#matrixview(eed9513d24570b3d)., pcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd).); |
| 1755 | centreEachColumn_MAT_inoutcxx . . $ centreEachColumn_MAT_inout(5dd9f6ea610bc98c). (xcxx . . $ matrixview#matrixview(eed9513d24570b3d).); |
| 1756 | MATnormalize_inplacecxx . . $ MATnormalize_inplace(2fdf026ca2b4c21). (xcxx . . $ matrixview#matrixview(eed9513d24570b3d)., 2.0, sqrtcxx . . $ sqrt(7759b11ec49fe502). (numberOfPoints)); |
| 1757 | /* |
| 1758 | Calculate interpoint distances from the configuration |
| 1759 | */ |
| 1760 | autoDistancecxx . . $ autoDistance# dist = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 1761 | /* |
| 1762 | Monotone regression |
| 1763 | */ |
| 1764 | autoDistancecxx . . $ autoDistance# fit = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (mycxx . . $ `melder/melder.h:44:9`! veccxx . . $ structKruskal#vec..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! tiesHandlingcxx . . $ structKruskal#tiesHandling.); |
| 1765 | /* |
| 1766 | Get numerator and denominator of stress |
| 1767 | */ |
| 1768 | MDSVec_Distances_getStressValuescxx . . $ MDSVec_Distances_getStressValues(554152236f601307). (mycxx . . $ `melder/melder.h:44:9`! veccxx . . $ structKruskal#vec..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), dist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), fit.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! stress_formulacxx . . $ structKruskal#stress_formula., & stress, & s, & t, & dbar); |
| 1769 | /* |
| 1770 | Prevent overflow when stress is small |
| 1771 | */ |
| 1772 | if (stress >= 1e-6) { |
| 1773 | mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structKruskal#dx..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 0.0; |
| 1774 | for (integercxx . . $ integer# i = 1; i <= hiscxx . . $ `melder/melder.h:47:9`! numberOfProximitiescxx . . $ structMDSVec#numberOfProximities.; i ++) { |
| 1775 | const integercxx . . $ integer# ii = mycxx . . $ `melder/melder.h:44:9`! veccxx . . $ structKruskal#vec. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). rowIndexcxx . . $ structMDSVec#rowIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], jj = mycxx . . $ `melder/melder.h:44:9`! veccxx . . $ structKruskal#vec. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). columnIndexcxx . . $ structMDSVec#columnIndex. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 1776 | const double g1 = stress * ((dist ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] - fit ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj]) / s - (dist ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj] - dbar) / t); |
| 1777 | for (integercxx . . $ integer# j = 1; j <= numberOfDimensions; j ++) { |
| 1778 | const double dj = x [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] - x [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).jj] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1779 | double g2 = g1 * powcxx . . $ pow(b71928d39fde4295). (fabscxx . . $ fabs(fee4f1d22bc8e617). (dj) / dist ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).jj], mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). metriccxx . . $ structConfiguration#metric. - 1.0); |
| 1780 | if (dj < 0.0) |
| 1781 | g2 = -g2; |
| 1782 | mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structKruskal#dx. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).ii] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] += g2; |
| 1783 | mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structKruskal#dx. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).jj] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] -= g2; |
| 1784 | } |
| 1785 | } |
| 1786 | } |
| 1787 | (mycxx . . $ `melder/melder.h:44:9`! minimizercxx . . $ structKruskal#minimizer. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfFunctionCallscxx . . $ structMinimizer#numberOfFunctionCalls.) ++; |
| 1788 | return stress; |
| 1789 | } |
| 1790 | |
| 1791 | /* |
| 1792 | Precondition: configuration was not changed since previous call to func |
| 1793 | */ |
| 1794 | static void dfunccxx . . $ dfunc(b88fc210334e1b81). (Daatacxx . . $ Daata# object, VECcxx . . $ VEC# const& /* p */, VECcxx . . $ VEC# const& dp) { |
| 1795 | const Kruskalcxx . . $ Kruskal# me = (Kruskalcxx . . $ Kruskal#) object; |
| 1796 | const Configurationcxx . . $ Configuration# thee = mycxx . . $ `melder/melder.h:44:9`! configurationcxx . . $ structKruskal#configuration..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 1797 | |
| 1798 | integercxx . . $ integer# k = 1; |
| 1799 | for (integercxx . . $ integer# i = 1; i <= thycxx . . $ `melder/melder.h:45:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) { |
| 1800 | for (integercxx . . $ integer# j = 1; j <= thycxx . . $ `melder/melder.h:45:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 1801 | dp [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k ++] = mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structKruskal#dx. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1802 | } |
| 1803 | } |
| 1804 | |
| 1805 | autoConfigurationcxx . . $ autoConfiguration# Dissimilarity_Configuration_kruskalcxx . . $ Dissimilarity_Configuration_kruskal(c0ef0cd66200370d). (Dissimilaritycxx . . $ Dissimilarity# me, Configurationcxx . . $ Configuration# him, kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions) { |
| 1806 | try { |
| 1807 | /* |
| 1808 | The Configuration is normalized: each dimension centred + |
| 1809 | total variance set to 1.0 |
| 1810 | */ |
| 1811 | const integercxx . . $ integer# numberOfCoordinates = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. * hiscxx . . $ `melder/melder.h:47:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 1812 | const integercxx . . $ integer# numberOfParameters = numberOfCoordinates - hiscxx . . $ `melder/melder.h:47:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1; |
| 1813 | const integercxx . . $ integer# numberOfData = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. * (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1) / 2; |
| 1814 | |
| 1815 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (numberOfParameters <= numberOfData, |
| 1816 | U"The number of parameters should not exceed the number of data."); |
| 1817 | |
| 1818 | autoKruskalcxx . . $ autoKruskal# thee = Kruskal_createcxx . . $ Kruskal_create(84a8221d5fc17b10). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., hiscxx . . $ `melder/melder.h:47:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 1819 | TableOfReal_copyLabelscxx . . $ TableOfReal_copyLabels(4a8870dfd6c30d44). (me, thycxx . . $ `melder/melder.h:45:9`! configurationcxx . . $ structKruskal#configuration..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, 0); |
| 1820 | autoDissimilaritycxx . . $ autoDissimilarity# dissimilarity = Data_copycxx . . $ Data_copy(97a542a26794c80e). (me); |
| 1821 | thycxx . . $ `melder/melder.h:45:9`! proximitiescxx . . $ structKruskal#proximities. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (dissimilaritycxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 1822 | thycxx . . $ `melder/melder.h:45:9`! veccxx . . $ structKruskal#vec. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Dissimilarity_to_MDSVeccxx . . $ Dissimilarity_to_MDSVec(85c5d8f810079c7c). (me); |
| 1823 | |
| 1824 | thycxx . . $ `melder/melder.h:45:9`! minimizercxx . . $ structKruskal#minimizer. =cxx . . $ autoSomeThing#`operator=`(ed6a1a4da6aedae3). VDSmagtMinimizer_createcxx . . $ VDSmagtMinimizer_create(db2e53d812b6eef7). (numberOfCoordinates, (Daatacxx . . $ Daata#) thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), funccxx . . $ func(798b806ccf84f768)., dfunccxx . . $ dfunc(b88fc210334e1b81).); |
| 1825 | |
| 1826 | VECchainRows_preallocatedcxx . . $ VECchainRows_preallocated(4ac231a09fafb822). (thycxx . . $ `melder/melder.h:45:9`! minimizercxx . . $ structKruskal#minimizer. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pcxx . . $ structMinimizer#p..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 1827 | |
| 1828 | thycxx . . $ `melder/melder.h:45:9`! stress_formulacxx . . $ structKruskal#stress_formula. = stress_formula; |
| 1829 | thycxx . . $ `melder/melder.h:45:9`! tiesHandlingcxx . . $ structKruskal#tiesHandling. = tiesHandling; |
| 1830 | Configuration_setMetriccxx . . $ Configuration_setMetric(84077623e938518a). (thycxx . . $ `melder/melder.h:45:9`! configurationcxx . . $ structKruskal#configuration..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), hiscxx . . $ `melder/melder.h:47:9`! metriccxx . . $ structConfiguration#metric.); |
| 1831 | |
| 1832 | Minimizer_minimizeManyTimescxx . . $ Minimizer_minimizeManyTimes(6f5f44f2f964a5b2). (thycxx . . $ `melder/melder.h:45:9`! minimizercxx . . $ structKruskal#minimizer..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfIterations, numberOfRepetitions, tolerance); |
| 1833 | |
| 1834 | // call the function to get the best configuration |
| 1835 | |
| 1836 | (void) funccxx . . $ func(798b806ccf84f768). ((Daatacxx . . $ Daata#) thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thycxx . . $ `melder/melder.h:45:9`! minimizercxx . . $ structKruskal#minimizer. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pcxx . . $ structMinimizer#p..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 1837 | return thycxx . . $ `melder/melder.h:45:9`! configurationcxx . . $ structKruskal#configuration..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1838 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1839 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Configuration created."); |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | /************************** INDSCAL **************************************/ |
| 1844 | |
| 1845 | /* |
| 1846 | Ten Berge, Kiers & Krijnen (1993), Computational Solutions for the |
| 1847 | Problem of Negative Saliences and Nonsymmetry in INDSCAL, Journal of Classification 10, 115-124. |
| 1848 | */ |
| 1849 | |
| 1850 | static void indscal_iteration_tenBergecxx . . $ indscal_iteration_tenBerge(94220fdb72e7b519). (ScalarProductListcxx . . $ ScalarProductList# zc, Configurationcxx . . $ Configuration# xc, Saliencecxx . . $ Salience# weights) { |
| 1851 | const integercxx . . $ integer# nPoints = xc -> numberOfRowscxx . . $ structTableOfReal#numberOfRows., nDimensions = xc -> numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 1852 | const integercxx . . $ integer# nSources = zc->sizecxx . . $ CollectionOf#size.; |
| 1853 | |
| 1854 | const double tolerance = 1e-4; // reasonable for dominant eigenvector estimation. |
| 1855 | autoMATcxx . . $ autoMAT# wsih = raw_MATcxx . . $ raw_MAT(3d09731056d2b97d). (nPoints, nPoints); |
| 1856 | autoVECcxx . . $ autoVEC# solution = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (nPoints); |
| 1857 | |
| 1858 | for (integercxx . . $ integer# h = 1; h <= nDimensions; h ++) { |
| 1859 | autoScalarProductListcxx . . $ autoScalarProductList# sprc = Data_copycxx . . $ Data_copy(97a542a26794c80e). (zc); |
| 1860 | wsih.allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(50b469ae42a42f64). 0.0; |
| 1861 | for (integercxx . . $ integer# i = 1; i <= nSources; i ++) { |
| 1862 | const ScalarProductcxx . . $ ScalarProduct# sih = sprc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 1863 | /* |
| 1864 | Construct the Sih matrices (eq. 6) |
| 1865 | */ |
| 1866 | for (integercxx . . $ integer# j = 1; j <= nDimensions; j ++) { |
| 1867 | if (j != h) { |
| 1868 | for (integercxx . . $ integer# k = 1; k <= nPoints; k ++) |
| 1869 | for (integercxx . . $ integer# l = 1; l <= nPoints; l ++) |
| 1870 | sih -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).l] -= xc -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * xc -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] * weights -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]; |
| 1871 | } |
| 1872 | } |
| 1873 | /* |
| 1874 | the weighted S matrix (eq. 8) |
| 1875 | */ |
| 1876 | wsih.allcxx . . $ automatrix#all(2114117ba8ed4224).() +=cxx . . $ `operator+=`(b78e8a4998bd3572). sihcxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58). -> datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() *cxx . . $ `operator*`(3dd25102fdc24343). weights -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).h]; |
| 1877 | } |
| 1878 | |
| 1879 | solution.allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). xccxx . . $ constvectorview#constvectorview(5c6f246bf1d99401). -> datacxx . . $ structTableOfReal#data..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (h); // initial guess |
| 1880 | /* |
| 1881 | largest eigenvalue of wsih (nonsymmetric matrix!!) is optimal solution for this dimension |
| 1882 | */ |
| 1883 | (void) VECdominantEigenvector_inplacecxx . . $ VECdominantEigenvector_inplace(35a6868fae9f156b). (solution.getcxx . . $ autovector#get(e8d1da7fe68a6585).(), wsihcxx . . $ constmatrix#constmatrix(eed9513d24570b3d)..getcxx . . $ automatrix#get(b2b81450b5bdda66).(), tolerance); |
| 1884 | /* |
| 1885 | normalize the solution: centre and x'x = 1 |
| 1886 | */ |
| 1887 | double mean; |
| 1888 | centre_VEC_inoutcxx . . $ centre_VEC_inout(b915798f9bafc8a). (solutioncxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), & mean); |
| 1889 | if (mean == 0.0) |
| 1890 | continue; |
| 1891 | VECnormalize_inplacecxx . . $ VECnormalize_inplace(963991e5268b1933). (solutioncxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 2.0, 1.0); |
| 1892 | |
| 1893 | for (integercxx . . $ integer# k = 1; k <= nPoints; k ++) |
| 1894 | xc -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).h] = solution [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).k]; |
| 1895 | /* |
| 1896 | update weights. Make negative weights zero. |
| 1897 | */ |
| 1898 | for (integercxx . . $ integer# i = 1; i <= nSources; i ++) { |
| 1899 | const ScalarProductcxx . . $ ScalarProduct# spr = sprc ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 1900 | longdoublecxx . . $ longdouble# wih = 0.0; |
| 1901 | for (integercxx . . $ integer# k = 1; k <= nPoints; k ++) { |
| 1902 | for (integercxx . . $ integer# l = 1; l <= nPoints; l ++) |
| 1903 | wih += xc -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).h] * spr -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).k] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).l] * xc -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).h]; |
| 1904 | } |
| 1905 | if (wih < 0.0) |
| 1906 | wih = 0.0; |
| 1907 | weights -> datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).h] = double (wih); |
| 1908 | } |
| 1909 | } |
| 1910 | } |
| 1911 | |
| 1912 | |
| 1913 | void ScalarProductList_Configuration_Salience_indscalcxx . . $ ScalarProductList_Configuration_Salience_indscal(c96890aca4e33b94). (ScalarProductListcxx . . $ ScalarProductList# sp, Configurationcxx . . $ Configuration# configuration, Saliencecxx . . $ Salience# weights, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out_conf, autoSaliencecxx . . $ autoSalience# *out_sal, double *out_varianceAccountedFor) { |
| 1914 | try { |
| 1915 | autoConfigurationcxx . . $ autoConfiguration# conf = Data_copycxx . . $ Data_copy(97a542a26794c80e). (configuration); |
| 1916 | autoSaliencecxx . . $ autoSalience# sal = Data_copycxx . . $ Data_copy(97a542a26794c80e). (weights); |
| 1917 | /* |
| 1918 | Solve for X, and W matrix via Alternating Least Squares. |
| 1919 | */ |
| 1920 | if (showProgress) |
| 1921 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"INDSCAL analysis"); |
| 1922 | double vafp = 0.0, varianceAccountedFor; |
| 1923 | const double tol = 1e-6; |
| 1924 | integercxx . . $ integer# iter; |
| 1925 | for (iter = 1; iter <= numberOfIterations; iter ++) { |
| 1926 | indscal_iteration_tenBergecxx . . $ indscal_iteration_tenBerge(94220fdb72e7b519). (sp, conf.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), sal.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 1927 | /* |
| 1928 | Goodness of fit and test criterion. |
| 1929 | */ |
| 1930 | ScalarProductList_Configuration_Salience_vafcxx . . $ ScalarProductList_Configuration_Salience_vaf(e6c124e8055a2d38). (sp, conf.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), sal.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), & varianceAccountedFor); |
| 1931 | |
| 1932 | if (varianceAccountedFor > 1.0 - tol || fabscxx . . $ fabs(fee4f1d22bc8e617). (varianceAccountedFor - vafp) / vafp < tolerance) |
| 1933 | break; |
| 1934 | |
| 1935 | vafp = varianceAccountedFor; |
| 1936 | if (showProgress) Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (iter / (numberOfIterations + 1.0), |
| 1937 | U"indscal: varianceAccountedFor ", varianceAccountedFor); |
| 1938 | } |
| 1939 | const integercxx . . $ integer# numberOfZeros = NUMcountZeroscxx . . $ NUMcountZeros(f49a0b798c9b6ef3). (salcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 1940 | |
| 1941 | if (out_conf) { |
| 1942 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (conf.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"indscal"); |
| 1943 | *out_conf =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). conf.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1944 | } |
| 1945 | if (out_sal) { |
| 1946 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (sal.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"indscal"); |
| 1947 | TableOfReal_setLabelsFromCollectionItemNamescxx . . $ TableOfReal_setLabelsFromCollectionItemNames(ab1514337d93b725). (sal.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), (Collectioncxx . . $ Collection#) sp, true, false); // FIXME cast |
| 1948 | *out_sal =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). sal.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 1949 | } |
| 1950 | if (out_varianceAccountedFor) |
| 1951 | *out_varianceAccountedFor = varianceAccountedFor; |
| 1952 | if (showProgress) { |
| 1953 | const integercxx . . $ integer# nSources = sp->sizecxx . . $ CollectionOf#size.; |
| 1954 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"**************** INDSCAL results on Distances *******************\n\n", |
| 1955 | Thing_classNamecxx . . $ Thing_className(fbb3dc34e3ef688d). (sp), U"number of objects: ", nSources); |
| 1956 | for (integercxx . . $ integer# i = 1; i <= nSources; i ++) |
| 1957 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" ", Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (sp->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i])); |
| 1958 | |
| 1959 | if (numberOfZeros > 0) |
| 1960 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"WARNING: ", numberOfZeros, U" zero weight", ( numberOfZeros > 1 ? U"s" : U"" ), U"!"); |
| 1961 | |
| 1962 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\n\nVariance Accounted For = ", varianceAccountedFor, U"\nThe optimal configuration was reached in ", ( iter > numberOfIterations ? numberOfIterations : iter ), U" iterations."); |
| 1963 | MelderInfo_draincxx . . $ MelderInfo_drain(49f6e7a06ebc5aa8).(); |
| 1964 | } |
| 1965 | if (showProgress) |
| 1966 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1967 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1968 | if (showProgress) { |
| 1969 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 1970 | } |
| 1971 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No indscal configuration calculated."); |
| 1972 | } |
| 1973 | } |
| 1974 | |
| 1975 | void DistanceList_Configuration_Salience_indscalcxx . . $ DistanceList_Configuration_Salience_indscal(fedfad592847cd3). (DistanceListcxx . . $ DistanceList# distances, Configurationcxx . . $ Configuration# configuration, Saliencecxx . . $ Salience# weights, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out1, autoSaliencecxx . . $ autoSalience# *out2, double *out_varianceAccountedFor) { |
| 1976 | try { |
| 1977 | autoScalarProductListcxx . . $ autoScalarProductList# sp = DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (distances, normalizeScalarProducts); |
| 1978 | ScalarProductList_Configuration_Salience_indscalcxx . . $ ScalarProductList_Configuration_Salience_indscal(c96890aca4e33b94). (sp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), configuration, weights, tolerance, numberOfIterations, showProgress, out1, out2, out_varianceAccountedFor); |
| 1979 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 1980 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No indscal configuration calculated."); |
| 1981 | } |
| 1982 | } |
| 1983 | |
| 1984 | void DissimilarityList_Configuration_Salience_indscalcxx . . $ DissimilarityList_Configuration_Salience_indscal(2c8f220638c77694). (DissimilarityListcxx . . $ DissimilarityList# dissims, Configurationcxx . . $ Configuration# conf, Saliencecxx . . $ Salience# weights, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out_configuration, autoSaliencecxx . . $ autoSalience# *out_salience, double *out_varianceAccountedFor) { |
| 1985 | try { |
| 1986 | autoConfigurationcxx . . $ autoConfiguration# configuration = Data_copycxx . . $ Data_copy(97a542a26794c80e). (conf); |
| 1987 | autoSaliencecxx . . $ autoSalience# salience = Data_copycxx . . $ Data_copy(97a542a26794c80e). (weights); |
| 1988 | autoMDSVecListcxx . . $ autoMDSVecList# mdsveclist = DissimilarityList_to_MDSVecListcxx . . $ DissimilarityList_to_MDSVecList(e3bc9589d47cfee1). (dissims); |
| 1989 | |
| 1990 | if (showProgress) |
| 1991 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"INDSCAL analysis"); |
| 1992 | |
| 1993 | const double tol = 1e-6; |
| 1994 | double vafp = 0.0, vaf; |
| 1995 | integercxx . . $ integer# iter; |
| 1996 | for (iter = 1; iter <= numberOfIterations; iter ++) { |
| 1997 | autoDistanceListcxx . . $ autoDistanceList# distances = MDSVecList_Configuration_Salience_monotoneRegressioncxx . . $ MDSVecList_Configuration_Salience_monotoneRegression(17e17409e69af4ec). (mdsveclist.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), configuration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 1998 | autoScalarProductListcxx . . $ autoScalarProductList# sp = DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), normalizeScalarProducts); |
| 1999 | |
| 2000 | indscal_iteration_tenBergecxx . . $ indscal_iteration_tenBerge(94220fdb72e7b519). (sp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), configuration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2001 | /* |
| 2002 | Goodness of fit and test criterion. |
| 2003 | */ |
| 2004 | DistanceList_Configuration_Salience_vafcxx . . $ DistanceList_Configuration_Salience_vaf(1d9b38452e9b0f2d). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), configuration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), normalizeScalarProducts, & vaf); |
| 2005 | |
| 2006 | if (vaf > 1.0 - tol || fabscxx . . $ fabs(fee4f1d22bc8e617). (vaf - vafp) < vafp * tolerance) |
| 2007 | break; |
| 2008 | vafp = vaf; |
| 2009 | if (showProgress) |
| 2010 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). ((double) iter / (numberOfIterations + 1), U"indscal: vaf ", vaf); |
| 2011 | } |
| 2012 | integercxx . . $ integer# numberOfZeros = NUMcountZeroscxx . . $ NUMcountZeros(f49a0b798c9b6ef3). (saliencecxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d). ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data..getcxx . . $ automatrix#get(b2b81450b5bdda66).()); |
| 2013 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (configuration.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"indscal_mr"); |
| 2014 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"indscal_mr"); |
| 2015 | TableOfReal_setLabelsFromCollectionItemNamescxx . . $ TableOfReal_setLabelsFromCollectionItemNames(ab1514337d93b725). (salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), (Collectioncxx . . $ Collection#) dissims, true, false); // FIXME cast |
| 2016 | |
| 2017 | if (out_configuration) |
| 2018 | *out_configuration =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). configuration.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2019 | if (out_salience) |
| 2020 | *out_salience =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). salience.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2021 | if (out_varianceAccountedFor) |
| 2022 | *out_varianceAccountedFor = vaf; |
| 2023 | |
| 2024 | if (showProgress) { |
| 2025 | const integercxx . . $ integer# nSources = dissims->sizecxx . . $ CollectionOf#size.; |
| 2026 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"**************** INDSCAL with monotone regression *******************"); |
| 2027 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (Thing_classNamecxx . . $ Thing_className(fbb3dc34e3ef688d). (dissims)); |
| 2028 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of objects: ", nSources); |
| 2029 | for (integercxx . . $ integer# i = 1; i <= nSources; i ++) |
| 2030 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" ", Thing_getNamecxx . . $ Thing_getName(fbb3dc34e3ef688d). (dissims->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i])); |
| 2031 | if (numberOfZeros > 0) |
| 2032 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"WARNING: ", numberOfZeros, U" zero weight", ( numberOfZeros > 1 ? U"s" : U"" )); |
| 2033 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Variance Accounted For: ", vaf); |
| 2034 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Based on MONOTONE REGRESSION"); |
| 2035 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"number of iterations: ", (iter > numberOfIterations ? numberOfIterations : iter)); |
| 2036 | MelderInfo_draincxx . . $ MelderInfo_drain(49f6e7a06ebc5aa8).(); |
| 2037 | } |
| 2038 | if (showProgress) |
| 2039 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2040 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2041 | if (showProgress) |
| 2042 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2043 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No inscal configuration calculated."); |
| 2044 | } |
| 2045 | } |
| 2046 | |
| 2047 | void DistanceList_Configuration_indscalcxx . . $ DistanceList_Configuration_indscal(9ce66b66acf16869). (DistanceListcxx . . $ DistanceList# dists, Configurationcxx . . $ Configuration# conf, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out1, autoSaliencecxx . . $ autoSalience# *out2) { |
| 2048 | try { |
| 2049 | autoSaliencecxx . . $ autoSalience# w = Salience_createcxx . . $ Salience_create(c072d15a45b2e699). (dists->sizecxx . . $ CollectionOf#size., conf -> numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 2050 | double vaf; |
| 2051 | DistanceList_Configuration_Salience_indscalcxx . . $ DistanceList_Configuration_Salience_indscal(fedfad592847cd3). (dists, conf, w.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), normalizeScalarProducts, tolerance, numberOfIterations, showProgress, out1, out2, & vaf); |
| 2052 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2053 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No indscal performed."); |
| 2054 | } |
| 2055 | } |
| 2056 | |
| 2057 | autoDistanceListcxx . . $ autoDistanceList# MDSVecList_Configuration_Salience_monotoneRegressioncxx . . $ MDSVecList_Configuration_Salience_monotoneRegression(17e17409e69af4ec). (MDSVecListcxx . . $ MDSVecList# vecs, Configurationcxx . . $ Configuration# conf, Saliencecxx . . $ Salience# weights, kMDS_TiesHandling tiesHandling) { |
| 2058 | try { |
| 2059 | autoVECcxx . . $ autoVEC# w = copy_VECcxx . . $ copy_VEC(d4415e68b25283a8). (confcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> wcxx . . $ structConfiguration#w..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); |
| 2060 | autoDistanceListcxx . . $ autoDistanceList# distances = DistanceList_createcxx . . $ DistanceList_create(dea20e937b1fc8dd). (); |
| 2061 | for (integercxx . . $ integer# i = 1; i <= vecs->sizecxx . . $ CollectionOf#size.; i ++) { |
| 2062 | conf -> wcxx . . $ structConfiguration#w..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). weightscxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> datacxx . . $ structTableOfReal#data..rowcxx . . $ automatrix#row(2d545b3cb3f8e666). (i); |
| 2063 | autoDistancecxx . . $ autoDistance# dc = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (conf); |
| 2064 | autoDistancecxx . . $ autoDistance# dist = MDSVec_Distance_monotoneRegressioncxx . . $ MDSVec_Distance_monotoneRegression(a21a4808c03f5908). (vecs->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i], dc.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling); |
| 2065 | distances ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (distcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 2066 | } |
| 2067 | Configuration_setDefaultWeightscxx . . $ Configuration_setDefaultWeights(4cfce9233baadf27). (conf); |
| 2068 | return distancescxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2069 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2070 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No DistanceList created."); |
| 2071 | } |
| 2072 | } |
| 2073 | |
| 2074 | autoSaliencecxx . . $ autoSalience# DistanceList_Configuration_to_Saliencecxx . . $ DistanceList_Configuration_to_Salience(ca35ffb2c4126684). (DistanceListcxx . . $ DistanceList# d, Configurationcxx . . $ Configuration# c, bool normalize) { |
| 2075 | try { |
| 2076 | autoScalarProductListcxx . . $ autoScalarProductList# sp = DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (d, normalize); |
| 2077 | autoSaliencecxx . . $ autoSalience# w = ScalarProductList_Configuration_to_Saliencecxx . . $ ScalarProductList_Configuration_to_Salience(9e0a6ff475b40f8). (sp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), c); |
| 2078 | return wcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2079 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2080 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No Salience created."); |
| 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | autoSaliencecxx . . $ autoSalience# ScalarProductList_Configuration_to_Saliencecxx . . $ ScalarProductList_Configuration_to_Salience(9e0a6ff475b40f8). (ScalarProductListcxx . . $ ScalarProductList# me, Configurationcxx . . $ Configuration# him) { |
| 2085 | try { |
| 2086 | autoSaliencecxx . . $ autoSalience# salience = Salience_createcxx . . $ Salience_create(c072d15a45b2e699). (mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size., hiscxx . . $ `melder/melder.h:47:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 2087 | autoConfigurationcxx . . $ autoConfiguration# cx = Data_copycxx . . $ Data_copy(97a542a26794c80e). (him); |
| 2088 | indscal_iteration_tenBergecxx . . $ indscal_iteration_tenBerge(94220fdb72e7b519). (me, cx.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), salience.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2089 | return saliencecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2090 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2091 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No Salience created."); |
| 2092 | } |
| 2093 | } |
| 2094 | |
| 2095 | autoSaliencecxx . . $ autoSalience# DissimilarityList_Configuration_to_Saliencecxx . . $ DissimilarityList_Configuration_to_Salience(6d428a9bdf879c21). (DissimilarityListcxx . . $ DissimilarityList# me, Configurationcxx . . $ Configuration# him, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts) { |
| 2096 | try { |
| 2097 | autoDistanceListcxx . . $ autoDistanceList# distances = DissimilarityList_Configuration_monotoneRegressioncxx . . $ DissimilarityList_Configuration_monotoneRegression(ae8bd1dfb1080b7f). (me, him, tiesHandling); |
| 2098 | autoSaliencecxx . . $ autoSalience# w = DistanceList_Configuration_to_Saliencecxx . . $ DistanceList_Configuration_to_Salience(ca35ffb2c4126684). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), him, normalizeScalarProducts); |
| 2099 | return wcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2100 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2101 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No Salience created."); |
| 2102 | } |
| 2103 | } |
| 2104 | |
| 2105 | void DissimilarityList_Configuration_indscalcxx . . $ DissimilarityList_Configuration_indscal(c5e4660dd7d6578). (DissimilarityListcxx . . $ DissimilarityList# dissims, Configurationcxx . . $ Configuration# conf, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out1, autoSaliencecxx . . $ autoSalience# *out2) { |
| 2106 | try { |
| 2107 | autoDistanceListcxx . . $ autoDistanceList# distances = DissimilarityList_Configuration_monotoneRegressioncxx . . $ DissimilarityList_Configuration_monotoneRegression(ae8bd1dfb1080b7f). (dissims, conf, tiesHandling); |
| 2108 | autoSaliencecxx . . $ autoSalience# weights = DistanceList_Configuration_to_Saliencecxx . . $ DistanceList_Configuration_to_Salience(ca35ffb2c4126684). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), conf, normalizeScalarProducts); |
| 2109 | double vaf; |
| 2110 | DissimilarityList_Configuration_Salience_indscalcxx . . $ DissimilarityList_Configuration_Salience_indscal(2c8f220638c77694). (dissims, conf, weights.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling, normalizeScalarProducts, tolerance, numberOfIterations, showProgress, out1, out2, & vaf); |
| 2111 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2112 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No indscal performed."); |
| 2113 | } |
| 2114 | } |
| 2115 | |
| 2116 | void DissimilarityList_indscalcxx . . $ DissimilarityList_indscal(71f38e09e21b07b2). (DissimilarityListcxx . . $ DissimilarityList# me, integercxx . . $ integer# numberOfDimensions, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out_conf, autoSaliencecxx . . $ autoSalience# *out_sal) { |
| 2117 | bool showMulti = showProgress && numberOfRepetitions > 1; |
| 2118 | try { |
| 2119 | const bool showSingle = (showProgress && numberOfRepetitions == 1); |
| 2120 | |
| 2121 | autoDistanceListcxx . . $ autoDistanceList# distances = DissimilarityList_to_DistanceListcxx . . $ DissimilarityList_to_DistanceList(86647294691f1178). (me, kMDS_AnalysisScale::ORDINAL); |
| 2122 | autoConfigurationcxx . . $ autoConfiguration# cstartcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; autoSaliencecxx . . $ autoSalience# wstartcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2123 | DistanceList_to_Configuration_ytlcxx . . $ DistanceList_to_Configuration_ytl(48811c2fdfd82138). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfDimensions, normalizeScalarProducts, & cstart, & wstart); |
| 2124 | autoConfigurationcxx . . $ autoConfiguration# conf = Data_copycxx . . $ Data_copy(97a542a26794c80e). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2125 | autoSaliencecxx . . $ autoSalience# sal = Data_copycxx . . $ Data_copy(97a542a26794c80e). (wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2126 | |
| 2127 | if (showMulti) |
| 2128 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"Indscal many times"); |
| 2129 | |
| 2130 | double vaf, vafmin = 0.0; |
| 2131 | for (integercxx . . $ integer# iter = 1; iter <= numberOfRepetitions; iter ++) { |
| 2132 | autoConfigurationcxx . . $ autoConfiguration# cresultcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2133 | autoSaliencecxx . . $ autoSalience# wresultcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2134 | DissimilarityList_Configuration_Salience_indscalcxx . . $ DissimilarityList_Configuration_Salience_indscal(2c8f220638c77694). (me, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling, |
| 2135 | normalizeScalarProducts, tolerance, numberOfIterations, showSingle, & cresult, & wresult, & vaf); |
| 2136 | if (vaf > vafmin) { |
| 2137 | vafmin = vaf; |
| 2138 | conf =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). cresult.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2139 | sal =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). wresult.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2140 | } |
| 2141 | Configuration_randomizecxx . . $ Configuration_randomize(4cfce9233baadf27). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2142 | Configuration_normalizecxx . . $ Configuration_normalize(d5cde0c5e772706a). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0, true); |
| 2143 | Salience_setDefaultscxx . . $ Salience_setDefaults(1120f0269e41a951). (wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2144 | |
| 2145 | if (showMulti) |
| 2146 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). ( (double) iter / (numberOfRepetitions + 1), iter, U" from ", numberOfRepetitions); |
| 2147 | } |
| 2148 | |
| 2149 | if (out_conf) |
| 2150 | *out_conf =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). conf.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2151 | if (out_sal) |
| 2152 | *out_sal =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). sal.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2153 | if (showMulti) |
| 2154 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2155 | |
| 2156 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2157 | if (showMulti) { |
| 2158 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2159 | } |
| 2160 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no indscal performed."); |
| 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | void DistanceList_to_Configuration_indscalcxx . . $ DistanceList_to_Configuration_indscal(da4671b3a7d680f4). (DistanceListcxx . . $ DistanceList# distances, integercxx . . $ integer# numberOfDimensions, bool normalizeScalarProducts, double tolerance, integercxx . . $ integer# numberOfIterations, integercxx . . $ integer# numberOfRepetitions, bool showProgress, autoConfigurationcxx . . $ autoConfiguration# *out_conf, autoSaliencecxx . . $ autoSalience# *out_sal) { |
| 2165 | bool showMulti = showProgress && numberOfRepetitions > 1; |
| 2166 | try { |
| 2167 | const bool showSingle = (showProgress && numberOfRepetitions == 1); |
| 2168 | autoConfigurationcxx . . $ autoConfiguration# cstartcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2169 | autoSaliencecxx . . $ autoSalience# wstartcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2170 | DistanceList_to_Configuration_ytlcxx . . $ DistanceList_to_Configuration_ytl(48811c2fdfd82138). (distances, numberOfDimensions, normalizeScalarProducts, & cstart, & wstart); |
| 2171 | autoConfigurationcxx . . $ autoConfiguration# conf = Data_copycxx . . $ Data_copy(97a542a26794c80e). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2172 | autoSaliencecxx . . $ autoSalience# sal = Data_copycxx . . $ Data_copy(97a542a26794c80e). (wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2173 | |
| 2174 | if (showMulti) |
| 2175 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). (0.0, U"Indscal many times"); |
| 2176 | |
| 2177 | double vaf, vafmin = 0.0; |
| 2178 | for (integercxx . . $ integer# i = 1; i <= numberOfRepetitions; i ++) { |
| 2179 | autoConfigurationcxx . . $ autoConfiguration# cresultcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2180 | autoSaliencecxx . . $ autoSalience# wresultcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 2181 | DistanceList_Configuration_Salience_indscalcxx . . $ DistanceList_Configuration_Salience_indscal(fedfad592847cd3). (distances, cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), normalizeScalarProducts, tolerance, numberOfIterations, showSingle, & cresult, & wresult, & vaf); |
| 2182 | if (vaf > vafmin) { |
| 2183 | vafmin = vaf; |
| 2184 | conf =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). cresult.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2185 | sal =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). wresult.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2186 | } |
| 2187 | Configuration_randomizecxx . . $ Configuration_randomize(4cfce9233baadf27). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2188 | Configuration_normalizecxx . . $ Configuration_normalize(d5cde0c5e772706a). (cstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1.0, true); |
| 2189 | Salience_setDefaultscxx . . $ Salience_setDefaults(1120f0269e41a951). (wstart.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2190 | |
| 2191 | if (showMulti) |
| 2192 | Melder_progresscxx . . $ Melder_progress(3af686d0d3721642). ((double) i / (numberOfRepetitions + 1), i, U" from ", numberOfRepetitions); |
| 2193 | } |
| 2194 | |
| 2195 | if (out_conf) |
| 2196 | *out_conf =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). conf.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2197 | if (out_sal) |
| 2198 | *out_sal =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). sal.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 2199 | if (showMulti) |
| 2200 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2201 | |
| 2202 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2203 | if (showMulti) |
| 2204 | Melder_progresscxx . . $ Melder_progress(ba8836b59fb42830). (1.0); |
| 2205 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (distances, U": no indscal performed."); |
| 2206 | } |
| 2207 | } |
| 2208 | |
| 2209 | void DissimilarityList_Configuration_Salience_vafcxx . . $ DissimilarityList_Configuration_Salience_vaf(79eacdb4638be6e5). (DissimilarityListcxx . . $ DissimilarityList# me, Configurationcxx . . $ Configuration# thee, Saliencecxx . . $ Salience# him, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts, double *out_varianceAccountedFor) { |
| 2210 | autoDistanceListcxx . . $ autoDistanceList# distances = DissimilarityList_Configuration_monotoneRegressioncxx . . $ DissimilarityList_Configuration_monotoneRegression(ae8bd1dfb1080b7f). (me, thee, tiesHandling); |
| 2211 | DistanceList_Configuration_Salience_vafcxx . . $ DistanceList_Configuration_Salience_vaf(1d9b38452e9b0f2d). (distances.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thee, him, normalizeScalarProducts, out_varianceAccountedFor); |
| 2212 | } |
| 2213 | |
| 2214 | void DistanceList_Configuration_vafcxx . . $ DistanceList_Configuration_vaf(d5e8c78a65837f8c). (DistanceListcxx . . $ DistanceList# me, Configurationcxx . . $ Configuration# thee, bool normalizeScalarProducts, double *out_varianceAccountedFor) { |
| 2215 | autoSaliencecxx . . $ autoSalience# w = DistanceList_Configuration_to_Saliencecxx . . $ DistanceList_Configuration_to_Salience(ca35ffb2c4126684). (me, thee, normalizeScalarProducts); |
| 2216 | DistanceList_Configuration_Salience_vafcxx . . $ DistanceList_Configuration_Salience_vaf(1d9b38452e9b0f2d). (me, thee, w.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), normalizeScalarProducts, out_varianceAccountedFor); |
| 2217 | } |
| 2218 | |
| 2219 | void DissimilarityList_Configuration_vafcxx . . $ DissimilarityList_Configuration_vaf(beb1d603b55e824f). (DissimilarityListcxx . . $ DissimilarityList# me, Configurationcxx . . $ Configuration# thee, kMDS_TiesHandling tiesHandling, bool normalizeScalarProducts, double *out_varianceAccountedFor) { |
| 2220 | autoSaliencecxx . . $ autoSalience# w = DissimilarityList_Configuration_to_Saliencecxx . . $ DissimilarityList_Configuration_to_Salience(6d428a9bdf879c21). (me, thee, tiesHandling, normalizeScalarProducts); |
| 2221 | DissimilarityList_Configuration_Salience_vafcxx . . $ DissimilarityList_Configuration_Salience_vaf(79eacdb4638be6e5). (me, thee, w.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tiesHandling, normalizeScalarProducts, out_varianceAccountedFor); |
| 2222 | } |
| 2223 | |
| 2224 | void DistanceList_Configuration_Salience_vafcxx . . $ DistanceList_Configuration_Salience_vaf(1d9b38452e9b0f2d). (DistanceListcxx . . $ DistanceList# me, Configurationcxx . . $ Configuration# thee, Saliencecxx . . $ Salience# him, bool normalizeScalarProducts, double *out_varianceAccountedFor) { |
| 2225 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! size == hiscxx . . $ `melder/melder.h:47:9`! numberOfRows && thycxx . . $ `melder/melder.h:45:9`! numberOfColumns == hiscxx . . $ `melder/melder.h:47:9`! numberOfColumns, |
| 2226 | U"Dimensions should agree."); |
| 2227 | autoScalarProductListcxx . . $ autoScalarProductList# sp = DistanceList_to_ScalarProductListcxx . . $ DistanceList_to_ScalarProductList(b7b2a3be4b7817ca). (me, normalizeScalarProducts); |
| 2228 | ScalarProductList_Configuration_Salience_vafcxx . . $ ScalarProductList_Configuration_Salience_vaf(e6c124e8055a2d38). (sp.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thee, him, out_varianceAccountedFor); |
| 2229 | } |
| 2230 | |
| 2231 | void ScalarProduct_Configuration_getVariancescxx . . $ ScalarProduct_Configuration_getVariances(961a9f6118eb3069). (ScalarProductcxx . . $ ScalarProduct# me, Configurationcxx . . $ Configuration# thee, double *out_varianceExplained, double *out_varianceTotal) { |
| 2232 | autoDistancecxx . . $ autoDistance# distance = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (thee); |
| 2233 | autoScalarProductcxx . . $ autoScalarProduct# fit = Distance_to_ScalarProductcxx . . $ Distance_to_ScalarProduct(af226fe7231506a). (distance.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0); |
| 2234 | /* |
| 2235 | ScalarProduct is double centred, i.e., mean == 0. |
| 2236 | */ |
| 2237 | double varianceExplained = 0.0, varianceTotal = 0.0; |
| 2238 | for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; j ++) { |
| 2239 | for (integercxx . . $ integer# k = 1; k <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; k ++) { |
| 2240 | const double d2 = mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] - fit ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 2241 | varianceExplained += d2 * d2; |
| 2242 | varianceTotal += mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k] * mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).k]; |
| 2243 | } |
| 2244 | } |
| 2245 | |
| 2246 | if (out_varianceExplained) |
| 2247 | *out_varianceExplained = varianceExplained; |
| 2248 | if (out_varianceTotal) |
| 2249 | *out_varianceTotal = varianceTotal; |
| 2250 | |
| 2251 | } |
| 2252 | |
| 2253 | void ScalarProductList_Configuration_Salience_vafcxx . . $ ScalarProductList_Configuration_Salience_vaf(e6c124e8055a2d38). (ScalarProductListcxx . . $ ScalarProductList# me, Configurationcxx . . $ Configuration# thee, Saliencecxx . . $ Salience# him, double *out_varianceAccountedFor) { |
| 2254 | autoVECcxx . . $ autoVEC# w = copy_VECcxx . . $ copy_VEC(d4415e68b25283a8). (thycxx . . $ `melder/melder.h:45:9`! wcxx . . $ structConfiguration#w..getcxx . . $ autovector#get(e8d1da7fe68a6585).()); // save weights |
| 2255 | try { |
| 2256 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! size == hiscxx . . $ `melder/melder.h:47:9`! numberOfRows && thycxx . . $ `melder/melder.h:45:9`! numberOfColumns == hiscxx . . $ `melder/melder.h:47:9`! numberOfColumns, |
| 2257 | U"Dimensions should agree."); |
| 2258 | |
| 2259 | double t = 0.0, n = 0.0; |
| 2260 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.; i ++) { |
| 2261 | const ScalarProductcxx . . $ ScalarProduct# sp = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 2262 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (sp -> numberOfRows == thycxx . . $ `melder/melder.h:45:9`! numberOfRows, |
| 2263 | U"Dimension of ScalarProduct ", i, U" should match Configuration."); |
| 2264 | /* |
| 2265 | Weigh configuration before calculating variances |
| 2266 | */ |
| 2267 | for (integercxx . . $ integer# j = 1; j <= thycxx . . $ `melder/melder.h:45:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; j ++) |
| 2268 | thycxx . . $ `melder/melder.h:45:9`! wcxx . . $ structConfiguration#w. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j] = sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j]); |
| 2269 | |
| 2270 | double vare, vart; |
| 2271 | ScalarProduct_Configuration_getVariancescxx . . $ ScalarProduct_Configuration_getVariances(961a9f6118eb3069). (sp, thee, & vare, & vart); |
| 2272 | |
| 2273 | t += vare; |
| 2274 | n += vart; |
| 2275 | } |
| 2276 | |
| 2277 | if (out_varianceAccountedFor) |
| 2278 | *out_varianceAccountedFor = ( n > 0.0 ? 1.0 - t / n : 0.0 ); |
| 2279 | thycxx . . $ `melder/melder.h:45:9`! wcxx . . $ structConfiguration#w..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). wcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(); // restore weights |
| 2280 | |
| 2281 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2282 | thycxx . . $ `melder/melder.h:45:9`! wcxx . . $ structConfiguration#w..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). wcxx . . $ constvectorview#constvectorview(5c6f246bf1d99401)..allcxx . . $ autovector#all(a26726dad87555bb).(); |
| 2283 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No out_varianceAccountedFor calculated."); |
| 2284 | } |
| 2285 | } |
| 2286 | |
| 2287 | /********************** Examples *********************************************/ |
| 2288 | |
| 2289 | autoSaliencecxx . . $ autoSalience# Salience_createCarrollWishExamplecxx . . $ Salience_createCarrollWishExample(9ef949508dad2dfa). () { |
| 2290 | try { |
| 2291 | integercxx . . $ integer# numberOfSources = 8; |
| 2292 | constexpr double wx [9] = {0, 1.0, 0.866, 0.707, 0.5, 0.1, 0.5, 0.354, 0.1}; |
| 2293 | constexpr double wy [9] = {0, 0.1, 0.5, 0.707, 0.866, 1, 0.1, 0.354, 0.5}; |
| 2294 | constexpr conststring32cxx . . $ conststring32# name [] = { U"", U"1", U"2", U"3", U"4", U"5", U"6", U"7", U"8"}; |
| 2295 | autoSaliencecxx . . $ autoSalience# me = Salience_createcxx . . $ Salience_create(c072d15a45b2e699). (numberOfSources, 2); |
| 2296 | |
| 2297 | for (integercxx . . $ integer# i = 1; i <= numberOfSources; i ++) { |
| 2298 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = wx [i]; |
| 2299 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = wy [i]; |
| 2300 | TableOfReal_setRowLabelcxx . . $ TableOfReal_setRowLabel(7bba53c4f5b398fa). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), i, name [i]); |
| 2301 | } |
| 2302 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2303 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2304 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Salience for Carroll Wish example not created."); |
| 2305 | } |
| 2306 | } |
| 2307 | |
| 2308 | autoCollectioncxx . . $ autoCollection# INDSCAL_createCarrollWishExamplecxx . . $ INDSCAL_createCarrollWishExample(23c753eefaa01494). (double noiseRange) { |
| 2309 | try { |
| 2310 | autoConfigurationcxx . . $ autoConfiguration# c = Configuration_createCarrollWishExamplecxx . . $ Configuration_createCarrollWishExample(c895aeeeb43362cf). (); |
| 2311 | const integercxx . . $ integer# numberOfObjects = c ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numberOfRowscxx . . $ structTableOfReal#numberOfRows., numberOfSources = 8; |
| 2312 | autoSaliencecxx . . $ autoSalience# s = Salience_createCarrollWishExamplecxx . . $ Salience_createCarrollWishExample(9ef949508dad2dfa). (); |
| 2313 | autoCollectioncxx . . $ autoCollection# me = Collection_createcxx . . $ Collection_create(859008c51157a0cd). (); |
| 2314 | for (integercxx . . $ integer# l = 1; l <= numberOfSources; l ++) { |
| 2315 | c ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). wcxx . . $ structConfiguration#w. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = s ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1]; |
| 2316 | c ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). wcxx . . $ structConfiguration#w. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).2] = s ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).l] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2]; |
| 2317 | autoDistancecxx . . $ autoDistance# d = Configuration_to_Distancecxx . . $ Configuration_to_Distance(eb9925fa1662ef19). (c.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2318 | autoDissimilaritycxx . . $ autoDissimilarity# dissim = Distance_to_Dissimilaritycxx . . $ Distance_to_Dissimilarity(3ef1c2fefce3b7fd). (d.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 2319 | for (integercxx . . $ integer# i = 1; i <= numberOfObjects - 1; i ++) { |
| 2320 | for (integercxx . . $ integer# j = i + 1; j <= numberOfObjects; j ++) |
| 2321 | dissim ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).i] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).j] = (dissim ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).j] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i] += NUMrandomUniformcxx . . $ NUMrandomUniform(d8e7e0733fa41c87). (0.0, noiseRange)); |
| 2322 | } |
| 2323 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (dissim.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), s ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).l].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 2324 | mycxx . . $ `melder/melder.h:44:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (dissimcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).()); |
| 2325 | } |
| 2326 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"CarrollWish"); |
| 2327 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 2328 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 2329 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Collection not created."); |
| 2330 | } |
| 2331 | } |
| 2332 | |
| 2333 | void drawSplinescxx . . $ drawSplines(60b9e15fc9bbba09). (Graphicscxx . . $ Graphics# g, double low, double high, double ymin, double ymax, |
| 2334 | kMDS_splineType splineType, integercxx . . $ integer# order, conststring32cxx . . $ conststring32# interiorKnots, bool garnish) |
| 2335 | { |
| 2336 | constexpr integercxx . . $ integer# maximumNumberOfKnots = 100; |
| 2337 | integercxx . . $ integer# k = order; |
| 2338 | double knot [maximumNumberOfKnots + 1]; |
| 2339 | if (k > maximumNumberOfKnots) |
| 2340 | return; |
| 2341 | if (splineType == kMDS_splineType::I_SPLINE) |
| 2342 | k ++; |
| 2343 | for (integercxx . . $ integer# i = 1; i <= k; i ++) |
| 2344 | knot [i] = low; |
| 2345 | integercxx . . $ integer# numberOfKnots = k; |
| 2346 | |
| 2347 | { // scope |
| 2348 | conststring8cxx . . $ conststring8# start = Melder_peek32to8 (interiorKnots); // UGLY; because of non-availability of str32tod |
| 2349 | mutablestring8cxx . . $ mutablestring8# end; // this is not actually mutated, but strtod's signature requires this |
| 2350 | while (*start) { |
| 2351 | const double value = strtodcxx . . $ strtod(d6476bb9e2fdf17c). (start, & end); |
| 2352 | start = end; |
| 2353 | if (value < low || value > high) { |
| 2354 | Melder_warningcxx . . $ Melder_warning(6298c93241566110). (U"drawSplines: knots should be in interval (", low, U", ", high, U")"); |
| 2355 | return; |
| 2356 | } |
| 2357 | if (numberOfKnots == maximumNumberOfKnots) { |
| 2358 | Melder_warningcxx . . $ Melder_warning(6298c93241566110). (U"drawSplines: too many knots (", maximumNumberOfKnots + 1, U")"); |
| 2359 | return; |
| 2360 | } |
| 2361 | knot [++ numberOfKnots] = value; |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | const integercxx . . $ integer# numberOfInteriorKnots = numberOfKnots - k; |
| 2366 | for (integercxx . . $ integer# i = 1; i <= k; i ++) { |
| 2367 | if (numberOfKnots == maximumNumberOfKnots) { |
| 2368 | Melder_warningcxx . . $ Melder_warning(6298c93241566110). (U"drawSplines: too many knots (", maximumNumberOfKnots + 1, U")"); |
| 2369 | return; |
| 2370 | } |
| 2371 | knot [++numberOfKnots] = high; |
| 2372 | } |
| 2373 | |
| 2374 | const integercxx . . $ integer# nSplines = order + numberOfInteriorKnots; |
| 2375 | if (nSplines == 0) |
| 2376 | return; |
| 2377 | |
| 2378 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, low, high, ymin, ymax); |
| 2379 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g); |
| 2380 | constexpr integercxx . . $ integer# numberOfPoints = 1000; |
| 2381 | autoVECcxx . . $ autoVEC# y = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfPoints); |
| 2382 | const double dx = (high - low) / (numberOfPoints - 1); |
| 2383 | for (integercxx . . $ integer# i = 1; i <= nSplines; i ++) { |
| 2384 | for (integercxx . . $ integer# j = 1; j <= numberOfPoints; j ++) { |
| 2385 | const double x = low + dx * (j - 1); |
| 2386 | double yx; |
| 2387 | if (splineType == kMDS_splineType::M_SPLINE) |
| 2388 | yx = NUMmsplinecxx . . $ NUMmspline(55addd8cdfddff3d). (constVECcxx . . $ constvector#constvector(be07d762837ca876). (& knot [1], numberOfKnots), order, i, x); |
| 2389 | else |
| 2390 | yx = NUMisplinecxx . . $ NUMispline(55addd8cdfddff3d). (constVECcxx . . $ constvector#constvector(be07d762837ca876). (& knot [1], numberOfKnots), order, i, x); |
| 2391 | y [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j] = ( yx < ymin ? ymin : ( yx > ymax ? ymax : yx ) ); |
| 2392 | } |
| 2393 | Graphics_functioncxx . . $ Graphics_function(1c6279e2c8b8beb1). (g, y.asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).(), 1, numberOfPoints, low, high); |
| 2394 | } |
| 2395 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g); |
| 2396 | if (garnish) { |
| 2397 | static MelderStringcxx . . $ MelderString# ts; |
| 2398 | const integercxx . . $ integer# lastKnot = ( splineType == kMDS_splineType::I_SPLINE ? numberOfKnots - 2 : numberOfKnots ); |
| 2399 | Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g); |
| 2400 | Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, false, ( splineType == kMDS_splineType::M_SPLINE ? U"\\s{M}\\--spline" : U"\\s{I}\\--spline" )); |
| 2401 | Graphics_marksTopcxx . . $ Graphics_marksTop(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 2402 | Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false); |
| 2403 | if (low <= knot [order]) { |
| 2404 | if (order == 1) |
| 2405 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"t__1_"); |
| 2406 | else if (order == 2) |
| 2407 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"{t__1_, t__2_}"); |
| 2408 | else |
| 2409 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"{t__1_..t__", order, U"_}"); |
| 2410 | Graphics_markBottomcxx . . $ Graphics_markBottom(e82cc8dc402e8bd7). (g, low, false, false, false, ts.stringcxx . . $ MelderString#string.); |
| 2411 | } |
| 2412 | for (integercxx . . $ integer# i = 1; i <= numberOfInteriorKnots; i ++) { |
| 2413 | if (low <= knot [k + i] && knot [k + i] < high) { |
| 2414 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"t__", order + i, U"_"); |
| 2415 | Graphics_markBottomcxx . . $ Graphics_markBottom(e82cc8dc402e8bd7). (g, knot [k + i], false, true, true, ts.stringcxx . . $ MelderString#string.); |
| 2416 | Graphics_markTopcxx . . $ Graphics_markTop(e82cc8dc402e8bd7). (g, knot [k + i], true, false, false, nullptr); |
| 2417 | } |
| 2418 | } |
| 2419 | if (knot [lastKnot - order + 1] <= high) { |
| 2420 | if (order == 1) |
| 2421 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"t__", lastKnot, U"_"); |
| 2422 | else |
| 2423 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& ts, U"{t__", ( order == 2 ? lastKnot - 1 : lastKnot - order + 1 ), U"_, t__", lastKnot, U"_}"); |
| 2424 | Graphics_markBottomcxx . . $ Graphics_markBottom(e82cc8dc402e8bd7). (g, high, false, false, false, ts.stringcxx . . $ MelderString#string.); |
| 2425 | } |
| 2426 | } |
| 2427 | } |
| 2428 | |
| 2429 | void drawMDSClassRelationscxx . . $ drawMDSClassRelations(2d838ed765120c5d). (Graphicscxx . . $ Graphics# g) { |
| 2430 | const integercxx . . $ integer# nBoxes = 6; |
| 2431 | const double boxWidth = 0.3, boxWidth2 = boxWidth / 2.0, boxWidth3 = boxWidth / 3.0; |
| 2432 | const double boxHeight = 0.1, boxHeight2 = boxHeight / 2.0; |
| 2433 | const double boxHeight3 = boxHeight / 3.0; |
| 2434 | const double r_mm = 3, dxt = 0.025, dyt = 0.03; |
| 2435 | const double dboxx = 1.0 - 0.2 - 2.0 * boxWidth, dboxy = (1.0 - 4.0 * boxHeight) / 3.0; |
| 2436 | double x1, x2, xm, x23, x13, y1, y2, ym, y23, y13; |
| 2437 | const double x [7] = {0.0, 0.2, 0.2, 0.7, 0.2, 0.7, 0.2}; /* left */ |
| 2438 | const double y [7] = {0.0, 0.9, 0.6, 0.6, 0.3, 0.3, 0.0}; /* bottom */ |
| 2439 | const conststring32cxx . . $ conststring32# text [7] = {U"", U"Confusion", U"Dissimilarity %\\de__%%ij%_", U"Similarity", U"Distance %d__%%ij%_, %d\\'p__%%ij%_", U"ScalarProduct", U"Configuration" }; |
| 2440 | |
| 2441 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, -0.05, 1.05, -0.05, 1.05); |
| 2442 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 2443 | for (integercxx . . $ integer# i = 1; i <= nBoxes; i ++) { |
| 2444 | x2 = x [i] + boxWidth; |
| 2445 | y2 = y [i] + boxHeight; |
| 2446 | xm = x [i] + boxWidth2; |
| 2447 | ym = y [i] + boxHeight2; |
| 2448 | Graphics_roundedRectanglecxx . . $ Graphics_roundedRectangle(9d9e8b5bd1d9d21f). (g, x [i], x2, y [i], y2, r_mm); |
| 2449 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, xm, ym, text [i]); |
| 2450 | } |
| 2451 | |
| 2452 | Graphics_setLineWidthcxx . . $ Graphics_setLineWidth(2514a1c07b6be5e2). (g, 2); |
| 2453 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 2454 | |
| 2455 | // Confusion to Dissimilarity |
| 2456 | |
| 2457 | xm = x [1] + boxWidth2; |
| 2458 | y2 = y [2] + boxHeight; |
| 2459 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, xm, y [1], xm, y2); |
| 2460 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, xm + dxt, y2 + dboxy / 2, U"pdf"); |
| 2461 | |
| 2462 | // Confusion to Similarity |
| 2463 | |
| 2464 | x1 = x [1] + boxWidth; |
| 2465 | xm = x [3] + boxWidth2; |
| 2466 | ym = y [1] + boxHeight2; |
| 2467 | y2 = y [3] + boxHeight; |
| 2468 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, x1, ym, xm, ym); |
| 2469 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, xm, ym, xm, y2); |
| 2470 | y2 += + dboxy / 2 + dyt / 2; |
| 2471 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, xm + dxt, y2, U"average"); |
| 2472 | y2 -= dyt; |
| 2473 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, xm + dxt, y2, U"houtgast"); |
| 2474 | |
| 2475 | // Dissimilarity to Similarity |
| 2476 | |
| 2477 | x1 = x [2] + boxWidth; |
| 2478 | y23 = y [2] + 2 * boxHeight3; |
| 2479 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x1, y23, x [3], y23); |
| 2480 | y13 = y [2] + boxHeight3; |
| 2481 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x [3], y13, x1, y13); |
| 2482 | |
| 2483 | // Dissimilarity to Distance |
| 2484 | |
| 2485 | x13 = x [4] + boxWidth3; |
| 2486 | y1 = y [4] + boxHeight; |
| 2487 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x13, y1, x13, y [2]); |
| 2488 | x23 = x [4] + 2 * boxWidth3; |
| 2489 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x23, y [2], x23, y1); |
| 2490 | |
| 2491 | x1 = x23 + dxt; |
| 2492 | y1 = y [2] - dyt; |
| 2493 | x2 = 0 + dxt; |
| 2494 | y1 -= dyt; |
| 2495 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"%d\\'p__%%ij%_ = %\\de__%%ij%_"); |
| 2496 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x2, y1, U"absolute"); |
| 2497 | y1 -= dyt; |
| 2498 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"%d\\'p__%%ij%_ = %b\\.c%\\de__%%ij%_"); |
| 2499 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x2, y1, U"ratio"); |
| 2500 | y1 -= dyt; |
| 2501 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"%d\\'p__%%ij%_ = %b\\.c%\\de__%%ij%_+%a"); |
| 2502 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x2, y1, U"interval"); |
| 2503 | y1 -= dyt; |
| 2504 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"%d\\'p__%%ij%_ = \\s{I}-spline (%\\de__%%ij%_)"); |
| 2505 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x2, y1, U"\\s{I}\\--spline"); |
| 2506 | y1 -= dyt; |
| 2507 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"%d\\'p__%%ij%_ = monotone (%\\de__%%ij%_)"); |
| 2508 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x2, y1, U"monotone"); |
| 2509 | |
| 2510 | // Distance to ScalarProduct |
| 2511 | |
| 2512 | x1 = x [4] + boxWidth; |
| 2513 | ym = y [4] + boxHeight2; |
| 2514 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x1, ym, x [5], ym); |
| 2515 | |
| 2516 | // Distance to Configuration |
| 2517 | |
| 2518 | y1 = y [6] + boxHeight; |
| 2519 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x13, y1, x13, y [4]); |
| 2520 | |
| 2521 | // ScalarProduct to Configuration |
| 2522 | |
| 2523 | x13 = x [5] + boxWidth3; |
| 2524 | x23 = x [6] + 2 * boxWidth3; |
| 2525 | y1 = y [5] - dboxy / 2; |
| 2526 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, x13, y [5], x13, y1); |
| 2527 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, x13, y1, x23, y1); |
| 2528 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x23, y1, x23, y [6] + boxHeight); |
| 2529 | x1 = x [6] + boxWidth + dboxx / 2; |
| 2530 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 2531 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"\\s{TORSCA}"); |
| 2532 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`!); |
| 2533 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, y1, U"\\s{YTL}"); |
| 2534 | |
| 2535 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (g, Graphics_DOTTEDcxx . . $ `sys/Graphics.h:288:9`!); |
| 2536 | |
| 2537 | x23 = x [5] + 2 * boxWidth3; |
| 2538 | ym = y [6] + boxHeight2; |
| 2539 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, x23, y [5], x23, ym); |
| 2540 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, x23, ym, x [6] + boxWidth, ym); |
| 2541 | x1 = x [6] + boxWidth + dboxx / 2 + boxWidth3; |
| 2542 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 2543 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, x1, ym, U"\\s{INDSCAL}"); |
| 2544 | |
| 2545 | // Dissimilarity to Configuration |
| 2546 | |
| 2547 | ym = y [2] + boxHeight2; |
| 2548 | y2 = y [6] + boxHeight2; |
| 2549 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, x [2], ym, 0, ym); |
| 2550 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (g, 0, ym, 0, y2); |
| 2551 | Graphics_arrowcxx . . $ Graphics_arrow(72bdb7937dbb13da). (g, 0, y2, x [6], y2); |
| 2552 | |
| 2553 | // Restore settings |
| 2554 | |
| 2555 | Graphics_setLineTypecxx . . $ Graphics_setLineType(9abe41586e87648d). (g, Graphics_DRAWNcxx . . $ `sys/Graphics.h:287:9`!); |
| 2556 | Graphics_setLineWidthcxx . . $ Graphics_setLineWidth(2514a1c07b6be5e2). (g, 1.0); |
| 2557 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 2558 | } |
| 2559 | |
| 2560 | /* End of file MDS.cpp */ |