You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2009/06/11 10:54:04 UTC
svn commit: r783702 [2/4] - in /commons/proper/math/trunk: ./
src/experimental/org/apache/commons/math/linear/
src/java/org/apache/commons/math/
src/java/org/apache/commons/math/estimation/
src/java/org/apache/commons/math/linear/ src/java/org/apache/c...
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java Thu Jun 11 08:54:02 2009
@@ -245,7 +245,7 @@
public RealVector solve(RealVector b)
throws IllegalArgumentException, InvalidMatrixException {
try {
- return solve((RealVectorImpl) b);
+ return solve((ArrayRealVector) b);
} catch (ClassCastException cce) {
final int m = lTData.length;
@@ -276,7 +276,7 @@
}
}
- return new RealVectorImpl(x, false);
+ return new ArrayRealVector(x, false);
}
}
@@ -288,9 +288,9 @@
* @exception IllegalArgumentException if matrices dimensions don't match
* @exception InvalidMatrixException if decomposed matrix is singular
*/
- public RealVectorImpl solve(RealVectorImpl b)
+ public ArrayRealVector solve(ArrayRealVector b)
throws IllegalArgumentException, InvalidMatrixException {
- return new RealVectorImpl(solve(b.getDataRef()), false);
+ return new ArrayRealVector(solve(b.getDataRef()), false);
}
/** {@inheritDoc} */
@@ -340,7 +340,7 @@
}
}
- return new RealMatrixImpl(x, false);
+ return new Array2DRowRealMatrix(x, false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenDecompositionImpl.java Thu Jun 11 08:54:02 2009
@@ -139,7 +139,7 @@
private double[] imagEigenvalues;
/** Eigenvectors. */
- private RealVectorImpl[] eigenvectors;
+ private ArrayRealVector[] eigenvectors;
/** Cached value of V. */
private RealMatrix cachedV;
@@ -366,7 +366,7 @@
private double[] imagEigenvalues;
/** Eigenvectors. */
- private final RealVectorImpl[] eigenvectors;
+ private final ArrayRealVector[] eigenvectors;
/**
* Build a solver from decomposed matrix.
@@ -375,7 +375,7 @@
* @param eigenvectors eigenvectors
*/
private Solver(final double[] realEigenvalues, final double[] imagEigenvalues,
- final RealVectorImpl[] eigenvectors) {
+ final ArrayRealVector[] eigenvectors) {
this.realEigenvalues = realEigenvalues;
this.imagEigenvalues = imagEigenvalues;
this.eigenvectors = eigenvectors;
@@ -405,7 +405,7 @@
final double[] bp = new double[m];
for (int i = 0; i < m; ++i) {
- final RealVectorImpl v = eigenvectors[i];
+ final ArrayRealVector v = eigenvectors[i];
final double[] vData = v.getDataRef();
final double s = v.dotProduct(b) / realEigenvalues[i];
for (int j = 0; j < m; ++j) {
@@ -441,7 +441,7 @@
final double[] bp = new double[m];
for (int i = 0; i < m; ++i) {
- final RealVectorImpl v = eigenvectors[i];
+ final ArrayRealVector v = eigenvectors[i];
final double[] vData = v.getDataRef();
final double s = v.dotProduct(b) / realEigenvalues[i];
for (int j = 0; j < m; ++j) {
@@ -449,7 +449,7 @@
}
}
- return new RealVectorImpl(bp, false);
+ return new ArrayRealVector(bp, false);
}
@@ -479,7 +479,7 @@
final double[][] bp = new double[m][nColB];
for (int k = 0; k < nColB; ++k) {
for (int i = 0; i < m; ++i) {
- final RealVectorImpl v = eigenvectors[i];
+ final ArrayRealVector v = eigenvectors[i];
final double[] vData = v.getDataRef();
double s = 0;
for (int j = 0; j < m; ++j) {
@@ -1687,7 +1687,7 @@
private void findEigenVectors() {
final int m = main.length;
- eigenvectors = new RealVectorImpl[m];
+ eigenvectors = new ArrayRealVector[m];
// perform an initial non-shifted LDLt decomposition
final double[] d = new double[m];
@@ -1718,7 +1718,7 @@
* @param l off-diagonal elements of the initial non-shifted L matrix
* @return an eigenvector
*/
- private RealVectorImpl findEigenvector(final double eigenvalue,
+ private ArrayRealVector findEigenvector(final double eigenvalue,
final double[] d, final double[] l) {
// compute the LDLt and UDUt decompositions of the
@@ -1765,8 +1765,8 @@
}
return (transformer == null) ?
- new RealVectorImpl(eigenvector, false) :
- new RealVectorImpl(transformer.getQ().operate(eigenvector), false);
+ new ArrayRealVector(eigenvector, false) :
+ new ArrayRealVector(transformer.getQ().operate(eigenvector), false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java Thu Jun 11 08:54:02 2009
@@ -155,7 +155,7 @@
public FieldMatrix<T> getL() {
if ((cachedL == null) && !singular) {
final int m = pivot.length;
- cachedL = new FieldMatrixImpl<T>(field, m, m);
+ cachedL = new Array2DRowFieldMatrix<T>(field, m, m);
for (int i = 0; i < m; ++i) {
final T[] luI = lu[i];
for (int j = 0; j < i; ++j) {
@@ -171,7 +171,7 @@
public FieldMatrix<T> getU() {
if ((cachedU == null) && !singular) {
final int m = pivot.length;
- cachedU = new FieldMatrixImpl<T>(field, m, m);
+ cachedU = new Array2DRowFieldMatrix<T>(field, m, m);
for (int i = 0; i < m; ++i) {
final T[] luI = lu[i];
for (int j = i; j < m; ++j) {
@@ -186,7 +186,7 @@
public FieldMatrix<T> getP() {
if ((cachedP == null) && !singular) {
final int m = pivot.length;
- cachedP = new FieldMatrixImpl<T>(field, m, m);
+ cachedP = new Array2DRowFieldMatrix<T>(field, m, m);
for (int i = 0; i < m; ++i) {
cachedP.setEntry(i, pivot[i], field.getOne());
}
@@ -304,7 +304,7 @@
public FieldVector<T> solve(FieldVector<T> b)
throws IllegalArgumentException, InvalidMatrixException {
try {
- return solve((FieldVectorImpl<T>) b);
+ return solve((ArrayFieldVector<T>) b);
} catch (ClassCastException cce) {
final int m = pivot.length;
@@ -341,7 +341,7 @@
}
}
- return new FieldVectorImpl<T>(bp, false);
+ return new ArrayFieldVector<T>(bp, false);
}
}
@@ -353,9 +353,9 @@
* @exception IllegalArgumentException if matrices dimensions don't match
* @exception InvalidMatrixException if decomposed matrix is singular
*/
- public FieldVectorImpl<T> solve(FieldVectorImpl<T> b)
+ public ArrayFieldVector<T> solve(ArrayFieldVector<T> b)
throws IllegalArgumentException, InvalidMatrixException {
- return new FieldVectorImpl<T>(solve(b.getDataRef()), false);
+ return new ArrayFieldVector<T>(solve(b.getDataRef()), false);
}
/** {@inheritDoc} */
@@ -413,7 +413,7 @@
}
}
- return new FieldMatrixImpl<T>(bp, false);
+ return new Array2DRowFieldMatrix<T>(bp, false);
}
@@ -421,7 +421,7 @@
public FieldMatrix<T> getInverse() throws InvalidMatrixException {
final int m = pivot.length;
final T one = field.getOne();
- FieldMatrix<T> identity = new FieldMatrixImpl<T>(field, m, m);
+ FieldMatrix<T> identity = new Array2DRowFieldMatrix<T>(field, m, m);
for (int i = 0; i < m; ++i) {
identity.setEntry(i, i, one);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/LUDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/LUDecompositionImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/LUDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/LUDecompositionImpl.java Thu Jun 11 08:54:02 2009
@@ -301,7 +301,7 @@
public RealVector solve(RealVector b)
throws IllegalArgumentException, InvalidMatrixException {
try {
- return solve((RealVectorImpl) b);
+ return solve((ArrayRealVector) b);
} catch (ClassCastException cce) {
final int m = pivot.length;
@@ -338,7 +338,7 @@
}
}
- return new RealVectorImpl(bp, false);
+ return new ArrayRealVector(bp, false);
}
}
@@ -350,9 +350,9 @@
* @exception IllegalArgumentException if matrices dimensions don't match
* @exception InvalidMatrixException if decomposed matrix is singular
*/
- public RealVectorImpl solve(RealVectorImpl b)
+ public ArrayRealVector solve(ArrayRealVector b)
throws IllegalArgumentException, InvalidMatrixException {
- return new RealVectorImpl(solve(b.getDataRef()), false);
+ return new ArrayRealVector(solve(b.getDataRef()), false);
}
/** {@inheritDoc} */
@@ -409,7 +409,7 @@
}
}
- return new RealMatrixImpl(bp, false);
+ return new Array2DRowRealMatrix(bp, false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/MatrixUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/MatrixUtils.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/MatrixUtils.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/MatrixUtils.java Thu Jun 11 08:54:02 2009
@@ -49,7 +49,7 @@
* <p>The type of matrix returned depends on the dimension. Below
* 2<sup>12</sup> elements (i.e. 4096 elements or 64×64 for a
* square matrix) which can be stored in a 32kB array, a {@link
- * RealMatrixImpl} instance is built. Above this threshold a {@link
+ * Array2DRowRealMatrix} instance is built. Above this threshold a {@link
* BlockRealMatrix} instance is built.</p>
* <p>The matrix elements are all set to 0.0.</p>
* @param rows number of rows of the matrix
@@ -59,7 +59,7 @@
*/
public static RealMatrix createRealMatrix(final int rows, final int columns) {
return (rows * columns <= 4096) ?
- new RealMatrixImpl(rows, columns) : new BlockRealMatrix(rows, columns);
+ new Array2DRowRealMatrix(rows, columns) : new BlockRealMatrix(rows, columns);
}
/**
@@ -81,7 +81,7 @@
final int rows,
final int columns) {
return (rows * columns <= 4096) ?
- new FieldMatrixImpl<T>(field, rows, columns) : new BlockFieldMatrix<T>(field, rows, columns);
+ new Array2DRowFieldMatrix<T>(field, rows, columns) : new BlockFieldMatrix<T>(field, rows, columns);
}
/**
@@ -90,7 +90,7 @@
* <p>The type of matrix returned depends on the dimension. Below
* 2<sup>12</sup> elements (i.e. 4096 elements or 64×64 for a
* square matrix) which can be stored in a 32kB array, a {@link
- * RealMatrixImpl} instance is built. Above this threshold a {@link
+ * Array2DRowRealMatrix} instance is built. Above this threshold a {@link
* BlockRealMatrix} instance is built.</p>
* <p>The input array is copied, not referenced.</p>
*
@@ -104,7 +104,7 @@
*/
public static RealMatrix createRealMatrix(double[][] data) {
return (data.length * data[0].length <= 4096) ?
- new RealMatrixImpl(data) : new BlockRealMatrix(data);
+ new Array2DRowRealMatrix(data) : new BlockRealMatrix(data);
}
/**
@@ -127,7 +127,7 @@
*/
public static <T extends FieldElement<T>> FieldMatrix<T> createFieldMatrix(T[][] data) {
return (data.length * data[0].length <= 4096) ?
- new FieldMatrixImpl<T>(data) : new BlockFieldMatrix<T>(data);
+ new Array2DRowFieldMatrix<T>(data) : new BlockFieldMatrix<T>(data);
}
/**
@@ -167,7 +167,7 @@
Arrays.fill(dRow, zero);
dRow[row] = one;
}
- return new FieldMatrixImpl<T>(d, false);
+ return new Array2DRowFieldMatrix<T>(d, false);
}
/**
@@ -304,7 +304,7 @@
* @throws NullPointerException if <code>data</code>is null
*/
public static RealVector createRealVector(double[] data) {
- return new RealVectorImpl(data, true);
+ return new ArrayRealVector(data, true);
}
/**
@@ -317,7 +317,7 @@
* @throws NullPointerException if <code>data</code>is null
*/
public static <T extends FieldElement<T>> FieldVector<T> createFieldVector(final T[] data) {
- return new FieldVectorImpl<T>(data, true);
+ return new ArrayFieldVector<T>(data, true);
}
/**
@@ -694,7 +694,7 @@
* @return converted matrix
*/
RealMatrix getConvertedMatrix() {
- return new RealMatrixImpl(data, false);
+ return new Array2DRowRealMatrix(data, false);
}
}
@@ -738,7 +738,7 @@
* @return converted matrix
*/
RealMatrix getConvertedMatrix() {
- return new RealMatrixImpl(data, false);
+ return new Array2DRowRealMatrix(data, false);
}
}
@@ -824,7 +824,7 @@
}
// create the instance
- final RealVector vector = new RealVectorImpl(data, false);
+ final RealVector vector = new ArrayRealVector(data, false);
// set up the field
final java.lang.reflect.Field f =
@@ -933,7 +933,7 @@
}
// create the instance
- final RealMatrix matrix = new RealMatrixImpl(data, false);
+ final RealMatrix matrix = new Array2DRowRealMatrix(data, false);
// set up the field
final java.lang.reflect.Field f =
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/QRDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/QRDecompositionImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/QRDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/QRDecompositionImpl.java Thu Jun 11 08:54:02 2009
@@ -335,9 +335,9 @@
public RealVector solve(RealVector b)
throws IllegalArgumentException, InvalidMatrixException {
try {
- return solve((RealVectorImpl) b);
+ return solve((ArrayRealVector) b);
} catch (ClassCastException cce) {
- return new RealVectorImpl(solve(b.getData()), false);
+ return new ArrayRealVector(solve(b.getData()), false);
}
}
@@ -348,9 +348,9 @@
* @throws IllegalArgumentException if matrices dimensions don't match
* @throws InvalidMatrixException if decomposed matrix is singular
*/
- public RealVectorImpl solve(RealVectorImpl b)
+ public ArrayRealVector solve(ArrayRealVector b)
throws IllegalArgumentException, InvalidMatrixException {
- return new RealVectorImpl(solve(b.getDataRef()), false);
+ return new ArrayRealVector(solve(b.getDataRef()), false);
}
/** {@inheritDoc} */
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealMatrixImpl.java Thu Jun 11 08:54:02 2009
@@ -48,7 +48,9 @@
* </p>
*
* @version $Revision$ $Date$
+ * @deprecated as of 2.0 replaced by {@link Array2DRowRealMatrix}
*/
+@Deprecated
public class RealMatrixImpl extends AbstractRealMatrix implements Serializable {
/** Serializable version identifier */
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorFormat.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorFormat.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorFormat.java Thu Jun 11 08:54:02 2009
@@ -258,9 +258,9 @@
* @exception ParseException if the beginning of the specified string
* cannot be parsed.
*/
- public RealVectorImpl parse(String source) throws ParseException {
+ public ArrayRealVector parse(String source) throws ParseException {
ParsePosition parsePosition = new ParsePosition(0);
- RealVectorImpl result = parse(source, parsePosition);
+ ArrayRealVector result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw MathRuntimeException.createParseException(
parsePosition.getErrorIndex(),
@@ -275,7 +275,7 @@
* @param pos input/ouput parsing parameter.
* @return the parsed {@link RealVector} object.
*/
- public RealVectorImpl parse(String source, ParsePosition pos) {
+ public ArrayRealVector parse(String source, ParsePosition pos) {
int initialIndex = pos.getIndex();
// parse prefix
@@ -321,7 +321,7 @@
for (int i = 0; i < data.length; ++i) {
data[i] = components.get(i).doubleValue();
}
- return new RealVectorImpl(data, false);
+ return new ArrayRealVector(data, false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java Thu Jun 11 08:54:02 2009
@@ -30,11 +30,11 @@
import org.apache.commons.math.linear.DefaultRealMatrixChangingVisitor;
import org.apache.commons.math.linear.FieldLUDecompositionImpl;
import org.apache.commons.math.linear.FieldMatrix;
-import org.apache.commons.math.linear.FieldMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowFieldMatrix;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.MatrixVisitorException;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
@@ -337,7 +337,7 @@
}
}
- return coefficients.msToN.multiply(new RealMatrixImpl(multistep, false));
+ return coefficients.msToN.multiply(new Array2DRowRealMatrix(multistep, false));
}
@@ -411,7 +411,7 @@
shiftedP[0] = new BigFraction[order - 1];
Arrays.fill(shiftedP[0], BigFraction.ZERO);
FieldMatrix<BigFraction> bigMSupdate =
- bigMStoN.multiply(new FieldMatrixImpl<BigFraction>(shiftedP, false));
+ bigMStoN.multiply(new Array2DRowFieldMatrix<BigFraction>(shiftedP, false));
// convert coefficients to double
msToN = MatrixUtils.bigFractionMatrixToRealMatrix(bigMStoN);
@@ -452,7 +452,7 @@
}
}
- return new FieldMatrixImpl<BigFraction>(pData, false);
+ return new Array2DRowFieldMatrix<BigFraction>(pData, false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java Thu Jun 11 08:54:02 2009
@@ -30,11 +30,11 @@
import org.apache.commons.math.linear.DefaultRealMatrixChangingVisitor;
import org.apache.commons.math.linear.FieldLUDecompositionImpl;
import org.apache.commons.math.linear.FieldMatrix;
-import org.apache.commons.math.linear.FieldMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowFieldMatrix;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.MatrixVisitorException;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealMatrixPreservingVisitor;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
@@ -398,7 +398,7 @@
}
}
- return coefficients.msToN.multiply(new RealMatrixImpl(multistep, false));
+ return coefficients.msToN.multiply(new Array2DRowRealMatrix(multistep, false));
}
@@ -527,7 +527,7 @@
shiftedP[0] = new BigFraction[order - 1];
Arrays.fill(shiftedP[0], BigFraction.ZERO);
FieldMatrix<BigFraction> bigMSupdate =
- bigMStoN.multiply(new FieldMatrixImpl<BigFraction>(shiftedP, false));
+ bigMStoN.multiply(new Array2DRowFieldMatrix<BigFraction>(shiftedP, false));
// convert coefficients to double
msToN = MatrixUtils.bigFractionMatrixToRealMatrix(bigMStoN);
@@ -568,7 +568,7 @@
}
}
- return new FieldMatrixImpl<BigFraction>(pData, false);
+ return new Array2DRowFieldMatrix<BigFraction>(pData, false);
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java Thu Jun 11 08:54:02 2009
@@ -23,7 +23,7 @@
import java.util.Arrays;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealMatrixPreservingVisitor;
/**
@@ -251,7 +251,7 @@
nI[j] = in.readDouble();
}
}
- nordsieck = new RealMatrixImpl(nData, false);
+ nordsieck = new Array2DRowRealMatrix(nData, false);
} else {
nordsieck = null;
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearConstraint.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearConstraint.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearConstraint.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearConstraint.java Thu Jun 11 08:54:02 2009
@@ -24,7 +24,7 @@
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealVector;
-import org.apache.commons.math.linear.RealVectorImpl;
+import org.apache.commons.math.linear.ArrayRealVector;
/**
@@ -78,7 +78,7 @@
*/
public LinearConstraint(final double[] coefficients, final Relationship relationship,
final double value) {
- this(new RealVectorImpl(coefficients), relationship, value);
+ this(new ArrayRealVector(coefficients), relationship, value);
}
/**
@@ -128,7 +128,7 @@
for (int i = 0; i < sub.length; ++i) {
sub[i] = lhsCoefficients[i] - rhsCoefficients[i];
}
- this.coefficients = new RealVectorImpl(sub, false);
+ this.coefficients = new ArrayRealVector(sub, false);
this.relationship = relationship;
this.value = rhsConstant - lhsConstant;
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearObjectiveFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearObjectiveFunction.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearObjectiveFunction.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/LinearObjectiveFunction.java Thu Jun 11 08:54:02 2009
@@ -24,7 +24,7 @@
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealVector;
-import org.apache.commons.math.linear.RealVectorImpl;
+import org.apache.commons.math.linear.ArrayRealVector;
/**
* An objective function for a linear optimization problem.
@@ -55,7 +55,7 @@
* @param constantTerm The constant term of the linear equation
*/
public LinearObjectiveFunction(double[] coefficients, double constantTerm) {
- this(new RealVectorImpl(coefficients), constantTerm);
+ this(new ArrayRealVector(coefficients), constantTerm);
}
/**
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java Thu Jun 11 08:54:02 2009
@@ -29,7 +29,7 @@
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealVector;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.RealPointValuePair;
@@ -111,7 +111,7 @@
getConstraintTypeCounts(Relationship.GEQ);
this.numArtificialVariables = getConstraintTypeCounts(Relationship.EQ) +
getConstraintTypeCounts(Relationship.GEQ);
- this.tableau = new RealMatrixImpl(createTableau(goalType == GoalType.MAXIMIZE));
+ this.tableau = new Array2DRowRealMatrix(createTableau(goalType == GoalType.MAXIMIZE));
initialize();
}
@@ -297,7 +297,7 @@
}
matrix[i][width - 1] = getEntry(i + 1, getRhsOffset());
}
- this.tableau = new RealMatrixImpl(matrix);
+ this.tableau = new Array2DRowRealMatrix(matrix);
this.numArtificialVariables = 0;
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java Thu Jun 11 08:54:02 2009
@@ -18,9 +18,9 @@
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealVector;
-import org.apache.commons.math.linear.RealVectorImpl;
+import org.apache.commons.math.linear.ArrayRealVector;
/**
* Abstract base class for implementations of MultipleLinearRegression.
@@ -55,8 +55,8 @@
x[i][j] = data[pointer++];
}
}
- this.X = new RealMatrixImpl(x);
- this.Y = new RealVectorImpl(y);
+ this.X = new Array2DRowRealMatrix(x);
+ this.Y = new ArrayRealVector(y);
}
/**
@@ -65,7 +65,7 @@
* @param y the [n,1] array representing the y sample
*/
protected void newYSampleData(double[] y) {
- this.Y = new RealVectorImpl(y);
+ this.Y = new ArrayRealVector(y);
}
/**
@@ -74,7 +74,7 @@
* @param x the [n,k] array representing the x sample
*/
protected void newXSampleData(double[][] x) {
- this.X = new RealMatrixImpl(x);
+ this.X = new Array2DRowRealMatrix(x);
}
/**
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java Thu Jun 11 08:54:02 2009
@@ -18,7 +18,7 @@
import org.apache.commons.math.linear.LUDecompositionImpl;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealVector;
@@ -68,7 +68,7 @@
* @param omega the [n,n] array representing the covariance
*/
protected void newCovarianceData(double[][] omega){
- this.Omega = new RealMatrixImpl(omega);
+ this.Omega = new Array2DRowRealMatrix(omega);
this.OmegaInverse = null;
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java Thu Jun 11 08:54:02 2009
@@ -21,9 +21,9 @@
import org.apache.commons.math.linear.QRDecomposition;
import org.apache.commons.math.linear.QRDecompositionImpl;
import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.linear.RealMatrixImpl;
+import org.apache.commons.math.linear.Array2DRowRealMatrix;
import org.apache.commons.math.linear.RealVector;
-import org.apache.commons.math.linear.RealVectorImpl;
+import org.apache.commons.math.linear.ArrayRealVector;
/**
* <p>Implements ordinary least squares (OLS) to estimate the parameters of a
@@ -107,7 +107,7 @@
RealMatrix Q = qr.getQ();
final int p = qr.getR().getColumnDimension();
final int n = Q.getColumnDimension();
- RealMatrixImpl augI = new RealMatrixImpl(n, n);
+ Array2DRowRealMatrix augI = new Array2DRowRealMatrix(n, n);
double[][] augIData = augI.getDataRef();
for (int i = 0; i < n; i++) {
for (int j =0; j < n; j++) {
@@ -130,7 +130,7 @@
*/
@Override
protected void newXSampleData(double[][] x) {
- this.X = new RealMatrixImpl(x);
+ this.X = new Array2DRowRealMatrix(x);
qr = new QRDecompositionImpl(X);
}
@@ -211,7 +211,7 @@
}
x[index] = (constants.getEntry(index) - sum) / coefficients.getEntry(index, index);
}
- return new RealVectorImpl(x);
+ return new ArrayRealVector(x);
}
/**
Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Thu Jun 11 08:54:02 2009
@@ -84,6 +84,11 @@
FieldLUDecomposition)
</action>
<action dev="luc" type="add" >
+ The RealMatrixImpl implementation classes has been renamed Array2DRowRealMatrix
+ to reflect its specificities and for consistency with the new implementations. The
+ previous name is still available but is deprecated
+ </action>
+ <action dev="luc" type="add" >
Added a block-based storage type for dense matrices improving speed for large dimensions
</action>
<action dev="psteitz" type="add" due-to="John Bollinger">
Modified: commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml?rev=783702&r1=783701&r2=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml Thu Jun 11 08:54:02 2009
@@ -53,11 +53,11 @@
<source>
// Create a real matrix with two rows and three columns
double[][] matrixData = { {1d,2d,3d}, {2d,5d,3d}};
-RealMatrix m = new RealMatrixImpl(matrixData);
+RealMatrix m = new Array2DRowRealMatrix(matrixData);
// One more with three rows, two columns
double[][] matrixData2 = { {1d,2d}, {2d,5d}, {1d, 7d}};
-RealMatrix n = new RealMatrixImpl(matrixData2);
+RealMatrix n = new Array2DRowRealMatrix(matrixData2);
// Note: The constructor copies the input double[][] array.
@@ -72,8 +72,8 @@
</p>
<p>
The three main implementations of the interface are <a
- href="../apidocs/org/apache/commons/math/linear/RealMatrixImpl.html">
- RealMatrixImpl</a> and <a
+ href="../apidocs/org/apache/commons/math/linear/Array2DRowRealMatrix.html">
+ Array2DRowRealMatrix</a> and <a
href="../apidocs/org/apache/commons/math/linear/BlockRealMatrix.html">
BlockRealMatrix</a> for dense matrices (the second one being more suited to
dimensions above 50 or 100) and <a
@@ -124,7 +124,7 @@
and build a solver
<source>
RealMatrix coefficients =
- new RealMatrixImpl(new double[][] { { 2, 3, -2 }, { -1, 7, 6 }, { 4, -3, -5 } },
+ new Array2DRowRealMatrix(new double[][] { { 2, 3, -2 }, { -1, 7, 6 }, { 4, -3, -5 } },
false);
DecompositionSolver solver = new LUDecompositionImpl(coefficients).getSolver();
</source>
Copied: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java (from r783662, commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java?p2=commons/proper/math/trunk/src/test/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java&p1=commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java&r1=783662&r2=783702&rev=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java Thu Jun 11 08:54:02 2009
@@ -23,12 +23,12 @@
import org.apache.commons.math.TestUtils;
/**
- * Test cases for the {@link RealMatrixImpl} class.
+ * Test cases for the {@link Array2DRowRealMatrix} class.
*
* @version $Revision$ $Date$
*/
-public final class RealMatrixImplTest extends TestCase {
+public final class Array2DRowRealMatrixTest extends TestCase {
// 3 x 3 identity matrix
protected double[][] id = { {1d,0d,0d}, {0d,1d,0d}, {0d,0d,1d} };
@@ -90,20 +90,20 @@
protected double entryTolerance = 10E-16;
protected double normTolerance = 10E-14;
- public RealMatrixImplTest(String name) {
+ public Array2DRowRealMatrixTest(String name) {
super(name);
}
public static Test suite() {
- TestSuite suite = new TestSuite(RealMatrixImplTest.class);
- suite.setName("RealMatrixImpl Tests");
+ TestSuite suite = new TestSuite(Array2DRowRealMatrixTest.class);
+ suite.setName("Array2DRowRealMatrix Tests");
return suite;
}
/** test dimensions */
public void testDimensions() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(testData2);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
assertEquals("testData row dimension",3,m.getRowDimension());
assertEquals("testData column dimension",3,m.getColumnDimension());
assertTrue("testData is square",m.isSquare());
@@ -114,18 +114,18 @@
/** test copy functions */
public void testCopyFunctions() {
- RealMatrixImpl m1 = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(m1.getData());
+ Array2DRowRealMatrix m1 = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(m1.getData());
assertEquals(m2,m1);
- RealMatrixImpl m3 = new RealMatrixImpl(testData);
- RealMatrixImpl m4 = new RealMatrixImpl(m3.getData(), false);
+ Array2DRowRealMatrix m3 = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m4 = new Array2DRowRealMatrix(m3.getData(), false);
assertEquals(m4,m3);
}
/** test add */
public void testAdd() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl mInv = new RealMatrixImpl(testDataInv);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix mInv = new Array2DRowRealMatrix(testDataInv);
RealMatrix mPlusMInv = m.add(mInv);
double[][] sumEntries = mPlusMInv.getData();
for (int row = 0; row < m.getRowDimension(); row++) {
@@ -139,8 +139,8 @@
/** test add failure */
public void testAddFail() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(testData2);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
try {
m.add(m2);
fail("IllegalArgumentException expected");
@@ -151,28 +151,28 @@
/** test norm */
public void testNorm() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(testData2);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
assertEquals("testData norm",14d,m.getNorm(),entryTolerance);
assertEquals("testData2 norm",7d,m2.getNorm(),entryTolerance);
}
/** test Frobenius norm */
public void testFrobeniusNorm() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(testData2);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
assertEquals("testData Frobenius norm", Math.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
assertEquals("testData2 Frobenius norm", Math.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
}
/** test m-n = m + -n */
public void testPlusMinus() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m2 = new RealMatrixImpl(testDataInv);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testDataInv);
TestUtils.assertEquals("m-n = m + -n",m.subtract(m2),
m2.scalarMultiply(-1d).add(m),entryTolerance);
try {
- m.subtract(new RealMatrixImpl(testData2));
+ m.subtract(new Array2DRowRealMatrix(testData2));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
@@ -181,10 +181,10 @@
/** test multiply */
public void testMultiply() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl mInv = new RealMatrixImpl(testDataInv);
- RealMatrixImpl identity = new RealMatrixImpl(id);
- RealMatrixImpl m2 = new RealMatrixImpl(testData2);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix mInv = new Array2DRowRealMatrix(testDataInv);
+ Array2DRowRealMatrix identity = new Array2DRowRealMatrix(id);
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
TestUtils.assertEquals("inverse multiply",m.multiply(mInv),
identity,entryTolerance);
TestUtils.assertEquals("inverse multiply",mInv.multiply(m),
@@ -196,31 +196,31 @@
TestUtils.assertEquals("identity multiply",m2.multiply(identity),
m2,entryTolerance);
try {
- m.multiply(new RealMatrixImpl(bigSingular));
+ m.multiply(new Array2DRowRealMatrix(bigSingular));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
}
}
- //Additional Test for RealMatrixImplTest.testMultiply
+ //Additional Test for Array2DRowRealMatrixTest.testMultiply
private double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
private double[][] d4 = new double[][] {{1},{2},{3},{4}};
private double[][] d5 = new double[][] {{30},{70}};
public void testMultiply2() {
- RealMatrix m3 = new RealMatrixImpl(d3);
- RealMatrix m4 = new RealMatrixImpl(d4);
- RealMatrix m5 = new RealMatrixImpl(d5);
+ RealMatrix m3 = new Array2DRowRealMatrix(d3);
+ RealMatrix m4 = new Array2DRowRealMatrix(d4);
+ RealMatrix m5 = new Array2DRowRealMatrix(d5);
TestUtils.assertEquals("m3*m4=m5", m3.multiply(m4), m5, entryTolerance);
}
/** test trace */
public void testTrace() {
- RealMatrix m = new RealMatrixImpl(id);
+ RealMatrix m = new Array2DRowRealMatrix(id);
assertEquals("identity trace",3d,m.getTrace(),entryTolerance);
- m = new RealMatrixImpl(testData2);
+ m = new Array2DRowRealMatrix(testData2);
try {
m.getTrace();
fail("Expecting NonSquareMatrixException");
@@ -231,19 +231,19 @@
/** test sclarAdd */
public void testScalarAdd() {
- RealMatrix m = new RealMatrixImpl(testData);
- TestUtils.assertEquals("scalar add",new RealMatrixImpl(testDataPlus2),
+ RealMatrix m = new Array2DRowRealMatrix(testData);
+ TestUtils.assertEquals("scalar add",new Array2DRowRealMatrix(testDataPlus2),
m.scalarAdd(2d),entryTolerance);
}
/** test operate */
public void testOperate() {
- RealMatrix m = new RealMatrixImpl(id);
+ RealMatrix m = new Array2DRowRealMatrix(id);
TestUtils.assertEquals("identity operate", testVector,
m.operate(testVector), entryTolerance);
TestUtils.assertEquals("identity operate", testVector,
- m.operate(new RealVectorImpl(testVector)).getData(), entryTolerance);
- m = new RealMatrixImpl(bigSingular);
+ m.operate(new ArrayRealVector(testVector)).getData(), entryTolerance);
+ m = new Array2DRowRealMatrix(bigSingular);
try {
m.operate(testVector);
fail("Expecting illegalArgumentException");
@@ -254,7 +254,7 @@
/** test issue MATH-209 */
public void testMath209() {
- RealMatrix a = new RealMatrixImpl(new double[][] {
+ RealMatrix a = new Array2DRowRealMatrix(new double[][] {
{ 1, 2 }, { 3, 4 }, { 5, 6 }
}, false);
double[] b = a.operate(new double[] { 1, 1 });
@@ -266,23 +266,23 @@
/** test transpose */
public void testTranspose() {
- RealMatrix m = new RealMatrixImpl(testData);
+ RealMatrix m = new Array2DRowRealMatrix(testData);
RealMatrix mIT = new LUDecompositionImpl(m).getSolver().getInverse().transpose();
RealMatrix mTI = new LUDecompositionImpl(m.transpose()).getSolver().getInverse();
TestUtils.assertEquals("inverse-transpose", mIT, mTI, normTolerance);
- m = new RealMatrixImpl(testData2);
- RealMatrix mt = new RealMatrixImpl(testData2T);
+ m = new Array2DRowRealMatrix(testData2);
+ RealMatrix mt = new Array2DRowRealMatrix(testData2T);
TestUtils.assertEquals("transpose",mt,m.transpose(),normTolerance);
}
/** test preMultiply by vector */
public void testPremultiplyVector() {
- RealMatrix m = new RealMatrixImpl(testData);
+ RealMatrix m = new Array2DRowRealMatrix(testData);
TestUtils.assertEquals("premultiply", m.preMultiply(testVector),
preMultTest, normTolerance);
- TestUtils.assertEquals("premultiply", m.preMultiply(new RealVectorImpl(testVector).getData()),
+ TestUtils.assertEquals("premultiply", m.preMultiply(new ArrayRealVector(testVector).getData()),
preMultTest, normTolerance);
- m = new RealMatrixImpl(bigSingular);
+ m = new Array2DRowRealMatrix(bigSingular);
try {
m.preMultiply(testVector);
fail("expecting IllegalArgumentException");
@@ -292,14 +292,14 @@
}
public void testPremultiply() {
- RealMatrix m3 = new RealMatrixImpl(d3);
- RealMatrix m4 = new RealMatrixImpl(d4);
- RealMatrix m5 = new RealMatrixImpl(d5);
+ RealMatrix m3 = new Array2DRowRealMatrix(d3);
+ RealMatrix m4 = new Array2DRowRealMatrix(d4);
+ RealMatrix m5 = new Array2DRowRealMatrix(d5);
TestUtils.assertEquals("m3*m4=m5", m4.preMultiply(m3), m5, entryTolerance);
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl mInv = new RealMatrixImpl(testDataInv);
- RealMatrixImpl identity = new RealMatrixImpl(id);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix mInv = new Array2DRowRealMatrix(testDataInv);
+ Array2DRowRealMatrix identity = new Array2DRowRealMatrix(id);
TestUtils.assertEquals("inverse multiply",m.preMultiply(mInv),
identity,entryTolerance);
TestUtils.assertEquals("inverse multiply",mInv.preMultiply(m),
@@ -309,7 +309,7 @@
TestUtils.assertEquals("identity multiply",identity.preMultiply(mInv),
mInv,entryTolerance);
try {
- m.preMultiply(new RealMatrixImpl(bigSingular));
+ m.preMultiply(new Array2DRowRealMatrix(bigSingular));
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
// ignored
@@ -317,7 +317,7 @@
}
public void testGetVectors() {
- RealMatrix m = new RealMatrixImpl(testData);
+ RealMatrix m = new Array2DRowRealMatrix(testData);
TestUtils.assertEquals("get row",m.getRow(0),testDataRow1,entryTolerance);
TestUtils.assertEquals("get col",m.getColumn(2),testDataCol3,entryTolerance);
try {
@@ -335,7 +335,7 @@
}
public void testGetEntry() {
- RealMatrix m = new RealMatrixImpl(testData);
+ RealMatrix m = new Array2DRowRealMatrix(testData);
assertEquals("get entry",m.getEntry(0,1),2d,entryTolerance);
try {
m.getEntry(10, 4);
@@ -349,10 +349,10 @@
public void testExamples() {
// Create a real matrix with two rows and three columns
double[][] matrixData = { {1d,2d,3d}, {2d,5d,3d}};
- RealMatrix m = new RealMatrixImpl(matrixData);
+ RealMatrix m = new Array2DRowRealMatrix(matrixData);
// One more with three rows, two columns
double[][] matrixData2 = { {1d,2d}, {2d,5d}, {1d, 7d}};
- RealMatrix n = new RealMatrixImpl(matrixData2);
+ RealMatrix n = new Array2DRowRealMatrix(matrixData2);
// Now multiply m by n
RealMatrix p = m.multiply(n);
assertEquals(2, p.getRowDimension());
@@ -364,7 +364,7 @@
// Solve example
double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}};
- RealMatrix coefficients = new RealMatrixImpl(coefficientsData);
+ RealMatrix coefficients = new Array2DRowRealMatrix(coefficientsData);
double[] constants = {1, -2, 1};
double[] solution = new LUDecompositionImpl(coefficients).getSolver().solve(constants);
assertEquals(2 * solution[0] + 3 * solution[1] -2 * solution[2], constants[0], 1E-12);
@@ -375,7 +375,7 @@
// test submatrix accessors
public void testGetSubMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
checkGetSubMatrix(m, subRows23Cols00, 2 , 3 , 0, 0, false);
checkGetSubMatrix(m, subRows00Cols33, 0 , 0 , 3, 3, false);
checkGetSubMatrix(m, subRows01Cols23, 0 , 1 , 2, 3, false);
@@ -398,7 +398,7 @@
boolean mustFail) {
try {
RealMatrix sub = m.getSubMatrix(startRow, endRow, startColumn, endColumn);
- assertEquals(new RealMatrixImpl(reference), sub);
+ assertEquals(new Array2DRowRealMatrix(reference), sub);
if (mustFail) {
fail("Expecting MatrixIndexException");
}
@@ -414,7 +414,7 @@
boolean mustFail) {
try {
RealMatrix sub = m.getSubMatrix(selectedRows, selectedColumns);
- assertEquals(new RealMatrixImpl(reference), sub);
+ assertEquals(new Array2DRowRealMatrix(reference), sub);
if (mustFail) {
fail("Expecting MatrixIndexException");
}
@@ -426,7 +426,7 @@
}
public void testCopySubMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
checkCopy(m, subRows23Cols00, 2 , 3 , 0, 0, false);
checkCopy(m, subRows00Cols33, 0 , 0 , 3, 3, false);
checkCopy(m, subRows01Cols23, 0 , 1 , 2, 3, false);
@@ -453,7 +453,7 @@
new double[1][1] :
new double[reference.length][reference[0].length];
m.copySubMatrix(startRow, endRow, startColumn, endColumn, sub);
- assertEquals(new RealMatrixImpl(reference), new RealMatrixImpl(sub));
+ assertEquals(new Array2DRowRealMatrix(reference), new Array2DRowRealMatrix(sub));
if (mustFail) {
fail("Expecting MatrixIndexException");
}
@@ -472,7 +472,7 @@
new double[1][1] :
new double[reference.length][reference[0].length];
m.copySubMatrix(selectedRows, selectedColumns, sub);
- assertEquals(new RealMatrixImpl(reference), new RealMatrixImpl(sub));
+ assertEquals(new Array2DRowRealMatrix(reference), new Array2DRowRealMatrix(sub));
if (mustFail) {
fail("Expecting MatrixIndexException");
}
@@ -484,9 +484,9 @@
}
public void testGetRowMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealMatrix mRow0 = new RealMatrixImpl(subRow0);
- RealMatrix mRow3 = new RealMatrixImpl(subRow3);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealMatrix mRow0 = new Array2DRowRealMatrix(subRow0);
+ RealMatrix mRow3 = new Array2DRowRealMatrix(subRow3);
assertEquals("Row0", mRow0,
m.getRowMatrix(0));
assertEquals("Row3", mRow3,
@@ -506,8 +506,8 @@
}
public void testSetRowMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealMatrix mRow3 = new RealMatrixImpl(subRow3);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealMatrix mRow3 = new Array2DRowRealMatrix(subRow3);
assertNotSame(mRow3, m.getRowMatrix(0));
m.setRowMatrix(0, mRow3);
assertEquals(mRow3, m.getRowMatrix(0));
@@ -526,9 +526,9 @@
}
public void testGetColumnMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealMatrix mColumn1 = new RealMatrixImpl(subColumn1);
- RealMatrix mColumn3 = new RealMatrixImpl(subColumn3);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealMatrix mColumn1 = new Array2DRowRealMatrix(subColumn1);
+ RealMatrix mColumn3 = new Array2DRowRealMatrix(subColumn3);
assertEquals("Column1", mColumn1,
m.getColumnMatrix(1));
assertEquals("Column3", mColumn3,
@@ -548,8 +548,8 @@
}
public void testSetColumnMatrix() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealMatrix mColumn3 = new RealMatrixImpl(subColumn3);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealMatrix mColumn3 = new Array2DRowRealMatrix(subColumn3);
assertNotSame(mColumn3, m.getColumnMatrix(1));
m.setColumnMatrix(1, mColumn3);
assertEquals(mColumn3, m.getColumnMatrix(1));
@@ -568,9 +568,9 @@
}
public void testGetRowVector() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealVector mRow0 = new RealVectorImpl(subRow0[0]);
- RealVector mRow3 = new RealVectorImpl(subRow3[0]);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealVector mRow0 = new ArrayRealVector(subRow0[0]);
+ RealVector mRow3 = new ArrayRealVector(subRow3[0]);
assertEquals("Row0", mRow0, m.getRowVector(0));
assertEquals("Row3", mRow3, m.getRowVector(3));
try {
@@ -588,8 +588,8 @@
}
public void testSetRowVector() {
- RealMatrix m = new RealMatrixImpl(subTestData);
- RealVector mRow3 = new RealVectorImpl(subRow3[0]);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
+ RealVector mRow3 = new ArrayRealVector(subRow3[0]);
assertNotSame(mRow3, m.getRowMatrix(0));
m.setRowVector(0, mRow3);
assertEquals(mRow3, m.getRowVector(0));
@@ -600,7 +600,7 @@
// expected
}
try {
- m.setRowVector(0, new RealVectorImpl(5));
+ m.setRowVector(0, new ArrayRealVector(5));
fail("Expecting InvalidMatrixException");
} catch (InvalidMatrixException ex) {
// expected
@@ -608,7 +608,7 @@
}
public void testGetColumnVector() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
RealVector mColumn1 = columnToVector(subColumn1);
RealVector mColumn3 = columnToVector(subColumn3);
assertEquals("Column1", mColumn1, m.getColumnVector(1));
@@ -628,7 +628,7 @@
}
public void testSetColumnVector() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
RealVector mColumn3 = columnToVector(subColumn3);
assertNotSame(mColumn3, m.getColumnVector(1));
m.setColumnVector(1, mColumn3);
@@ -640,7 +640,7 @@
// expected
}
try {
- m.setColumnVector(0, new RealVectorImpl(5));
+ m.setColumnVector(0, new ArrayRealVector(5));
fail("Expecting InvalidMatrixException");
} catch (InvalidMatrixException ex) {
// expected
@@ -652,11 +652,11 @@
for (int i = 0; i < data.length; ++i) {
data[i] = column[i][0];
}
- return new RealVectorImpl(data, false);
+ return new ArrayRealVector(data, false);
}
public void testGetRow() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
checkArrays(subRow0[0], m.getRow(0));
checkArrays(subRow3[0], m.getRow(3));
try {
@@ -674,7 +674,7 @@
}
public void testSetRow() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
assertTrue(subRow3[0][0] != m.getRow(0)[0]);
m.setRow(0, subRow3[0]);
checkArrays(subRow3[0], m.getRow(0));
@@ -693,7 +693,7 @@
}
public void testGetColumn() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
double[] mColumn1 = columnToArray(subColumn1);
double[] mColumn3 = columnToArray(subColumn3);
checkArrays(mColumn1, m.getColumn(1));
@@ -713,7 +713,7 @@
}
public void testSetColumn() {
- RealMatrix m = new RealMatrixImpl(subTestData);
+ RealMatrix m = new Array2DRowRealMatrix(subTestData);
double[] mColumn3 = columnToArray(subColumn3);
assertTrue(mColumn3[0] != m.getColumn(1)[0]);
m.setColumn(1, mColumn3);
@@ -748,29 +748,29 @@
}
public void testEqualsAndHashCode() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- RealMatrixImpl m1 = (RealMatrixImpl) m.copy();
- RealMatrixImpl mt = (RealMatrixImpl) m.transpose();
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ Array2DRowRealMatrix m1 = (Array2DRowRealMatrix) m.copy();
+ Array2DRowRealMatrix mt = (Array2DRowRealMatrix) m.transpose();
assertTrue(m.hashCode() != mt.hashCode());
assertEquals(m.hashCode(), m1.hashCode());
assertEquals(m, m);
assertEquals(m, m1);
assertFalse(m.equals(null));
assertFalse(m.equals(mt));
- assertFalse(m.equals(new RealMatrixImpl(bigSingular)));
+ assertFalse(m.equals(new Array2DRowRealMatrix(bigSingular)));
}
public void testToString() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
- assertEquals("RealMatrixImpl{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
+ assertEquals("Array2DRowRealMatrix{{1.0,2.0,3.0},{2.0,5.0,3.0},{1.0,0.0,8.0}}",
m.toString());
- m = new RealMatrixImpl();
- assertEquals("RealMatrixImpl{}",
+ m = new Array2DRowRealMatrix();
+ assertEquals("Array2DRowRealMatrix{}",
m.toString());
}
public void testSetSubMatrix() throws Exception {
- RealMatrixImpl m = new RealMatrixImpl(testData);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
m.setSubMatrix(detData2,1,1);
RealMatrix expected = MatrixUtils.createRealMatrix
(new double[][] {{1.0,2.0,3.0},{2.0,1.0,3.0},{1.0,2.0,4.0}});
@@ -814,7 +814,7 @@
} catch (NullPointerException e) {
// expected
}
- RealMatrixImpl m2 = new RealMatrixImpl();
+ Array2DRowRealMatrix m2 = new Array2DRowRealMatrix();
try {
m2.setSubMatrix(testData,0,1);
fail("expecting IllegalStateException");
@@ -850,13 +850,13 @@
int rows = 150;
int columns = 75;
- RealMatrix m = new RealMatrixImpl(rows, columns);
+ RealMatrix m = new Array2DRowRealMatrix(rows, columns);
m.walkInRowOrder(new SetVisitor());
GetVisitor getVisitor = new GetVisitor();
m.walkInOptimizedOrder(getVisitor);
assertEquals(rows * columns, getVisitor.getCount());
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInRowOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2);
getVisitor = new GetVisitor();
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
@@ -870,13 +870,13 @@
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInColumnOrder(new SetVisitor());
getVisitor = new GetVisitor();
m.walkInOptimizedOrder(getVisitor);
assertEquals(rows * columns, getVisitor.getCount());
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInColumnOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2);
getVisitor = new GetVisitor();
m.walkInOptimizedOrder(getVisitor, 1, rows - 2, 1, columns - 2);
@@ -890,13 +890,13 @@
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInOptimizedOrder(new SetVisitor());
getVisitor = new GetVisitor();
m.walkInRowOrder(getVisitor);
assertEquals(rows * columns, getVisitor.getCount());
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2);
getVisitor = new GetVisitor();
m.walkInRowOrder(getVisitor, 1, rows - 2, 1, columns - 2);
@@ -910,13 +910,13 @@
assertEquals(0.0, m.getEntry(rows - 1, j), 0);
}
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInOptimizedOrder(new SetVisitor());
getVisitor = new GetVisitor();
m.walkInColumnOrder(getVisitor);
assertEquals(rows * columns, getVisitor.getCount());
- m = new RealMatrixImpl(rows, columns);
+ m = new Array2DRowRealMatrix(rows, columns);
m.walkInOptimizedOrder(new SetVisitor(), 1, rows - 2, 1, columns - 2);
getVisitor = new GetVisitor();
m.walkInColumnOrder(getVisitor, 1, rows - 2, 1, columns - 2);
@@ -933,7 +933,7 @@
}
public void testSerial() {
- RealMatrixImpl m = new RealMatrixImpl(testData);
+ Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
assertEquals(m,TestUtils.serializeAndRecover(m));
}
@@ -996,7 +996,7 @@
out[i][j] = matrix.getEntry(permutation[i], j);
}
}
- return new RealMatrixImpl(out);
+ return new Array2DRowRealMatrix(out);
}
// /** Useful for debugging */
Copied: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/ArrayFieldVectorTest.java (from r783662, commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/ArrayFieldVectorTest.java?p2=commons/proper/math/trunk/src/test/org/apache/commons/math/linear/ArrayFieldVectorTest.java&p1=commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java&r1=783662&r2=783702&rev=783702&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/ArrayFieldVectorTest.java Thu Jun 11 08:54:02 2009
@@ -30,11 +30,11 @@
import org.apache.commons.math.fraction.FractionField;
/**
- * Test cases for the {@link FieldVectorImpl} class.
+ * Test cases for the {@link ArrayFieldVector} class.
*
* @version $Revision$ $Date$
*/
-public class FieldVectorImplTest extends TestCase {
+public class ArrayFieldVectorTest extends TestCase {
//
protected Fraction[][] ma1 = {
@@ -255,33 +255,33 @@
}
public static Test suite() {
- TestSuite suite = new TestSuite(FieldVectorImplTest.class);
- suite.setName("FieldVectorImpl<Fraction> Tests");
+ TestSuite suite = new TestSuite(ArrayFieldVectorTest.class);
+ suite.setName("ArrayFieldVector<Fraction> Tests");
return suite;
}
public void testConstructors() {
- FieldVectorImpl<Fraction> v0 = new FieldVectorImpl<Fraction>(FractionField.getInstance());
+ ArrayFieldVector<Fraction> v0 = new ArrayFieldVector<Fraction>(FractionField.getInstance());
assertEquals(0, v0.getDimension());
- FieldVectorImpl<Fraction> v1 = new FieldVectorImpl<Fraction>(FractionField.getInstance(), 7);
+ ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(FractionField.getInstance(), 7);
assertEquals(7, v1.getDimension());
assertEquals(new Fraction(0), v1.getEntry(6));
- FieldVectorImpl<Fraction> v2 = new FieldVectorImpl<Fraction>(5, new Fraction(123, 100));
+ ArrayFieldVector<Fraction> v2 = new ArrayFieldVector<Fraction>(5, new Fraction(123, 100));
assertEquals(5, v2.getDimension());
assertEquals(new Fraction(123, 100), v2.getEntry(4));
- FieldVectorImpl<Fraction> v3 = new FieldVectorImpl<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v3 = new ArrayFieldVector<Fraction>(vec1);
assertEquals(3, v3.getDimension());
assertEquals(new Fraction(2), v3.getEntry(1));
- FieldVectorImpl<Fraction> v4 = new FieldVectorImpl<Fraction>(vec4, 3, 2);
+ ArrayFieldVector<Fraction> v4 = new ArrayFieldVector<Fraction>(vec4, 3, 2);
assertEquals(2, v4.getDimension());
assertEquals(new Fraction(4), v4.getEntry(0));
try {
- new FieldVectorImpl<Fraction>(vec4, 8, 3);
+ new ArrayFieldVector<Fraction>(vec4, 8, 3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected behavior
@@ -289,19 +289,19 @@
fail("wrong exception caught");
}
- FieldVector<Fraction> v5_i = new FieldVectorImpl<Fraction>(dvec1);
+ FieldVector<Fraction> v5_i = new ArrayFieldVector<Fraction>(dvec1);
assertEquals(9, v5_i.getDimension());
assertEquals(new Fraction(9), v5_i.getEntry(8));
- FieldVectorImpl<Fraction> v5 = new FieldVectorImpl<Fraction>(dvec1);
+ ArrayFieldVector<Fraction> v5 = new ArrayFieldVector<Fraction>(dvec1);
assertEquals(9, v5.getDimension());
assertEquals(new Fraction(9), v5.getEntry(8));
- FieldVectorImpl<Fraction> v6 = new FieldVectorImpl<Fraction>(dvec1, 3, 2);
+ ArrayFieldVector<Fraction> v6 = new ArrayFieldVector<Fraction>(dvec1, 3, 2);
assertEquals(2, v6.getDimension());
assertEquals(new Fraction(4), v6.getEntry(0));
try {
- new FieldVectorImpl<Fraction>(dvec1, 8, 3);
+ new ArrayFieldVector<Fraction>(dvec1, 8, 3);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected behavior
@@ -309,27 +309,27 @@
fail("wrong exception caught");
}
- FieldVectorImpl<Fraction> v7 = new FieldVectorImpl<Fraction>(v1);
+ ArrayFieldVector<Fraction> v7 = new ArrayFieldVector<Fraction>(v1);
assertEquals(7, v7.getDimension());
assertEquals(new Fraction(0), v7.getEntry(6));
FieldVectorTestImpl<Fraction> v7_i = new FieldVectorTestImpl<Fraction>(vec1);
- FieldVectorImpl<Fraction> v7_2 = new FieldVectorImpl<Fraction>(v7_i);
+ ArrayFieldVector<Fraction> v7_2 = new ArrayFieldVector<Fraction>(v7_i);
assertEquals(3, v7_2.getDimension());
assertEquals(new Fraction(2), v7_2.getEntry(1));
- FieldVectorImpl<Fraction> v8 = new FieldVectorImpl<Fraction>(v1, true);
+ ArrayFieldVector<Fraction> v8 = new ArrayFieldVector<Fraction>(v1, true);
assertEquals(7, v8.getDimension());
assertEquals(new Fraction(0), v8.getEntry(6));
assertNotSame("testData not same object ", v1.data, v8.data);
- FieldVectorImpl<Fraction> v8_2 = new FieldVectorImpl<Fraction>(v1, false);
+ ArrayFieldVector<Fraction> v8_2 = new ArrayFieldVector<Fraction>(v1, false);
assertEquals(7, v8_2.getDimension());
assertEquals(new Fraction(0), v8_2.getEntry(6));
assertEquals(v1.data, v8_2.data);
- FieldVectorImpl<Fraction> v9 = new FieldVectorImpl<Fraction>(v1, v3);
+ ArrayFieldVector<Fraction> v9 = new ArrayFieldVector<Fraction>(v1, v3);
assertEquals(10, v9.getDimension());
assertEquals(new Fraction(1), v9.getEntry(7));
@@ -337,9 +337,9 @@
public void testDataInOut() {
- FieldVectorImpl<Fraction> v1 = new FieldVectorImpl<Fraction>(vec1);
- FieldVectorImpl<Fraction> v2 = new FieldVectorImpl<Fraction>(vec2);
- FieldVectorImpl<Fraction> v4 = new FieldVectorImpl<Fraction>(vec4);
+ ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v2 = new ArrayFieldVector<Fraction>(vec2);
+ ArrayFieldVector<Fraction> v4 = new ArrayFieldVector<Fraction>(vec4);
FieldVectorTestImpl<Fraction> v2_t = new FieldVectorTestImpl<Fraction>(vec2);
FieldVector<Fraction> v_append_1 = v1.append(v2);
@@ -367,7 +367,7 @@
assertNotSame("testData not same object ", v1.data, a_frac);
-// FieldVectorImpl<Fraction> vout4 = (FieldVectorImpl<Fraction>) v1.clone();
+// ArrayFieldVector<Fraction> vout4 = (ArrayFieldVector<Fraction>) v1.clone();
// assertEquals(3, vout4.getDimension());
// assertEquals(v1.data, vout4.data);
@@ -384,7 +384,7 @@
fail("wrong exception caught");
}
- FieldVectorImpl<Fraction> v_set1 = (FieldVectorImpl<Fraction>) v1.copy();
+ ArrayFieldVector<Fraction> v_set1 = (ArrayFieldVector<Fraction>) v1.copy();
v_set1.setEntry(1, new Fraction(11));
assertEquals(new Fraction(11), v_set1.getEntry(1));
try {
@@ -396,7 +396,7 @@
fail("wrong exception caught");
}
- FieldVectorImpl<Fraction> v_set2 = (FieldVectorImpl<Fraction>) v4.copy();
+ ArrayFieldVector<Fraction> v_set2 = (ArrayFieldVector<Fraction>) v4.copy();
v_set2.set(3, v1);
assertEquals(new Fraction(1), v_set2.getEntry(3));
assertEquals(new Fraction(7), v_set2.getEntry(6));
@@ -409,7 +409,7 @@
fail("wrong exception caught");
}
- FieldVectorImpl<Fraction> v_set3 = (FieldVectorImpl<Fraction>) v1.copy();
+ ArrayFieldVector<Fraction> v_set3 = (ArrayFieldVector<Fraction>) v1.copy();
v_set3.set(new Fraction(13));
assertEquals(new Fraction(13), v_set3.getEntry(2));
@@ -422,7 +422,7 @@
fail("wrong exception caught");
}
- FieldVectorImpl<Fraction> v_set4 = (FieldVectorImpl<Fraction>) v4.copy();
+ ArrayFieldVector<Fraction> v_set4 = (ArrayFieldVector<Fraction>) v4.copy();
v_set4.setSubVector(3, v2_t);
assertEquals(new Fraction(4), v_set4.getEntry(3));
assertEquals(new Fraction(7), v_set4.getEntry(6));
@@ -436,8 +436,8 @@
}
- FieldVectorImpl<Fraction> vout10 = (FieldVectorImpl<Fraction>) v1.copy();
- FieldVectorImpl<Fraction> vout10_2 = (FieldVectorImpl<Fraction>) v1.copy();
+ ArrayFieldVector<Fraction> vout10 = (ArrayFieldVector<Fraction>) v1.copy();
+ ArrayFieldVector<Fraction> vout10_2 = (ArrayFieldVector<Fraction>) v1.copy();
assertEquals(vout10, vout10_2);
vout10_2.setEntry(0, new Fraction(11, 10));
assertNotSame(vout10, vout10_2);
@@ -445,7 +445,7 @@
}
public void testMapFunctions() {
- FieldVectorImpl<Fraction> v1 = new FieldVectorImpl<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
//octave = v1 .+ 2.0
FieldVector<Fraction> v_mapAdd = v1.mapAdd(new Fraction(2));
@@ -505,14 +505,14 @@
}
public void testBasicFunctions() {
- FieldVectorImpl<Fraction> v1 = new FieldVectorImpl<Fraction>(vec1);
- FieldVectorImpl<Fraction> v2 = new FieldVectorImpl<Fraction>(vec2);
- new FieldVectorImpl<Fraction>(vec_null);
+ ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v2 = new ArrayFieldVector<Fraction>(vec2);
+ new ArrayFieldVector<Fraction>(vec_null);
FieldVectorTestImpl<Fraction> v2_t = new FieldVectorTestImpl<Fraction>(vec2);
//octave = v1 + v2
- FieldVectorImpl<Fraction> v_add = v1.add(v2);
+ ArrayFieldVector<Fraction> v_add = v1.add(v2);
Fraction[] result_add = {new Fraction(5), new Fraction(7), new Fraction(9)};
checkArray("compare vect" ,v_add.getData(),result_add);
@@ -522,7 +522,7 @@
checkArray("compare vect" ,v_add_i.getData(),result_add_i);
//octave = v1 - v2
- FieldVectorImpl<Fraction> v_subtract = v1.subtract(v2);
+ ArrayFieldVector<Fraction> v_subtract = v1.subtract(v2);
Fraction[] result_subtract = {new Fraction(-3), new Fraction(-3), new Fraction(-3)};
checkArray("compare vect" ,v_subtract.getData(),result_subtract);
@@ -531,7 +531,7 @@
checkArray("compare vect" ,v_subtract_i.getData(),result_subtract_i);
// octave v1 .* v2
- FieldVectorImpl<Fraction> v_ebeMultiply = v1.ebeMultiply(v2);
+ ArrayFieldVector<Fraction> v_ebeMultiply = v1.ebeMultiply(v2);
Fraction[] result_ebeMultiply = {new Fraction(4), new Fraction(10), new Fraction(18)};
checkArray("compare vect" ,v_ebeMultiply.getData(),result_ebeMultiply);
@@ -540,7 +540,7 @@
checkArray("compare vect" ,v_ebeMultiply_2.getData(),result_ebeMultiply_2);
// octave v1 ./ v2
- FieldVectorImpl<Fraction> v_ebeDivide = v1.ebeDivide(v2);
+ ArrayFieldVector<Fraction> v_ebeDivide = v1.ebeDivide(v2);
Fraction[] result_ebeDivide = {new Fraction(1, 4), new Fraction(2, 5), new Fraction(1, 2)};
checkArray("compare vect" ,v_ebeDivide.getData(),result_ebeDivide);
@@ -562,7 +562,7 @@
FieldMatrix<Fraction> m_outerProduct_2 = v1.outerProduct(v2_t);
assertEquals("compare val ",new Fraction(4), m_outerProduct_2.getEntry(0,0));
- FieldVectorImpl<Fraction> v_projection = v1.projection(v2);
+ ArrayFieldVector<Fraction> v_projection = v1.projection(v2);
Fraction[] result_projection = {new Fraction(128, 77), new Fraction(160, 77), new Fraction(192, 77)};
checkArray("compare vect", v_projection.getData(), result_projection);
@@ -573,9 +573,9 @@
}
public void testMisc() {
- FieldVectorImpl<Fraction> v1 = new FieldVectorImpl<Fraction>(vec1);
- FieldVectorImpl<Fraction> v4 = new FieldVectorImpl<Fraction>(vec4);
- FieldVector<Fraction> v4_2 = new FieldVectorImpl<Fraction>(vec4);
+ ArrayFieldVector<Fraction> v1 = new ArrayFieldVector<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v4 = new ArrayFieldVector<Fraction>(vec4);
+ FieldVector<Fraction> v4_2 = new ArrayFieldVector<Fraction>(vec4);
String out1 = v1.toString();
assertTrue("some output ", out1.length()!=0);
@@ -614,7 +614,7 @@
}
public void testSerial() {
- FieldVectorImpl<Fraction> v = new FieldVectorImpl<Fraction>(vec1);
+ ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(vec1);
assertEquals(v,TestUtils.serializeAndRecover(v));
}