TableOfReal_extensions.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #ifndef _TableOfReal_extensions_h_
  2. #define _TableOfReal_extensions_h_
  3. /* TableOfReal_extensions.h
  4. *
  5. * Copyright (C) 1993-2018 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Categories.h"
  21. #include "Collection.h"
  22. #include "Graphics_extensions.h"
  23. #include "Matrix_extensions.h"
  24. #include "PatternList.h"
  25. #include "Strings_.h"
  26. #include "SSCP.h"
  27. #include "TableOfReal.h"
  28. void TableOfReal_to_PatternList_and_Categories(TableOfReal me, integer fromrow, integer torow, integer fromcol, integer tocol,
  29. autoPatternList *p, autoCategories *c);
  30. autoTableOfReal TableOfReal_transpose (TableOfReal me);
  31. autoStrings TableOfReal_extractRowLabels (TableOfReal me);
  32. autoStrings TableOfReal_extractColumnLabels (TableOfReal me);
  33. void TableOfReal_Categories_setRowLabels (TableOfReal me, Categories thee);
  34. // !!! Set rowlabels from categories because we need a Table-object with string-columns.
  35. autoTableOfReal TableOfReal_sortOnlyByRowLabels (TableOfReal me);
  36. autoINTVEC TableOfReal_getSortedIndexFromRowLabels (TableOfReal me);
  37. autoTableOfReal TableOfReal_sortRowsByIndex (TableOfReal me, constINTVEC index, bool reverse);
  38. // thy data[reverse ? i : index[i]][j] = my data[reverse ? index[i] : i]
  39. autoTableOfReal TableOfReal_createIrisDataset ();
  40. autoTableOfReal TableOfReal_create_pols1973 (bool include_levels);
  41. autoTableOfReal TableOfReal_create_vanNierop1973 (bool include_levels);
  42. autoTableOfReal TableOfReal_create_weenink1983 (int option); /* M W C */
  43. /* The data for Fig. 2 in Sandwell (1987) */
  44. autoTableOfReal TableOfReal_create_sandwell1987 ();
  45. void TableOfReal_getColumnExtrema (TableOfReal me, integer col, double *min, double *max);
  46. integer TableOfReal_getColumnIndexAtMaximumInRow (TableOfReal me, integer rowNumber);
  47. conststring32 TableOfReal_getColumnLabelAtMaximumInRow (TableOfReal me, integer rowNumber);
  48. void TableOfReal_drawRowsAsHistogram (TableOfReal me, Graphics g, conststring32 rows, integer colb, integer cole,
  49. double ymin, double ymax, double xoffsetFraction, double interbarFraction,
  50. double interbarsFraction, conststring32 greys, bool garnish);
  51. void TableOfReal_drawScatterPlot (TableOfReal me, Graphics g, integer icx, integer icy, integer rowb,
  52. integer rowe, double xmin, double xmax, double ymin, double ymax,
  53. int labelSize, bool useRowLabels, conststring32 label, bool garnish);
  54. void TableOfReal_drawAsScalableSquares (TableOfReal me, Graphics g, integer rowmin, integer rowmax, integer colmin, integer colmax, kGraphicsMatrixOrigin origin, double cellSizeFactor, kGraphicsMatrixCellDrawingOrder fillOrder, bool garnish);
  55. void TableOfReal_drawScatterPlotMatrix (TableOfReal me, Graphics g, integer colb, integer cole, double fractionWhite);
  56. void TableOfReal_drawBoxPlots (TableOfReal me, Graphics g, integer rowmin, integer rowmax, integer colmin, integer colmax,
  57. double ymin, double ymax, bool garnish);
  58. void TableOfReal_drawVectors (TableOfReal me, Graphics g, integer colx1, integer coly1,
  59. integer colx2, integer coly2, double xmin, double xmax,
  60. double ymin, double ymax, int vectype, int labelsize, bool garnish);
  61. void TableOfReal_drawBiplot (TableOfReal me, Graphics g, double xmin, double xmax,
  62. double ymin, double ymax, double sv_splitfactor, int labelsize,
  63. bool garnish);
  64. void TableOfReal_drawColumnAsDistribution (TableOfReal me, Graphics g, integer column, double minimum, double maximum, integer nBins,
  65. double freqMin, double freqMax, bool cumulative, bool garnish);
  66. integer TableOfReal_getNumberOfLabelMatches (TableOfReal me, conststring32 search, bool columnLabels,
  67. bool use_regexp);
  68. /*
  69. Find number of labels that match search description.
  70. */
  71. void TableOfReal_copyLabels (TableOfReal me, TableOfReal thee, int rowOrigin, int columnOrigin);
  72. /*
  73. rowOrigin == 1 copy from row
  74. rowOrigin == 0 do nothing
  75. rowOrigin == -1 copy from column
  76. columnOrigin == 1 copy from column
  77. columnOrigin == 0 do nothing
  78. columnOrigin == -1 copy from row
  79. */
  80. void TableOfReal_setLabelsFromCollectionItemNames (TableOfReal me, Collection thee, bool setRowLabels, bool setColumnLabels);
  81. void TableOfReal_setSequentialColumnLabels (TableOfReal me, integer from, integer to, conststring32 precursor, integer number, integer increment);
  82. void TableOfReal_setSequentialRowLabels (TableOfReal me, integer from, integer to, conststring32 precursor, integer number, integer increment);
  83. bool TableOfReal_hasRowLabels (TableOfReal me);
  84. bool TableOfReal_hasColumnLabels (TableOfReal me);
  85. void TableOfReal_changeRowLabels (TableOfReal me, conststring32 search, conststring32 replace,
  86. integer maximumNumberOfReplaces, integer *nmatches, integer *nstringmatches, bool use_regexp);
  87. void TableOfReal_changeColumnLabels (TableOfReal me, conststring32 search, conststring32 replace,
  88. integer maximumNumberOfReplaces, integer *nmatches, integer *nstringmatches, bool use_regexp);
  89. /*
  90. Change all row/column labels. The 'search' and 'replace' string are
  91. interpreted as regular expressions when 'use_regexp' != 0.
  92. 'maximumNumberOfReplaces' is the maximum number of replaces in EACH string
  93. in the array of strings (you can replace ALL occurrences by making this
  94. number <= 0)
  95. The totalnumber of matches found is returned in 'nmatches'.
  96. The number of strings with at least one match is returned in
  97. 'nstringmatches'.
  98. */
  99. void TableOfReal_centreColumns (TableOfReal me);
  100. void TableOfReal_centreColumns_byRowLabel (TableOfReal me);
  101. /* PRECONDITION: Table should be sorted by row labels !! */
  102. double TableOfReal_getColumnQuantile (TableOfReal me, integer col, double quantile);
  103. double TableOfReal_getRowSumByLabel (TableOfReal me, conststring32 label);
  104. double TableOfReal_getRowSum (TableOfReal me, integer index);
  105. double TableOfReal_getColumnSumByLabel (TableOfReal me, conststring32 label);
  106. double TableOfReal_getColumnSum (TableOfReal me, integer index);
  107. double TableOfReal_getGrandSum (TableOfReal me);
  108. void TableOfReal_centreRows (TableOfReal me);
  109. void TableOfReal_doubleCentre (TableOfReal me);
  110. bool TableOfReal_checkNonNegativity (TableOfReal me);
  111. double TableOfReal_getTableNorm (TableOfReal me);
  112. void TableOfReal_normalizeTable (TableOfReal me, double norm);
  113. void TableOfReal_normalizeColumns (TableOfReal me, double norm);
  114. void TableOfReal_normalizeRows (TableOfReal me, double norm);
  115. void TableOfReal_standardizeColumns (TableOfReal me);
  116. void TableOfReal_standardizeRows (TableOfReal me);
  117. autoTableOfReal TableOfReal_rankColumns (TableOfReal me);
  118. autoTableOfReal TableOfReal_meansByRowLabels (TableOfReal me, bool expand, bool useMedians);
  119. /*
  120. stats == 0? averages : medians
  121. For a table with n rows and m different labels (m <= n):
  122. if (expand=1) { output has n rows, substitute each array by the average value for that row label}
  123. else output a table with m rows, the averages for the m labels.
  124. */
  125. autoTableOfReal TableOfReal_bootstrap (TableOfReal me);
  126. // Produce new table with the same number of entries, but randomly selected with replacement.
  127. autoTableOfReal TableOfReal_randomizeRows (TableOfReal me);
  128. /* Produce new table with randomized rows */
  129. /* For the inheritors */
  130. autoTableOfReal TableOfReal_to_TableOfReal (TableOfReal me);
  131. autoTableOfReal TableOfReal_choleskyDecomposition (TableOfReal me, bool upper, bool inverse);
  132. autoTableOfReal TableOfReal_appendColumns (TableOfReal me, TableOfReal thee);
  133. void TableOfReal_copyOneRowWithLabel (TableOfReal me, TableOfReal thee, integer myrow, integer thyrow);
  134. /* Henze & Wagner (1997), A new approach to the BHEP tests for multivariate normality, Journal of Multivariate Analysis 62, 1-23. */
  135. double TableOfReal_normalityTest_BHEP (TableOfReal me, double *beta /* input and output */, double *tnb, double *lnmu, double *lnvar);
  136. autoTableOfReal TableOfReal_TableOfReal_crossCorrelations (TableOfReal me, TableOfReal thee, bool by_columns, bool center, bool normalize);
  137. #pragma mark - class TableOfRealList
  138. autoTableOfReal TableOfRealList_sum (TableOfRealList me);
  139. bool TableOfRealList_haveIdenticalDimensions (TableOfRealList me);
  140. autoTableOfReal TableOfRealList_appendColumnsMany (TableOfRealList me);
  141. autoMatrix TableOfReal_to_Matrix_interpolateOnRectangularGrid (TableOfReal me, double xmin, double xmax, double nx, double ymin, double ymax, integer ny, int /* method */);
  142. #endif /* _TableOfReal_extensions_h_ */