SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix
Class DimensionCheck

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.DimensionCheck

public class DimensionCheck
extends java.lang.Object

This class collects the common functions for checking matrix dimensions.


Method Summary
static boolean isColumnVector(MatrixDimension A)
          Check if a matrix is a column vector.
static boolean isFat(MatrixDimension A)
          Check if a matrix is a fat matrix.
static boolean isRowVector(MatrixDimension A)
          Check if a matrix is a row vector.
static boolean isSquare(MatrixDimension A)
          Check if a matrix is a square matrix.
static boolean isTall(MatrixDimension A)
          Check if a matrix is a tall matrix.
static boolean isVector(MatrixDimension A)
          Check if a matrix is a row or a column vector.
static boolean sameDimension(MatrixDimension A1, MatrixDimension A2)
          Check if two matrices are of the same dimension.
static void throwIfDifferentDimension(MatrixDimension A1, MatrixDimension A2)
          Throws if A1.nrow !
static void throwIfIncompatible4Multiplication(MatrixDimension A1, MatrixDimension A2)
          Throws if A1.ncol !
static void throwIfIncompatible4Multiplication(MatrixDimension A, Vector v)
          Throws if A.ncol !
static void throwIfInvalidColumn(MatrixDimension A, int col)
          Throws if accessing an out of range column.
static void throwIfInvalidRow(MatrixDimension A, int row)
          Throws if accessing an out of range row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isColumnVector

public static boolean isColumnVector(MatrixDimension A)
Check if a matrix is a column vector.

Parameters:
A - a matrix
Returns:
true iff the matrix has only one column

isRowVector

public static boolean isRowVector(MatrixDimension A)
Check if a matrix is a row vector.

Parameters:
A - a matrix
Returns:
true iff the matrix has only one row

isVector

public static boolean isVector(MatrixDimension A)
Check if a matrix is a row or a column vector.

Parameters:
A - a matrix
Returns:
true iff the matrix has only one row or one column

isSquare

public static boolean isSquare(MatrixDimension A)
Check if a matrix is a square matrix.

Parameters:
A - a matrix
Returns:
true iff the matrix has as many rows as it has columns

isTall

public static boolean isTall(MatrixDimension A)
Check if a matrix is a tall matrix.

Parameters:
A - a matrix
Returns:
true iff the matrix has no fewer rows than it has columns

isFat

public static boolean isFat(MatrixDimension A)
Check if a matrix is a fat matrix.

Parameters:
A - a matrix
Returns:
true iff the matrix has no fewer columns than it has rows

sameDimension

public static boolean sameDimension(MatrixDimension A1,
                                    MatrixDimension A2)
Check if two matrices are of the same dimension.

Parameters:
A1 - a matrix
A2 - a matrix
Returns:
true iff rows and columns, i.e. the dimensions of A1 and A2, are equal

throwIfDifferentDimension

public static void throwIfDifferentDimension(MatrixDimension A1,
                                             MatrixDimension A2)
Throws if
A1.nrow != A2.nrow
OR
A1.ncol != A2.ncol

Parameters:
A1 - a matrix
A2 - a matrix

throwIfIncompatible4Multiplication

public static void throwIfIncompatible4Multiplication(MatrixDimension A1,
                                                      MatrixDimension A2)
Throws if
A1.ncol != A2.nrow

Parameters:
A1 - a matrix
A2 - a matrix

throwIfIncompatible4Multiplication

public static void throwIfIncompatible4Multiplication(MatrixDimension A,
                                                      Vector v)
Throws if
A.ncol != v.size

Parameters:
A - a matrix
v - a vector

throwIfInvalidRow

public static void throwIfInvalidRow(MatrixDimension A,
                                     int row)
Throws if accessing an out of range row.

Parameters:
A - a matrix
row - a row index

throwIfInvalidColumn

public static void throwIfInvalidColumn(MatrixDimension A,
                                        int col)
Throws if accessing an out of range column.

Parameters:
A - a matrix
col - a column index

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.