Formatting only, Eliminated tabs and trailing spaces.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2004-06-07 03:26:31 +00:00
parent 444c87274c
commit 1af2a2a253
5 changed files with 101 additions and 101 deletions

View File

@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,23 +22,23 @@ import org.apache.commons.lang.exception.NestableRuntimeException;
* Thrown when a system attempts an operation on a matrix, and
* that matrix does not satisfy the preconditions for the
* aforementioned operation.
* @version $Revision: 1.5 $ $Date: 2004/06/02 00:06:18 $
* @version $Revision: 1.6 $ $Date: 2004/06/07 03:26:31 $
*/
public class InvalidMatrixException extends NestableRuntimeException {
/** Serializable version identifier */
static final long serialVersionUID = 5318837237354354107L;
/**
* Default constructor.
*/
public InvalidMatrixException() {
this(null, null);
}
/**
* Construct an exception with the given message.
* @param message descriptive error message.
* @param message descriptive error message.
*/
public InvalidMatrixException(String message) {
this(message, null);

View File

@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,23 +21,23 @@ import org.apache.commons.lang.exception.NestableRuntimeException;
/**
* Thrown when an operation addresses a matrix coordinate (row,col)
* which is outside of the dimensions of a matrix.
* @version $Revision: 1.5 $ $Date: 2004/06/02 00:06:18 $
* @version $Revision: 1.6 $ $Date: 2004/06/07 03:26:31 $
*/
public class MatrixIndexException extends NestableRuntimeException {
/** Serializable version identifier */
static final long serialVersionUID = -1341109412864309526L;
/**
* Default constructor.
*/
public MatrixIndexException() {
this(null, null);
}
/**
* Construct an exception with the given message.
* @param message descriptive error message.
* @param message descriptive error message.
*/
public MatrixIndexException(String message) {
this(message, null);

View File

@ -1,12 +1,12 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,7 +18,7 @@ package org.apache.commons.math.linear;
/**
* Interface defining a real-valued matrix with basic algebraic operations
* @version $Revision: 1.18 $ $Date: 2004/06/05 22:28:10 $
* @version $Revision: 1.19 $ $Date: 2004/06/07 03:26:31 $
*/
public interface RealMatrix {
@ -28,7 +28,7 @@ public interface RealMatrix {
* @return matrix copy
*/
RealMatrix copy();
/**
* Compute the sum of this and m.
*
@ -36,8 +36,8 @@ public interface RealMatrix {
* @return this + m
* @throws IllegalArgumentException if m is not the same size as this
*/
RealMatrix add(RealMatrix m) throws IllegalArgumentException;
RealMatrix add(RealMatrix m) throws IllegalArgumentException;
/**
* Compute this minus m.
*
@ -45,8 +45,8 @@ public interface RealMatrix {
* @return this + m
* @throws IllegalArgumentException if m is not the same size as this
*/
RealMatrix subtract(RealMatrix m) throws IllegalArgumentException;
RealMatrix subtract(RealMatrix m) throws IllegalArgumentException;
/**
* Returns the result of adding d to each entry of this.
*
@ -54,7 +54,7 @@ public interface RealMatrix {
* @return d + this
*/
RealMatrix scalarAdd(double d);
/**
* Returns the result multiplying each entry of this by d.
*
@ -62,17 +62,17 @@ public interface RealMatrix {
* @return d * this
*/
RealMatrix scalarMultiply(double d);
/**
* Returns the result postmultiplying this by m.
*
* @param m matrix to postmultiply by
* @return this * m
* @throws IllegalArgumentException
* @throws IllegalArgumentException
* if columnDimension(this) != rowDimension(m)
*/
RealMatrix multiply(RealMatrix m) throws IllegalArgumentException;
/**
* Returns the result premultiplying this by <code>m</code>.
* @param m matrix to premultiply by
@ -81,14 +81,14 @@ public interface RealMatrix {
* if rowDimension(this) != columnDimension(m)
*/
public RealMatrix preMultiply(RealMatrix m) throws IllegalArgumentException;
/**
* Returns matrix entries as a two-dimensional array.
*
* @return 2-dimensional array of entries
*/
double[][] getData();
/**
* Overwrites the underlying data for the matrix with
* a fresh copy of <code>data</code>.
@ -96,7 +96,7 @@ public interface RealMatrix {
* @param data 2-dimensional array of entries
*/
void setData(double[][] data);
/**
* Returns the <a href="http://mathworld.wolfram.com/MaximumAbsoluteRowSumNorm.html">
* maximum absolute row sum norm</a> of the matrix.
@ -104,17 +104,17 @@ public interface RealMatrix {
* @return norm
*/
double getNorm();
/**
* Returns the entries in row number <code>row</code> as an array.
*
* @param row the row to be fetched
* @return array of entries in the row
* @throws MatrixIndexException if the specified row is greater
* @throws MatrixIndexException if the specified row is greater
* than the number of rows in this matrix
*/
double[] getRow(int row) throws MatrixIndexException;
/**
* Returns the entries in column number <code>col</code> as an array.
*
@ -124,37 +124,37 @@ public interface RealMatrix {
* than the number of columns in this matrix
*/
double[] getColumn(int col) throws MatrixIndexException;
/**
* Returns the entry in the specified row and column.
*
* @param row row location of entry to be fetched
* @param row row location of entry to be fetched
* @param column column location of entry to be fetched
* @return matrix entry in row,column
* @throws MatrixIndexException if the specified coordinate is outside
* @throws MatrixIndexException if the specified coordinate is outside
* the dimensions of this matrix
*/
double getEntry(int row, int column) throws MatrixIndexException;
/**
* Sets the entry in the specified row and column to the specified value.
*
* @param row row location of entry to be set
* @param row row location of entry to be set
* @param column column location of entry to be set
* @param value value to set
* @param value value to set
* @throws MatrixIndexException if the specified coordinate is outside
* he dimensions of this matrix
*/
void setEntry(int row, int column, double value)
void setEntry(int row, int column, double value)
throws MatrixIndexException;
/**
* Returns the transpose of this matrix.
*
* @return transpose matrix
*/
RealMatrix transpose();
/**
* Returns the inverse of this matrix.
*
@ -162,40 +162,40 @@ public interface RealMatrix {
* @throws InvalidMatrixException if this is not invertible
*/
RealMatrix inverse() throws InvalidMatrixException;
/**
* Returns the determinant of this matrix.
*
* @return determinant
*/
double getDeterminant();
/**
* Is this a square matrix?
* @return true if the matrix is square (rowDimension = columnDimension)
*/
boolean isSquare();
/**
* Is this a singular matrix?
* @return true if the matrix is singular
*/
boolean isSingular();
/**
* Returns the number of rows in the matrix.
*
* @return rowDimension
*/
int getRowDimension();
/**
* Returns the number of columns in the matrix.
*
* @return columnDimension
*/
int getColumnDimension();
/**
* Returns the <a href="http://mathworld.wolfram.com/MatrixTrace.html">
* trace</a> of the matrix (the sum of the elements on the main diagonal).
@ -203,7 +203,7 @@ public interface RealMatrix {
* @return trace
*/
double getTrace();
/**
* Returns the result of multiplying this by the vector <code>v</code>.
*
@ -212,7 +212,7 @@ public interface RealMatrix {
* @throws IllegalArgumentException if columnDimension != v.size()
*/
double[] operate(double[] v) throws IllegalArgumentException;
/**
* Returns the (row) vector result of premultiplying this by the vector <code>v</code>.
*
@ -220,23 +220,23 @@ public interface RealMatrix {
* @return v*this
* @throws IllegalArgumentException if rowDimension != v.size()
*/
double[] preMultiply(double[] v) throws IllegalArgumentException;
double[] preMultiply(double[] v) throws IllegalArgumentException;
/**
* Returns the solution vector for a linear system with coefficient
* matrix = this and constant vector = <code>b</code>.
*
* @param b constant vector
* @return vector of solution values to AX = b, where A is *this
* @throws IllegalArgumentException if this.rowDimension != b.length
* @throws IllegalArgumentException if this.rowDimension != b.length
* @throws InvalidMatrixException if this matrix is not square or is singular
*/
double[] solve(double[] b) throws IllegalArgumentException, InvalidMatrixException;
/**
* Returns a matrix of (column) solution vectors for linear systems with
* coefficient matrix = this and constant vectors = columns of
* <code>b</code>.
* <code>b</code>.
*
* @param b matrix of constant vectors forming RHS of linear systems to
* to solve

View File

@ -1,12 +1,12 @@
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,7 +20,7 @@ import java.io.Serializable;
/**
* Implementation for RealMatrix using a double[][] array to store entries
* and <a href="http://www.math.gatech.edu/~bourbaki/math2601/Web-notes/2num.pdf">
* LU decompostion</a> to support linear system
* LU decompostion</a> to support linear system
* solution and inverse.
* <p>
* The LU decompostion is performed as needed, to support the following operations: <ul>
@ -31,20 +31,20 @@ import java.io.Serializable;
* <p>
* <strong>Usage note</strong>:<br>
* The LU decomposition is stored and reused on subsequent calls. If matrix
* data are modified using any of the public setXxx methods, the saved
* data are modified using any of the public setXxx methods, the saved
* decomposition is discarded. If data are modified via references to the
* underlying array obtained using <code>getDataRef()</code>, then the stored
* LU decomposition will not be discarded. In this case, you need to
* LU decomposition will not be discarded. In this case, you need to
* explicitly invoke <code>LUDecompose()</code> to recompute the decomposition
* before using any of the methods above.
*
* @version $Revision: 1.23 $ $Date: 2004/06/05 22:31:16 $
* @version $Revision: 1.24 $ $Date: 2004/06/07 03:26:31 $
*/
public class RealMatrixImpl implements RealMatrix, Serializable {
/** Serializable version identifier */
static final long serialVersionUID = 4237564493130426188L;
/** Entries of the matrix */
private double data[][] = null;
@ -62,7 +62,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/** Bound to determine effective singularity in LU decomposition */
protected static double TOO_SMALL = 10E-12;
/**
/**
* Creates a matrix with no data
*/
public RealMatrixImpl() {
@ -93,8 +93,8 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
}
/**
* Create a new (column) RealMatrix using <code>v</code> as the
* data for the unique column of the <code>v.length x 1</code> matrix
* Create a new (column) RealMatrix using <code>v</code> as the
* data for the unique column of the <code>v.length x 1</code> matrix
* created.
* <p>
* The input array is copied, not referenced.
@ -229,7 +229,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
}
return new RealMatrixImpl(outData);
}
/**
* Returns the result premultiplying this by <code>m</code>.
* @param m matrix to premultiply by
@ -308,7 +308,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
*
* @param row the row to be fetched
* @return array of entries in the row
* @throws MatrixIndexException if the specified row is greater
* @throws MatrixIndexException if the specified row is greater
* than the number of rows in this matrix
*/
public double[] getRow(int row) throws MatrixIndexException {
@ -344,10 +344,10 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/**
* Returns the entry in the specified row and column.
*
* @param row row location of entry to be fetched
* @param row row location of entry to be fetched
* @param column column location of entry to be fetched
* @return matrix entry in row,column
* @throws MatrixIndexException if the specified coordinate is outside
* @throws MatrixIndexException if the specified coordinate is outside
* the dimensions of this matrix
*/
public double getEntry(int row, int column)
@ -361,9 +361,9 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/**
* Sets the entry in the specified row and column to the specified value.
*
* @param row row location of entry to be set
* @param row row location of entry to be set
* @param column column location of entry to be set
* @param value value to set
* @param value value to set
* @throws MatrixIndexException if the specified coordinate is outside
* he dimensions of this matrix
*/
@ -396,7 +396,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/**
* Returns the inverse matrix if this matrix is invertible.
*
*
* @return inverse matrix
* @throws InvalidMatrixException if this is not invertible
*/
@ -413,7 +413,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
throw new InvalidMatrixException("matrix is not square");
}
if (isSingular()) { // note: this has side effect of attempting LU decomp if lu == null
return 0d;
return 0d;
} else {
double det = (double) parity;
for (int i = 0; i < this.getRowDimension(); i++) {
@ -422,7 +422,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
return det;
}
}
/**
* @return true if the matrix is square (rowDimension = columnDimension)
*/
@ -522,7 +522,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/**
* Returns a matrix of (column) solution vectors for linear systems with
* coefficient matrix = this and constant vectors = columns of
* <code>b</code>.
* <code>b</code>.
*
* @param b array of constant forming RHS of linear systems to
* to solve
@ -547,7 +547,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
/**
* Returns a matrix of (column) solution vectors for linear systems with
* coefficient matrix = this and constant vectors = columns of
* <code>b</code>.
* <code>b</code>.
*
* @param b matrix of constant vectors forming RHS of linear systems to
* to solve
@ -606,9 +606,9 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
}
/**
* Computes a new
* Computes a new
* <a href="http://www.math.gatech.edu/~bourbaki/math2601/Web-notes/2num.pdf">
* LU decompostion</a> for this matrix, storing the result for use by other methods.
* LU decompostion</a> for this matrix, storing the result for use by other methods.
* <p>
* <strong>Implementation Note</strong>:<br>
* Uses <a href="http://www.damtp.cam.ac.uk/user/fdl/people/sd/lectures/nummeth98/linear.htm">
@ -624,7 +624,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
* @throws InvalidMatrixException if the matrix is non-square or singular.
*/
public void luDecompose() throws InvalidMatrixException {
int nRows = this.getRowDimension();
int nCols = this.getColumnDimension();
if (nRows != nCols) {
@ -698,7 +698,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
}
/**
*
*
* @see java.lang.Object#toString()
*/
public String toString() {
@ -737,31 +737,31 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
}
return out;
}
/**
* Returns the LU decomposition as a RealMatrix.
* Returns a fresh copy of the cached LU matrix if this has been computed;
* otherwise the composition is computed and cached for use by other methods.
* Since a copy is returned in either case, changes to the returned matrix do not
* affect the LU decomposition property.
* Returns a fresh copy of the cached LU matrix if this has been computed;
* otherwise the composition is computed and cached for use by other methods.
* Since a copy is returned in either case, changes to the returned matrix do not
* affect the LU decomposition property.
* <p>
* The matrix returned is a compact representation of the LU decomposition.
* Elements below the main diagonal correspond to entries of the "L" matrix;
* The matrix returned is a compact representation of the LU decomposition.
* Elements below the main diagonal correspond to entries of the "L" matrix;
* elements on and above the main diagonal correspond to entries of the "U"
* matrix.
* <p>
* Example: <pre>
*
*
* Returned matrix L U
* 2 3 1 1 0 0 2 3 1
* 2 3 1 1 0 0 2 3 1
* 5 4 6 5 1 0 0 4 6
* 1 7 8 1 7 1 0 0 8
* 1 7 8 1 7 1 0 0 8
* </pre>
*
*
* The L and U matrices satisfy the matrix equation LU = permuteRows(this), <br>
* where permuteRows reorders the rows of the matrix to follow the order determined
* by the <a href=#getPermutation()>permutation</a> property.
*
*
* @return LU decomposition matrix
* @throws InvalidMatrixException if the matrix is non-square or singular.
*/
@ -769,9 +769,9 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
if (lu == null) {
luDecompose();
}
return new RealMatrixImpl(lu);
return new RealMatrixImpl(lu);
}
/**
* Returns the permutation associated with the lu decomposition.
* The entries of the array represent a permutation of the numbers 0, ... , nRows - 1.
@ -781,7 +781,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
* and current first row is last.
* <p>
* Returns a fresh copy of the array.
*
*
* @return the permutation
*/
protected int[] getPermutation() {
@ -836,5 +836,5 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
return !(row < 1 || row > nRows || col < 1 || col > nCols);
}
}

View File

@ -14,6 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Revision: 1.5 $ $Date: 2004/04/26 18:28:17 $ -->
<body>Linear algebra support.</body>
<!-- $Revision: 1.6 $ $Date: 2004/06/07 03:26:31 $ -->
<body>Linear algebra support.</body>
</html>