Package dev.nm.misc.datastructure
Class DimensionCheck
java.lang.Object
dev.nm.misc.datastructure.DimensionCheck
These are the utility functions for checking table dimension.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Check if a table is a row or a column.static boolean
Check if a table is a column.static boolean
Check if a table is fat.static boolean
Check if a table is a row.static boolean
isSameDimension
(Table A1, Table A2) Check if two tables have the same dimension.static boolean
Check if a table is square.static boolean
Check if a table is tall.static void
throwIfDifferentDimension
(Table A1, Table A2) Throws ifA1.nRows() != A2.nRows()
OrA1.nCols() != A2.nCols()
static void
Throws ifA.nCols() != v.size()
static void
Throws ifA1.nCols() != A2.nRows()
static void
throwIfInvalidColumn
(Table A, int j) Throws if accessing an out of range column.static void
throwIfInvalidRow
(Table A, int i) Throws if accessing an out of range row.
-
Method Details
-
isColumn
Check if a table is a column.- Parameters:
A
- a table- Returns:
true
if the table has only one column
-
isRow
Check if a table is a row.- Parameters:
A
- a table- Returns:
true
if the table has only one row
-
isArray
Check if a table is a row or a column.- Parameters:
A
- a table- Returns:
true
if the table has only one row or one column
-
isSquare
Check if a table is square.- Parameters:
A
- a table- Returns:
true
if the table has as many rows as it has columns
-
isTall
Check if a table is tall.- Parameters:
A
- a table- Returns:
true
if the table has no fewer rows than it has columns
-
isFat
Check if a table is fat.- Parameters:
A
- a table- Returns:
true
if the table has no fewer columns than it has rows
-
isSameDimension
Check if two tables have the same dimension.- Parameters:
A1
- a tableA2
- a table- Returns:
true
if the rows and columns, i.e. the dimensions of A1 and A2, are equal
-
throwIfDifferentDimension
Throws if
OrA1.nRows() != A2.nRows()
A1.nCols() != A2.nCols()
- Parameters:
A1
- a tableA2
- a table
-
throwIfInvalidRow
Throws if accessing an out of range row.- Parameters:
A
- a tablei
- a row index
-
throwIfInvalidColumn
Throws if accessing an out of range column.- Parameters:
A
- a tablej
- a column index
-
throwIfIncompatible4Multiplication
Throws ifA1.nCols() != A2.nRows()
- Parameters:
A1
- a tableA2
- a table
-
throwIfIncompatible4Multiplication
Throws ifA.nCols() != v.size()
- Parameters:
A
- a tablev
- a vector
-