Package dev.nm.misc.datastructure
Class DimensionCheck
- java.lang.Object
-
- dev.nm.misc.datastructure.DimensionCheck
-
public class DimensionCheck extends Object
These are the utility functions for checking table dimension.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisArray(Table A)Check if a table is a row or a column.static booleanisColumn(Table A)Check if a table is a column.static booleanisFat(Table A)Check if a table is fat.static booleanisRow(Table A)Check if a table is a row.static booleanisSameDimension(Table A1, Table A2)Check if two tables have the same dimension.static booleanisSquare(Table A)Check if a table is square.static booleanisTall(Table A)Check if a table is tall.static voidthrowIfDifferentDimension(Table A1, Table A2)Throws ifA1.nRows() != A2.nRows()OrA1.nCols() != A2.nCols()static voidthrowIfIncompatible4Multiplication(Table A, Vector v)Throws ifA.nCols() != v.size()static voidthrowIfIncompatible4Multiplication(Table A1, Table A2)Throws ifA1.nCols() != A2.nRows()static voidthrowIfInvalidColumn(Table A, int j)Throws if accessing an out of range column.static voidthrowIfInvalidRow(Table A, int i)Throws if accessing an out of range row.
-
-
-
Method Detail
-
isColumn
public static boolean isColumn(Table A)
Check if a table is a column.- Parameters:
A- a table- Returns:
trueif the table has only one column
-
isRow
public static boolean isRow(Table A)
Check if a table is a row.- Parameters:
A- a table- Returns:
trueif the table has only one row
-
isArray
public static boolean isArray(Table A)
Check if a table is a row or a column.- Parameters:
A- a table- Returns:
trueif the table has only one row or one column
-
isSquare
public static boolean isSquare(Table A)
Check if a table is square.- Parameters:
A- a table- Returns:
trueif the table has as many rows as it has columns
-
isTall
public static boolean isTall(Table A)
Check if a table is tall.- Parameters:
A- a table- Returns:
trueif the table has no fewer rows than it has columns
-
isFat
public static boolean isFat(Table A)
Check if a table is fat.- Parameters:
A- a table- Returns:
trueif the table has no fewer columns than it has rows
-
isSameDimension
public static boolean isSameDimension(Table A1, Table A2)
Check if two tables have the same dimension.- Parameters:
A1- a tableA2- a table- Returns:
trueif the rows and columns, i.e. the dimensions of A1 and A2, are equal
-
throwIfDifferentDimension
public static void throwIfDifferentDimension(Table A1, Table A2)
Throws if
OrA1.nRows() != A2.nRows()A1.nCols() != A2.nCols()- Parameters:
A1- a tableA2- a table
-
throwIfInvalidRow
public static void throwIfInvalidRow(Table A, int i)
Throws if accessing an out of range row.- Parameters:
A- a tablei- a row index
-
throwIfInvalidColumn
public static void throwIfInvalidColumn(Table A, int j)
Throws if accessing an out of range column.- Parameters:
A- a tablej- a column index
-
throwIfIncompatible4Multiplication
public static void throwIfIncompatible4Multiplication(Table A1, Table A2)
Throws ifA1.nCols() != A2.nRows()- Parameters:
A1- a tableA2- a table
-
-