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 boolean
isArray(Table A)
Check if a table is a row or a column.static boolean
isColumn(Table A)
Check if a table is a column.static boolean
isFat(Table A)
Check if a table is fat.static boolean
isRow(Table A)
Check if a table is a row.static boolean
isSameDimension(Table A1, Table A2)
Check if two tables have the same dimension.static boolean
isSquare(Table A)
Check if a table is square.static boolean
isTall(Table A)
Check if a table is tall.static void
throwIfDifferentDimension(Table A1, Table A2)
Throws ifA1.nRows() != A2.nRows()
OrA1.nCols() != A2.nCols()
static void
throwIfIncompatible4Multiplication(Table A, Vector v)
Throws ifA.nCols() != v.size()
static void
throwIfIncompatible4Multiplication(Table A1, Table A2)
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 Detail
-
isColumn
public static boolean isColumn(Table A)
Check if a table is a column.- Parameters:
A
- a table- Returns:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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
-
-