| 1 | #ifndef _Table_h_ |
| 2 | #define _Table_h_ |
| 3 | /* Table.h |
| 4 | * |
| 5 | * Copyright (C) 2002-2012,2014-2019,2021-2024 Paul Boersma |
| 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. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "Collection.h" |
| 22 | #include "Graphics.h" |
| 23 | Thing_declare (Interpreter); |
| 24 | |
| 25 | #include "Table_def.h" |
| 26 | |
| 27 | void Table_initWithColumnNames (Table me, integer numberOfRows, constSTRVEC columnNames); |
| 28 | autoTable Table_createWithColumnNames (integer numberOfRows, constSTRVEC columnNames); |
| 29 | void Table_initWithoutColumnNames (Table me, integer numberOfRows, integer numberOfColumns); |
| 30 | autoTable Table_createWithoutColumnNames (integer numberOfRows, integer numberOfColumns); |
| 31 | #define Table_create Table_createWithoutColumnNames |
| 32 | |
| 33 | void Table_checkSpecifiedColumnNumbersWithinRange (Table me, constINTVECVU const& columnNumbers); |
| 34 | |
| 35 | autoTable Tables_append (OrderedOf<structTable>* me); |
| 36 | void Table_appendRow (Table me); |
| 37 | void Table_appendColumn (Table me, conststring32 columnName); |
| 38 | void Table_appendSumColumn (Table me, integer column1, integer column2, conststring32 columnName); |
| 39 | void Table_appendDifferenceColumn (Table me, integer column1, integer column2, conststring32 columnName); |
| 40 | void Table_appendProductColumn (Table me, integer column1, integer column2, conststring32 columnName); |
| 41 | void Table_appendQuotientColumn (Table me, integer column1, integer column2, conststring32 columnName); |
| 42 | void Table_removeRow (Table me, integer rowNumber); |
| 43 | void Table_removeColumn (Table me, integer columnNumber); |
| 44 | void Table_insertRow (Table me, integer rowPosition); |
| 45 | void Table_insertColumn (Table me, integer columnPosition, conststring32 columnName /* cattable */); |
| 46 | void Table_renameColumn_e (Table me, integer columnNumber, conststring32 columnName /* cattable */); |
| 47 | integer Table_columnNameToNumber_0 (constTable me, conststring32 columnName) noexcept; |
| 48 | integer Table_columnNameToNumber_e (constTable me, conststring32 columnName); |
| 49 | autoINTVEC Table_columnNamesToNumbers (constTable me, constSTRVEC const& columnNames); |
| 50 | autoINTVEC Table_getColumnIndicesFromColumnLabelString (constTable me, conststring32 string); |
| 51 | integer Table_searchColumn (constTable me, integer column, conststring32 value) noexcept; |
| 52 | |
| 53 | /* |
| 54 | * Procedure for reading strings or numbers from table cells: |
| 55 | * use the following two calls exclusively. |
| 56 | */ |
| 57 | conststring32 Table_getStringValue_a (Table me, integer row, integer column); |
| 58 | double Table_getNumericValue_a (Table me, integer row, integer column); |
| 59 | |
| 60 | /* |
| 61 | * Procedure for writing strings or numbers into table cells: |
| 62 | * use the following two calls exclusively. |
| 63 | */ |
| 64 | void Table_setStringValue (Table me, integer rowNumber, integer columnNumber, conststring32 value /* cattable */); |
| 65 | void Table_setNumericValue (Table me, integer row, integer column, double value); |
| 66 | |
| 67 | /* For optimizations only (e.g. conversion to Matrix or TableOfReal). */ |
| 68 | void Table_numericize_a (Table me, integer columnNumber); |
| 69 | |
| 70 | autoVEC Table_getAllNumbersInColumn (Table me, integer columnNumber); |
| 71 | autoSTRVEC Table_getAllTextsInColumn (Table me, integer columnNumber); |
| 72 | |
| 73 | double Table_getQuantile (Table me, integer column, double quantile); |
| 74 | double Table_getSum (Table me, integer column); |
| 75 | double Table_getMean (Table me, integer column); |
| 76 | double Table_getMaximum (Table me, integer icol); |
| 77 | double Table_getMinimum (Table me, integer icol); |
| 78 | double Table_getGroupMean (Table me, integer column, integer groupColumn, conststring32 group); |
| 79 | double Table_getStdev (Table me, integer column); |
| 80 | integer Table_drawRowFromDistribution (Table me, integer column); |
| 81 | double Table_getCorrelation_pearsonR (Table me, integer column1, integer column2, double significanceLevel, |
| 82 | double *out_significance, double *out_lowerLimit, double *out_upperLimit); |
| 83 | double Table_getCorrelation_kendallTau (Table me, integer column1, integer column2, double significanceLevel, |
| 84 | double *out_significance, double *out_lowerLimit, double *out_upperLimit); |
| 85 | double Table_getMean_studentT (Table me, integer column, double significanceLevel, |
| 86 | double *out_tFromZero, double *out_numberOfDegreesOfFreedom, double *out_significanceFromZero, double *out_lowerLimit, double *out_upperLimit); |
| 87 | double Table_getDifference_studentT (Table me, integer column1, integer column2, double significanceLevel, |
| 88 | double *out_t, double *out_numberOfDegreesOfFreedom, double *out_significance, double *out_lowerLimit, double *out_upperLimit); |
| 89 | double Table_getGroupMean_studentT (Table me, integer column, integer groupColumn, conststring32 group1, double significanceLevel, |
| 90 | double *out_tFromZero, double *out_numberOfDegreesOfFreedom, double *out_significanceFromZero, double *out_lowerLimit, double *out_upperLimit); |
| 91 | double Table_getGroupDifference_studentT (Table me, integer column, integer groupColumn, conststring32 group1, conststring32 group2, double significanceLevel, |
| 92 | double *out_tFromZero, double *out_numberOfDegreesOfFreedom, double *out_significanceFromZero, double *out_lowerLimit, double *out_upperLimit); |
| 93 | double Table_getGroupDifference_wilcoxonRankSum (Table me, integer column, integer groupColumn, conststring32 group1, conststring32 group2, |
| 94 | double *out_rankSum, double *out_significanceFromZero); |
| 95 | double Table_getVarianceRatio (Table me, integer column1, integer column2, double significanceLevel, |
| 96 | double *out_significance, double *out_lowerLimit, double *out_upperLimit); |
| 97 | bool Table_getExtrema (Table me, integer icol, double *minimum, double *maximum); |
| 98 | |
| 99 | void Table_formula (Table me, integer column, conststring32 formula, Interpreter interpreter); |
| 100 | void Table_formula_columnRange (Table me, integer column1, integer column2, conststring32 expression, Interpreter interpreter); |
| 101 | |
| 102 | void Table_sortRows_a (Table me, constINTVECVU const& columns); |
| 103 | void Table_sortRows (Table me, constSTRVEC columns); |
| 104 | void Table_randomizeRows (Table me) noexcept; |
| 105 | void Table_reflectRows (Table me) noexcept; |
| 106 | |
| 107 | void Table_scatterPlot (Table me, Graphics g, integer xcolumn, integer ycolumn, |
| 108 | double xmin, double xmax, double ymin, double ymax, integer markColumn, double fontSize, bool garnish); |
| 109 | void Table_scatterPlot_mark (Table me, Graphics g, integer xcolumn, integer ycolumn, |
| 110 | double xmin, double xmax, double ymin, double ymax, double markSize_mm, conststring32 mark, bool garnish); |
| 111 | void Table_drawEllipse_e (Table me, Graphics g, integer xcolumn, integer ycolumn, |
| 112 | double xmin, double xmax, double ymin, double ymax, double numberOfSigmas, bool garnish); |
| 113 | |
| 114 | void Table_list (constTable me, bool includeRowNumbers); |
| 115 | void Table_writeToTabSeparatedFile (Table me, MelderFile file); |
| 116 | void Table_writeToCommaSeparatedFile (Table me, MelderFile file); |
| 117 | void Table_writeToSemicolonSeparatedFile (Table me, MelderFile file); |
| 118 | autoTable Table_readFromTableFile (MelderFile file); |
| 119 | autoTable Table_readFromCharacterSeparatedTextFile (MelderFile file, char32 separator, bool interpretQuotes); |
| 120 | |
| 121 | autoTable Table_extractRowsWhereColumn_number (Table me, integer column, kMelder_number which, double criterion); |
| 122 | autoTable Table_extractRowsWhereColumn_string (Table me, integer column, kMelder_string which, conststring32 criterion); |
| 123 | autoTable Table_collapseRows (Table me, constSTRVEC factors, constSTRVEC columnsToSum, |
| 124 | constSTRVEC columnsToAverage, constSTRVEC columnsToMedianize, |
| 125 | constSTRVEC columnsToAverageLogarithmically, constSTRVEC columnsToMedianizeLogarithmically); |
| 126 | autoTable Table_rowsToColumns (Table me, constSTRVEC const& factors_names, conststring32 columnToTranspose, constSTRVEC const& columnsToExpand_names); |
| 127 | autoTable Table_transpose (Table me); |
| 128 | |
| 129 | void Table_columns_checkExist (Table me, constSTRVEC columnNames); |
| 130 | void Table_checkSpecifiedRowNumberWithinRange (Table me, integer rowNumber); |
| 131 | void Table_checkSpecifiedColumnNumberWithinRange (Table me, integer columnNumber); |
| 132 | bool Table_isCellNumeric_ErrorFalse (Table me, integer rowNumber, integer columnNumber); |
| 133 | bool Table_isColumnNumeric_ErrorFalse (Table me, integer columnNumber); |
| 134 | |
| 135 | conststring32 Table_messageColumn (Table me, integer column); |
| 136 | |
| 137 | /* End of file Table.h */ |
| 138 | #endif |