Class Matrix

java.lang.Object
  |
  +--Matrix

public class Matrix
extends java.lang.Object

Class Matrix provides several static operation on 2-dimensional arrays of double. The methods of class Matrix can operate correctly on 2 dimensional arrays which are rectangular (all rows are of equal length) and non-empty (not null and minimum size double[1][1]).

Version:
(18 April 2002)
Author:
(Antonios Symvonis)

Constructor Summary
Matrix()
           
 
Method Summary
static double[][] add(double[][] a, double[][] b)
          Implements 2d-array addition.
static double[][] clone(double[][] m)
          Creates an exact copy of a 2d-array.
static void fillRandomData(double[][] m)
          Fills a matrix with radmon data in the range [0..1).
static double[][] maxCols(double[][] m)
          It produces a single row 2d-array.
static double[][] maxRows(double[][] m)
          It produces a single column 2d-array.
static double[][] minCols(double[][] m)
          It produces a single row 2d-array.
static double[][] minRows(double[][] m)
          It produces a single column 2d-array.
static double[][] multiply(double[][] a, double[][] b)
          Implements 2d-array multiplication.
static double[][] multiply(double factor, double[][] m)
          Implements scalar 2d-array multiplication.
static void print(double[][] m)
          Prints the elements of a 2d-array, each row at a different line.
static double[][] subtract(double[][] a, double[][] b)
          Implements 2d-array subtraction.
static double[][] sumCols(double[][] m)
          It produces a single row 2d-array.
static double[][] sumRows(double[][] m)
          It produces a single column 2d-array.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix()
Method Detail

add

public static double[][] add(double[][] a,
                             double[][] b)
Implements 2d-array addition. The two arrays to be added must be rectangular, non-empty, and of identical dinensions.
Parameters:
a - The first matrix to be added.
b - The second array to be added.
Returns:
The sum of the argument arrays.

clone

public static double[][] clone(double[][] m)
Creates an exact copy of a 2d-array.
Parameters:
m - The array to be copied. Must be rectangular and non-empty.
Returns:
An exact copy of the argument array.

fillRandomData

public static void fillRandomData(double[][] m)
Fills a matrix with radmon data in the range [0..1). The random numbers have precision of 2 decimal digits.
Parameters:
m - The array to be filled. Must be rectangular and non-empty.

maxCols

public static double[][] maxCols(double[][] m)
It produces a single row 2d-array. The element at each column of the resulting 2d-array is equal to the maximum element of the corresponding column of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the maximum column elements.
Returns:
The single row 2d-array containing the column maximums.

maxRows

public static double[][] maxRows(double[][] m)
It produces a single column 2d-array. The element at each row of the resulting 2d-array is equal to the maximum element of the corresponding row of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the maximum row elements.
Returns:
The single column 2d-array containing the row maximums.

minCols

public static double[][] minCols(double[][] m)
It produces a single row 2d-array. The element at each column of the resulting 2d-array is equal to the minimum element of the corresponding column of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the minimum column elements.
Returns:
The single row 2d-array containing the column minimums.

minRows

public static double[][] minRows(double[][] m)
It produces a single column 2d-array. The element at each row of the resulting 2d-array is equal to the minimum element of the corresponding row of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the minimum row elements.
Returns:
The single column 2d-array containing the row minimums.

multiply

public static double[][] multiply(double[][] a,
                                  double[][] b)
Implements 2d-array multiplication. The two participating arrays must be rectangular, non-empty, and of appropriate dinensions (the number of columns of the first matrix must be equal to the number of rows of the second matrix).
Parameters:
a - The left matrix of the multiplication.
b - The right matrix of the multiplication.
Returns:
The result of the matrix multiplication.

multiply

public static double[][] multiply(double factor,
                                  double[][] m)
Implements scalar 2d-array multiplication. The participating array must be rectangular and non-empty.
Parameters:
factor - The factor of the multiplication.
m - The matrix to be multiplied.
Returns:
The result of the scalar multiplication.

print

public static void print(double[][] m)
Prints the elements of a 2d-array, each row at a different line.
Parameters:
m - The array of which the ellements are printed. Must be rectangular and non-empty.

subtract

public static double[][] subtract(double[][] a,
                                  double[][] b)
Implements 2d-array subtraction. The two participating arrays must be rectangular, non-empty, and of identical dinensions.
Parameters:
a - The matrix from which we subtract.
b - The matrix to be subtracted.
Returns:
The result of the subtraction.

sumCols

public static double[][] sumCols(double[][] m)
It produces a single row 2d-array. The element at each column of the resulting 2d-array is equal to the sum of the elements at the corresponding column of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the sum of the column elements.
Returns:
The single row 2d-array containing the column sums.

sumRows

public static double[][] sumRows(double[][] m)
It produces a single column 2d-array. The element at each row of the resulting 2d-array is equal to the sum of the elements at the corresponding row of the matrix given as parameter.
Parameters:
m - The matrix of which we compute the sum of the row elements.
Returns:
The single column 2d-array containing the row sums.


Generated by BlueJ