/** * Returns the total of the values in one column of the supplied data * table. * * @param data the table of values (<code>null</code> not permitted). * @param column the column index (zero-based). * * @return The total of the values in the specified column. */ public static double calculateColumnTotal(Values2D data, int column) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int rowCount = data.getRowCount(); for (int r = 0; r < rowCount; r++) { Number n = data.getValue(r, column); if (n != null) { total += n.doubleValue(); } } return total; }
/** * Returns the total of the values in one row of the supplied data * table. * * @param data the table of values (<code>null</code> not permitted). * @param row the row index (zero-based). * * @return The total of the values in the specified row. */ public static double calculateRowTotal(Values2D data, int row) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { Number n = data.getValue(row, c); if (n != null) { total += n.doubleValue(); } } return total; }
/** * Returns the total of the values in one column of the supplied data * table by taking only the row numbers in the array into account. * * @param data the table of values (<code>null</code> not permitted). * @param column the column index (zero-based). * @param validRows the array with valid rows (zero-based). * * @return The total of the valid values in the specified column. * * @since 1.0.13 */ public static double calculateColumnTotal(Values2D data, int column, int[] validRows) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int rowCount = data.getRowCount(); for (int v = 0; v < validRows.length; v++) { int row = validRows[v]; if (row < rowCount) { Number n = data.getValue(row, column); if (n != null) { total += n.doubleValue(); } } } return total; }
/** * Returns the total of the values in one row of the supplied data * table by taking only the column numbers in the array into account. * * @param data the table of values (<code>null</code> not permitted). * @param row the row index (zero-based). * @param validCols the array with valid cols (zero-based). * * @return The total of the valid values in the specified row. * * @since 1.0.13 */ public static double calculateRowTotal(Values2D data, int row, int[] validCols) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int colCount = data.getColumnCount(); for (int v = 0; v < validCols.length; v++) { int col = validCols[v]; if (col < colCount) { Number n = data.getValue(row, col); if (n != null) { total += n.doubleValue(); } } } return total; }
/** * Returns the total of the values in one row of the supplied data * table. * * @param data the table of values ({@code null} not permitted). * @param row the row index (zero-based). * * @return The total of the values in the specified row. */ public static double calculateRowTotal(Values2D data, int row) { Args.nullNotPermitted(data, "data"); double total = 0.0; int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { Number n = data.getValue(row, c); if (n != null) { total += n.doubleValue(); } } return total; }
/** * Returns the total of the values in one column of the supplied data * table. * * @param data the table of values ({@code null} not permitted). * @param column the column index (zero-based). * * @return The total of the values in the specified column. */ public static double calculateColumnTotal(Values2D data, int column) { Args.nullNotPermitted(data, "data"); double total = 0.0; int rowCount = data.getRowCount(); for (int r = 0; r < rowCount; r++) { Number n = data.getValue(r, column); if (n != null) { total += n.doubleValue(); } } return total; }
/** * Returns the total of the values in one row of the supplied data * table by taking only the column numbers in the array into account. * * @param data the table of values ({@code null} not permitted). * @param row the row index (zero-based). * @param validCols the array with valid cols (zero-based). * * @return The total of the valid values in the specified row. * * @since 1.0.13 */ public static double calculateRowTotal(Values2D data, int row, int[] validCols) { Args.nullNotPermitted(data, "data"); double total = 0.0; int colCount = data.getColumnCount(); for (int v = 0; v < validCols.length; v++) { int col = validCols[v]; if (col < colCount) { Number n = data.getValue(row, col); if (n != null) { total += n.doubleValue(); } } } return total; }
/** * Returns the total of the values in one column of the supplied data * table by taking only the row numbers in the array into account. * * @param data the table of values ({@code null} not permitted). * @param column the column index (zero-based). * @param validRows the array with valid rows (zero-based). * * @return The total of the valid values in the specified column. * * @since 1.0.13 */ public static double calculateColumnTotal(Values2D data, int column, int[] validRows) { Args.nullNotPermitted(data, "data"); double total = 0.0; int rowCount = data.getRowCount(); for (int v = 0; v < validRows.length; v++) { int row = validRows[v]; if (row < rowCount) { Number n = data.getValue(row, column); if (n != null) { total += n.doubleValue(); } } } return total; }