org.apache.commons.math.linear
Class BigMatrixImplTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.math.linear.BigMatrixImplTest
All Implemented Interfaces:
junit.framework.Test

public final class BigMatrixImplTest
extends junit.framework.TestCase

Test cases for the BigMatrixImpl class.

Version:
$Revision: 611480 $ $Date: 2008-01-12 14:04:42 -0700 (Sat, 12 Jan 2008) $

Field Summary
protected  double[][] bigSingular
           
protected  double[][] detData
           
protected  double[][] detData2
           
protected  double entryTolerance
           
protected  double[][] id
           
protected  double[][] luData
           
protected  double[][] luDataLUDecomposition
           
protected  double normTolerance
           
protected  double[] preMultTest
           
protected  double[][] singular
           
protected  double[][] subColumn1
           
protected  double[][] subColumn3
           
protected  double[][] subRow0
           
protected  double[][] subRow3
           
protected  double[][] subRows00Cols33
           
protected  double[][] subRows01Cols23
           
protected  double[][] subRows02Cols13
           
protected  double[][] subRows03Cols12
           
protected  double[][] subRows03Cols123
           
protected  double[][] subRows20Cols123
           
protected  double[][] subRows23Cols00
           
protected  double[][] subRows31Cols31
           
protected  double[][] subTestData
           
protected  double[][] testData
           
protected  double[][] testData2
           
protected  double[][] testData2T
           
protected  double[] testDataCol3
           
protected  double[][] testDataInv
           
protected  double[][] testDataLU
           
protected  double[][] testDataMinus
           
protected  double[][] testDataPlus2
           
protected  double[][] testDataPlusInv
           
protected  double[] testDataRow1
           
protected  java.lang.String[][] testDataString
           
protected  double[] testVector
           
protected  double[] testVector2
           
 
Constructor Summary
BigMatrixImplTest(java.lang.String name)
           
 
Method Summary
static java.math.BigDecimal[] asBigDecimal(double[] data)
           
static java.math.BigDecimal[][] asBigDecimal(double[][] data)
           
static double[] asDouble(java.math.BigDecimal[] data)
           
static double[][] asDouble(java.math.BigDecimal[][] data)
           
protected  void assertClose(java.lang.String msg, org.apache.commons.math.linear.BigMatrix m, org.apache.commons.math.linear.BigMatrix n, double tolerance)
          verifies that two matrices are close (1-norm)
protected  void assertClose(java.lang.String msg, double[] m, double[] n, double tolerance)
          verifies that two vectors are close (sup norm)
protected  org.apache.commons.math.linear.BigMatrix permuteRows(org.apache.commons.math.linear.BigMatrix matrix, int[] permutation)
          Returns the result of applying the given row permutation to the matrix
 void setUp()
           
protected  void splitLU(org.apache.commons.math.linear.BigMatrix lu, java.math.BigDecimal[][] lowerData, java.math.BigDecimal[][] upperData)
          extracts the l and u matrices from compact lu representation
static junit.framework.Test suite()
           
 void testAdd()
          test add
 void testAddFail()
          test add failure
 void testConstructors()
          test constructors
 void testCopyFunctions()
          test copy functions
 void testDeterminant()
          test determinant
 void testDimensions()
          test dimensions
 void testEqualsAndHashCode()
           
 void testGetColumnMatrix()
           
 void testGetRowMatrix()
           
 void testGetVectors()
           
 void testInverse()
          test inverse
 void testIsSingular()
          test isSingular
 void testLUDecomposition()
           
 void testMultiply()
          test multiply
 void testMultiply2()
           
 void testNorm()
          test norm
 void testOperate()
          test operate
 void testPlusMinus()
          test m-n = m + -n
 void testPremultiply()
           
 void testPremultiplyVector()
          test preMultiply by vector
 void testScalarAdd()
          test sclarAdd
 void testSetSubMatrix()
           
 void testSolve()
          test solve
 void testSubMatrix()
          test submatrix accessors
 void testToString()
           
 void testTrace()
          test trace
 void testTranspose()
          test transpose
protected  void verifyDecomposition(org.apache.commons.math.linear.BigMatrix matrix, org.apache.commons.math.linear.BigMatrix lu)
          Extracts l and u matrices from lu and verifies that matrix = l times u modulo permutation
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

testDataString

protected java.lang.String[][] testDataString

id

protected double[][] id

testData

protected double[][] testData

testDataLU

protected double[][] testDataLU

testDataPlus2

protected double[][] testDataPlus2

testDataMinus

protected double[][] testDataMinus

testDataRow1

protected double[] testDataRow1

testDataCol3

protected double[] testDataCol3

testDataInv

protected double[][] testDataInv

preMultTest

protected double[] preMultTest

testData2

protected double[][] testData2

testData2T

protected double[][] testData2T

testDataPlusInv

protected double[][] testDataPlusInv

luData

protected double[][] luData

luDataLUDecomposition

protected double[][] luDataLUDecomposition

singular

protected double[][] singular

bigSingular

protected double[][] bigSingular

detData

protected double[][] detData

detData2

protected double[][] detData2

testVector

protected double[] testVector

testVector2

protected double[] testVector2

subTestData

protected double[][] subTestData

subRows02Cols13

protected double[][] subRows02Cols13

subRows03Cols12

protected double[][] subRows03Cols12

subRows03Cols123

protected double[][] subRows03Cols123

subRows20Cols123

protected double[][] subRows20Cols123

subRows31Cols31

protected double[][] subRows31Cols31

subRows01Cols23

protected double[][] subRows01Cols23

subRows23Cols00

protected double[][] subRows23Cols00

subRows00Cols33

protected double[][] subRows00Cols33

subRow0

protected double[][] subRow0

subRow3

protected double[][] subRow3

subColumn1

protected double[][] subColumn1

subColumn3

protected double[][] subColumn3

entryTolerance

protected double entryTolerance

normTolerance

protected double normTolerance
Constructor Detail

BigMatrixImplTest

public BigMatrixImplTest(java.lang.String name)
Method Detail

setUp

public void setUp()
Overrides:
setUp in class junit.framework.TestCase

suite

public static junit.framework.Test suite()

asDouble

public static final double[] asDouble(java.math.BigDecimal[] data)

asDouble

public static final double[][] asDouble(java.math.BigDecimal[][] data)

asBigDecimal

public static final java.math.BigDecimal[] asBigDecimal(double[] data)

asBigDecimal

public static final java.math.BigDecimal[][] asBigDecimal(double[][] data)

testDimensions

public void testDimensions()
test dimensions


testCopyFunctions

public void testCopyFunctions()
test copy functions


testConstructors

public void testConstructors()
test constructors


testAdd

public void testAdd()
test add


testAddFail

public void testAddFail()
test add failure


testNorm

public void testNorm()
test norm


testPlusMinus

public void testPlusMinus()
test m-n = m + -n


testMultiply

public void testMultiply()
test multiply


testMultiply2

public void testMultiply2()

testIsSingular

public void testIsSingular()
test isSingular


testInverse

public void testInverse()
test inverse


testSolve

public void testSolve()
test solve


testDeterminant

public void testDeterminant()
test determinant


testTrace

public void testTrace()
test trace


testScalarAdd

public void testScalarAdd()
test sclarAdd


testOperate

public void testOperate()
test operate


testTranspose

public void testTranspose()
test transpose


testPremultiplyVector

public void testPremultiplyVector()
test preMultiply by vector


testPremultiply

public void testPremultiply()

testGetVectors

public void testGetVectors()

testLUDecomposition

public void testLUDecomposition()
                         throws java.lang.Exception
Throws:
java.lang.Exception

testSubMatrix

public void testSubMatrix()
test submatrix accessors


testGetColumnMatrix

public void testGetColumnMatrix()

testGetRowMatrix

public void testGetRowMatrix()

testEqualsAndHashCode

public void testEqualsAndHashCode()

testToString

public void testToString()

testSetSubMatrix

public void testSetSubMatrix()
                      throws java.lang.Exception
Throws:
java.lang.Exception

assertClose

protected void assertClose(java.lang.String msg,
                           org.apache.commons.math.linear.BigMatrix m,
                           org.apache.commons.math.linear.BigMatrix n,
                           double tolerance)
verifies that two matrices are close (1-norm)


assertClose

protected void assertClose(java.lang.String msg,
                           double[] m,
                           double[] n,
                           double tolerance)
verifies that two vectors are close (sup norm)


splitLU

protected void splitLU(org.apache.commons.math.linear.BigMatrix lu,
                       java.math.BigDecimal[][] lowerData,
                       java.math.BigDecimal[][] upperData)
                throws org.apache.commons.math.linear.InvalidMatrixException
extracts the l and u matrices from compact lu representation

Throws:
org.apache.commons.math.linear.InvalidMatrixException

permuteRows

protected org.apache.commons.math.linear.BigMatrix permuteRows(org.apache.commons.math.linear.BigMatrix matrix,
                                                               int[] permutation)
Returns the result of applying the given row permutation to the matrix


verifyDecomposition

protected void verifyDecomposition(org.apache.commons.math.linear.BigMatrix matrix,
                                   org.apache.commons.math.linear.BigMatrix lu)
                            throws java.lang.Exception
Extracts l and u matrices from lu and verifies that matrix = l times u modulo permutation

Throws:
java.lang.Exception


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.