Configuration Configuration_createLetterRExample (int choice) { double x1[33] = { 0, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -3, -2, -1, 0, 1, 2.25, 3, 3, 2.25, 1, 0, -1, -2, -3, -4, -1, 0, 1, 2, 3 }; double y1[33] = { 0, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3.5, 2, 1, -0.5, -1, -1, -1, -1, -1, -1, -2, -3, -4, -5, -6 }; double x2[33] = {0, 0.94756043346272423, 0.73504466902509913, 0.4528453515175927, 0.46311499024105723, 0.30345454816993439, 0.075184942115601547, -0.090010071904764719, -0.19630977381424003, -0.36341509807865086, -0.54216996409132612, -0.68704678013309872, -0.67370169194623086, -0.69336494336440502, -0.67809065144478664, -0.61382610572366281, -0.68656530656078996, -0.57704879646736551, -0.63417502349009069, -0.37153350651419026, -0.091809666009009777, 0.054833807442559397, 0.1445593164362155, 0.055587230806920782, 0.18201798315035453, 0.048445620192953162, 0.081595930742961439, 0.20063623749033621, 0.28546520751183313, 0.39384438699721991, 0.62832258520372286, 0.78548335015622228, 1.0610707888793069 }; double y2[33] = {0, 0.49630791172076621, 0.53320347382055022, 0.62384637225470441, 0.47592708487655661, 0.50364353255684202, 0.55311720162084443, 0.55118713773007066, 0.50007736370068601, 0.40432332354648709, 0.49817059660482677, 0.49803436631629411, 0.33213829258059019, 0.14585700576425648, -0.022110500334692869, -0.1752555003289698, -0.29448744336706828, -0.45639468287493545, -0.59177815505008013, -0.74980550818568981, -0.78095916436791279, -0.64447562732895125, -0.49526830813007033, -0.22443396573313243, -0.066378148077667398, -0.03498490725857361, 0.16196028200653381, 0.30633527000982519, -0.14894460651161745, -0.30808798640907431, -0.35920781945385832, -0.62766325578928184, -0.60389363590825562 }; try { double *x, *y; autoConfiguration me = Configuration_create (32, 2); if (choice == 2) { x = x2; y = y2; Thing_setName (me.peek(), U"R_fit"); } else { x = x1; y = y1; Thing_setName (me.peek(), U"R"); } for (long i = 1; i <= 32; i++) { char32 s[20]; Melder_sprint (s,20, i); TableOfReal_setRowLabel (me.peek(), i, s); my data [i][1] = x[i]; my data [i][2] = y[i]; } return me.transfer(); } catch (MelderError) { Melder_throw (U"Letter R Configuration not created."); } }
autoConfiguration TableOfReal_to_Configuration (TableOfReal me) { try { autoConfiguration thee = Configuration_create (my numberOfRows, my numberOfColumns); NUMmatrix_copyElements (my data, thy data, 1, my numberOfRows, 1, my numberOfColumns); TableOfReal_copyLabels (me, thee.peek(), 1, 1); return thee; } catch (MelderError) { Melder_throw (me, U": not converted."); } }
autoConfiguration Discriminant_and_TableOfReal_to_Configuration (Discriminant me, TableOfReal thee, long numberOfDimensions) { try { if (numberOfDimensions == 0) { numberOfDimensions = Discriminant_getNumberOfFunctions (me); } autoConfiguration him = Configuration_create (thy numberOfRows, numberOfDimensions); Eigen_and_TableOfReal_into_TableOfReal_projectRows (my eigen.get(), thee, 1, him.get(), 1, numberOfDimensions); TableOfReal_copyLabels (thee, him.get(), 1, 0); TableOfReal_setSequentialColumnLabels (him.get(), 0, 0, U"Eigenvector ", 1, 1); return him; } catch (MelderError) { Melder_throw (U"Configuration not created."); } }
autoConfiguration PCA_and_TableOfReal_to_Configuration (PCA me, TableOfReal thee, long numberOfDimensionsToKeep) { try { if (numberOfDimensionsToKeep == 0 || numberOfDimensionsToKeep > my numberOfEigenvalues) { numberOfDimensionsToKeep = my numberOfEigenvalues; } autoConfiguration him = Configuration_create (thy numberOfRows, numberOfDimensionsToKeep); Eigen_and_TableOfReal_into_TableOfReal_projectRows (me, thee, 1, him.get(), 1, numberOfDimensionsToKeep); NUMstrings_copyElements (thy rowLabels, his rowLabels, 1, thy numberOfRows); TableOfReal_setSequentialColumnLabels (him.get(), 0, 0, U"pc", 1, 1); return him; } catch (MelderError) { Melder_throw (U"Configuration not created from PCA & TableOfReal."); } }
autoTableOfReal PCA_to_TableOfReal_reconstruct1 (PCA me, char32 *numstring) { try { long npc; autoNUMvector<double> pc (NUMstring_to_numbers (numstring, & npc), 1); autoConfiguration c = Configuration_create (1, npc); for (long j = 1; j <= npc; j++) { c -> data [1][j] = pc[j]; } autoTableOfReal him = PCA_and_Configuration_to_TableOfReal_reconstruct (me, c.get()); return him; } catch (MelderError) { Melder_throw (me, U" not reconstructed."); } }
autoConfiguration Configuration_createCarrollWishExample () { double x[10] = {0.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0}; double y[10] = {0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0}; char32 const *label[] = { U"", U"A", U"B", U"C", U"D", U"E", U"F", U"G", U"H", U"I"}; try { long nObjects = 9; autoConfiguration me = Configuration_create (nObjects, 2); for (long i = 1; i <= nObjects; i++) { my data[i][1] = x[i]; my data[i][2] = y[i]; TableOfReal_setRowLabel (me.peek(), i, label[i]); } return me; } catch (MelderError) { Melder_throw (U"Carroll Wish Configuration not created."); } }
Configuration Configuration_createCarrollWishExample () { double x[10] = {0, -1, 0, 1, -1, 0, 1, -1, 0, 1}; double y[10] = {0, 1, 1, 1, 0, 0, 0, -1, -1, -1}; wchar_t const *label[] = { L"", L"A", L"B", L"C", L"D", L"E", L"F", L"G", L"H", L"I"}; try { long nObjects = 9; autoConfiguration me = Configuration_create (nObjects, 2); for (long i = 1; i <= nObjects; i++) { my data[i][1] = x[i]; my data[i][2] = y[i]; TableOfReal_setRowLabel (me.peek(), i, label[i]); } return me.transfer(); } catch (MelderError) { Melder_throw ("Carroll Wish Configuration not created."); } }