ru.tunegov.mathematic
Class Matrix

java.lang.Object
  |
  +--ru.tunegov.mathematic.Matrix
All Implemented Interfaces:
java.lang.Cloneable, ElementSet, MatrixElementSet, java.io.Serializable

public class Matrix
extends java.lang.Object
implements MatrixElementSet

This is a non-visual component that represents matrixes. The given class realizes main operations above matrixes.

Since:
Mathematic 1.0
See Also:
Serialized Form

Constructor Summary
Matrix()
          Contruct a Matrix object.
Matrix(double[][] array)
          Contruct a Matrix object.
Matrix(int rows, int cols)
          Contruct a Matrix object.
Matrix(java.lang.String s)
          Contruct a Matrix object.
 
Method Summary
 ElementSet abs()
          Returns the absolute value of an element of a set.
 ElementSet add(Complex arg)
          Returns the sum of the given element with argument (result = this + arg).
 ElementSet add(Decimal arg)
          Returns the sum of the given element with argument (result = this + arg).
 ElementSet add(double arg)
          Returns the sum of the given element with argument (result = this + arg).
 ElementSet add(ElementSet arg)
          Returns the sum of the given element with argument (result = this + arg).
 MatrixElementSet add(MatrixElementSet arg)
          Returns the sum of the given element with argument (result = this + arg).
 java.lang.Object clone()
          Returns clone of this object.
 ElementSet cos()
          Returns the cosine of given element.
 ElementSet divide(Complex arg)
          Returns the quotient of the given element with argument (result = this / arg).
 ElementSet divide(Decimal arg)
          Returns the quotient of the given element with argument (result = this / arg).
 ElementSet divide(double arg)
          Returns the quotient of the given element with argument (result = this / arg).
 ElementSet divide(ElementSet arg)
          Returns the quotient of the given element with argument (result = this / arg).
 MatrixElementSet divide(MatrixElementSet arg)
          Returns the quotient of the given element with argument (result = this / arg).
 ElementSet divideInverse(Complex arg)
          Returns the quotient of the argument with given element (result = arg / this).
 ElementSet divideInverse(Decimal arg)
          Returns the quotient of the argument with given element (result = arg / this).
 ElementSet divideInverse(double arg)
          Returns the quotient of the argument with given element (result = arg / this).
 MatrixElementSet divideInverse(MatrixElementSet arg)
          Returns the quotient of the argument with given element (result = arg / this).
 boolean equals(java.lang.Object obj)
          Compares two Objects for equality.
 ElementSet exp()
          Returns the exponential function raised in a degree equal to the given element.
 int getCols()
          Returns the number of columns in the matrix.
 ElementSet getItem(int row, int col)
          Returns thevalue of the cell in matrix.
 ElementSet[][] getItems()
          Returns the array of values of the matrix.
 int getRows()
          Returns the number of rows in the matrix.
 ElementSet inverse()
          Returns the inverse value of the given element.
 ElementSet log()
          Returns the logarithm of given element.
 ElementSet multiply(Complex arg)
          Returns the product of the given element with argument (result = this * arg).
 ElementSet multiply(Decimal arg)
          Returns the product of the given element with argument (result = this * arg).
 ElementSet multiply(double arg)
          Returns the product of the given element with argument (result = this * arg).
 ElementSet multiply(ElementSet arg)
          Returns the product of the given element with argument (result = this * arg).
 MatrixElementSet multiply(MatrixElementSet arg)
          Returns the product of the given element with argument (result = this * arg).
 ElementSet negate()
          Returns the element negative given.
 ElementSet norm()
          Returns the k norm of given element.
 ElementSet pow(double degree)
          Returns the given element raised to n-th degree.
 ElementSet root(int degree)
          Returns the root of n-th degree of given element.
 void setItem(int row, int col, ElementSet value)
          Sets the value of the cell in matrix.
 void setItems(ElementSet[][] value)
          Sets the array of values of the matrix.
 ElementSet sin()
          Returns the sine of given element.
 ElementSet sqrt()
          Returns the square root of given element.
 ElementSet subtract(Complex arg)
          Returns the difference of the given element with argument (result = this - arg).
 ElementSet subtract(Decimal arg)
          Returns the difference of the given element with argument (result = this - arg).
 ElementSet subtract(double arg)
          Returns the difference of the given element with argument (result = this - arg).
 ElementSet subtract(ElementSet arg)
          Returns the difference of the given element with argument (result = this - arg).
 MatrixElementSet subtract(MatrixElementSet arg)
          Returns the difference of the given element with argument (result = this - arg).
 ElementSet subtractInverse(Complex arg)
          Returns the difference of the argument with given element (result = arg - this).
 ElementSet subtractInverse(Decimal arg)
          Returns the difference of the argument with given element (result = arg - this).
 ElementSet subtractInverse(double arg)
          Returns the difference of the argument with given element (result = arg - this).
 MatrixElementSet subtractInverse(MatrixElementSet arg)
          Returns the difference of the argument with given element (result = arg - this).
 ElementSet tan()
          Returns the tangent of given element.
 java.lang.String toFormattedString(java.text.DecimalFormat df)
          Returns formatted string representing the given element.
 java.lang.String toString()
          Returns a String that represents the value of this object.
 MatrixElementSet transpose()
          Returns the transpose matrix.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix()
Contruct a Matrix object.

Matrix

public Matrix(double[][] array)
Contruct a Matrix object.
Parameters:
array - The matrix cells values

Matrix

public Matrix(int rows,
              int cols)
Contruct a Matrix object.
Parameters:
rows - The number of rows in the matrix
rows - The number of columns in the matrix

Matrix

public Matrix(java.lang.String s)
Contruct a Matrix object.
Parameters:
s - The string representation of the matrix
Method Detail

abs

public ElementSet abs()
Returns the absolute value of an element of a set.
Specified by:
abs in interface ElementSet
Returns:
The absolute value of an element of a set

add

public ElementSet add(double arg)
Returns the sum of the given element with argument (result = this + arg).
Specified by:
add in interface ElementSet
Parameters:
arg - The second argument
Returns:
The sum of the given element with argument

add

public ElementSet add(Complex arg)
Returns the sum of the given element with argument (result = this + arg).
Specified by:
add in interface ElementSet
Parameters:
arg - The second argument
Returns:
The sum of the given element with argument

add

public ElementSet add(Decimal arg)
Returns the sum of the given element with argument (result = this + arg).
Specified by:
add in interface ElementSet
Parameters:
arg - The second argument
Returns:
The sum of the given element with argument

add

public ElementSet add(ElementSet arg)
Returns the sum of the given element with argument (result = this + arg).
Specified by:
add in interface ElementSet
Parameters:
arg - The second argument
Returns:
The sum of the given element with argument

add

public MatrixElementSet add(MatrixElementSet arg)
Returns the sum of the given element with argument (result = this + arg).
Specified by:
add in interface ElementSet
Parameters:
arg - The second argument
Returns:
The sum of the given element with argument

clone

public java.lang.Object clone()
Returns clone of this object.
Specified by:
clone in interface ElementSet
Returns:
clone of this object

cos

public ElementSet cos()
Returns the cosine of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
cos in interface ElementSet
Returns:
The cosine of the given element

divide

public ElementSet divide(double arg)
Returns the quotient of the given element with argument (result = this / arg).
Specified by:
divide in interface ElementSet
Parameters:
arg - The second argument
Returns:
The quotient of the given element with argument

divide

public ElementSet divide(Complex arg)
Returns the quotient of the given element with argument (result = this / arg).
Specified by:
divide in interface ElementSet
Parameters:
arg - The second argument
Returns:
The quotient of the given element with argument

divide

public ElementSet divide(Decimal arg)
Returns the quotient of the given element with argument (result = this / arg).
Specified by:
divide in interface ElementSet
Parameters:
arg - The second argument
Returns:
The quotient of the given element with argument

divide

public ElementSet divide(ElementSet arg)
Returns the quotient of the given element with argument (result = this / arg).
Specified by:
divide in interface ElementSet
Parameters:
arg - The second argument
Returns:
The quotient of the given element with argument

divide

public MatrixElementSet divide(MatrixElementSet arg)
Returns the quotient of the given element with argument (result = this / arg). WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
divide in interface ElementSet
Parameters:
arg - The second argument
Returns:
The quotient of the given element with argument

divideInverse

public ElementSet divideInverse(double arg)
Returns the quotient of the argument with given element (result = arg / this). WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
divideInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The quotient of the argument with given element

divideInverse

public ElementSet divideInverse(Complex arg)
Returns the quotient of the argument with given element (result = arg / this). WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
divideInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The quotient of the argument with given element

divideInverse

public ElementSet divideInverse(Decimal arg)
Returns the quotient of the argument with given element (result = arg / this). WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
divideInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The quotient of the argument with given element

divideInverse

public MatrixElementSet divideInverse(MatrixElementSet arg)
Returns the quotient of the argument with given element (result = arg / this). WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
divideInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The quotient of the argument with given element

equals

public boolean equals(java.lang.Object obj)
Compares two Objects for equality.
Overrides:
equals in class java.lang.Object
Parameters:
obj - The reference object with which to compare
Returns:
true if this object is the same as the obj argument; false otherwise.

exp

public ElementSet exp()
Returns the exponential function raised in a degree equal to the given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
exp in interface ElementSet
Returns:
The exponential function raised in a degree equal to the given element.

getCols

public int getCols()
Returns the number of columns in the matrix.
Specified by:
getCols in interface MatrixElementSet
Returns:
The number of columns in the matrix

getItem

public ElementSet getItem(int row,
                          int col)
Returns thevalue of the cell in matrix.
Specified by:
getItem in interface MatrixElementSet
Parameters:
row - The row in matrix
col - The column in matrix
Returns:
The value of the cell in matrix

getItems

public ElementSet[][] getItems()
Returns the array of values of the matrix.
Specified by:
getItems in interface MatrixElementSet
Returns:
The array of values of the matrix

getRows

public int getRows()
Returns the number of rows in the matrix.
Specified by:
getRows in interface MatrixElementSet
Returns:
The number of rows in the matrix

inverse

public ElementSet inverse()
Returns the inverse value of the given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
inverse in interface ElementSet
Returns:
The inverse value of the given element

log

public ElementSet log()
Returns the logarithm of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
log in interface ElementSet
Returns:
The logarithm of the given element

multiply

public ElementSet multiply(double arg)
Returns the product of the given element with argument (result = this * arg).
Specified by:
multiply in interface ElementSet
Parameters:
arg - The second argument
Returns:
The product of the given element with argument

multiply

public ElementSet multiply(Complex arg)
Returns the product of the given element with argument (result = this * arg).
Specified by:
multiply in interface ElementSet
Parameters:
arg - The second argument
Returns:
The product of the given element with argument

multiply

public ElementSet multiply(Decimal arg)
Returns the product of the given element with argument (result = this * arg).
Specified by:
multiply in interface ElementSet
Parameters:
arg - The second argument
Returns:
The product of the given element with argument

multiply

public ElementSet multiply(ElementSet arg)
Returns the product of the given element with argument (result = this * arg).
Specified by:
multiply in interface ElementSet
Parameters:
arg - The second argument
Returns:
The product of the given element with argument

multiply

public MatrixElementSet multiply(MatrixElementSet arg)
Returns the product of the given element with argument (result = this * arg).
Specified by:
multiply in interface ElementSet
Parameters:
arg - The second argument
Returns:
The product of the given element with argument

negate

public ElementSet negate()
Returns the element negative given.
Specified by:
negate in interface ElementSet
Returns:
The element negative given

norm

public ElementSet norm()
Returns the k norm of given element.
Specified by:
norm in interface MatrixElementSet
Returns:
The k norm of given element

pow

public ElementSet pow(double degree)
Returns the given element raised to n-th degree.
Specified by:
pow in interface ElementSet
Parameters:
degree - The degree of power
Returns:
The given element raised to n-th degree

root

public ElementSet root(int degree)
Returns the root of n-th degree of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
root in interface ElementSet
Parameters:
degree - The degree of root
Returns:
The root of n-th degree of the given element

setItem

public void setItem(int row,
                    int col,
                    ElementSet value)
Sets the value of the cell in matrix.
Specified by:
setItem in interface MatrixElementSet
Parameters:
row - The row in matrix
col - The column in matrix
value - The value of the cell

setItems

public void setItems(ElementSet[][] value)
Sets the array of values of the matrix.
Specified by:
setItems in interface MatrixElementSet
Parameters:
value - The array of values of the matrix

sin

public ElementSet sin()
Returns the sine of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
sin in interface ElementSet
Returns:
The sine of the given element

sqrt

public ElementSet sqrt()
Returns the square root of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
sqrt in interface ElementSet
Returns:
The square root of the given element

subtract

public ElementSet subtract(double arg)
Returns the difference of the given element with argument (result = this - arg).
Specified by:
subtract in interface ElementSet
Parameters:
arg - The second argument
Returns:
The difference of the given element with argument

subtract

public ElementSet subtract(Complex arg)
Returns the difference of the given element with argument (result = this - arg).
Specified by:
subtract in interface ElementSet
Parameters:
arg - The second argument
Returns:
The difference of the given element with argument

subtract

public ElementSet subtract(Decimal arg)
Returns the difference of the given element with argument (result = this - arg).
Specified by:
subtract in interface ElementSet
Parameters:
arg - The second argument
Returns:
The difference of the given element with argument

subtract

public ElementSet subtract(ElementSet arg)
Returns the difference of the given element with argument (result = this - arg).
Specified by:
subtract in interface ElementSet
Parameters:
arg - The second argument
Returns:
The difference of the given element with argument

subtract

public MatrixElementSet subtract(MatrixElementSet arg)
Returns the difference of the given element with argument (result = this - arg).
Specified by:
subtract in interface ElementSet
Parameters:
arg - The second argument
Returns:
The difference of the given element with argument

subtractInverse

public ElementSet subtractInverse(double arg)
Returns the difference of the argument with given element (result = arg - this).
Specified by:
subtractInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The difference of the argument with given element

subtractInverse

public ElementSet subtractInverse(Complex arg)
Returns the difference of the argument with given element (result = arg - this).
Specified by:
subtractInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The difference of the argument with given element

subtractInverse

public ElementSet subtractInverse(Decimal arg)
Returns the difference of the argument with given element (result = arg - this).
Specified by:
subtractInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The difference of the argument with given element

subtractInverse

public MatrixElementSet subtractInverse(MatrixElementSet arg)
Returns the difference of the argument with given element (result = arg - this).
Specified by:
subtractInverse in interface ElementSet
Parameters:
arg - The first argument
Returns:
The difference of the argument with given element

tan

public ElementSet tan()
Returns the tangent of given element. WARNING: This operation not supported for this type. It throw OperationNotSupport exception.
Specified by:
tan in interface ElementSet
Returns:
The tangent of the given element

toFormattedString

public java.lang.String toFormattedString(java.text.DecimalFormat df)
Returns formatted string representing the given element.
Specified by:
toFormattedString in interface ElementSet
Parameters:
df - Formatter
Returns:
The formatted string representing the given element

toString

public java.lang.String toString()
Returns a String that represents the value of this object.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the receiver

transpose

public MatrixElementSet transpose()
Returns the transpose matrix.
Specified by:
transpose in interface MatrixElementSet
Returns:
The transpose matrix