You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bi...@apache.org on 2009/05/18 02:42:41 UTC
svn commit: r775784 - in
/commons/proper/math/trunk/src/java/org/apache/commons/math/linear:
OpenMapRealMatrix.java OpenMapRealVector.java SparseRealMatrix.java
SparseRealVector.java
Author: billbarker
Date: Mon May 18 00:42:41 2009
New Revision: 775784
URL: http://svn.apache.org/viewvc?rev=775784&view=rev
Log:
Sparse Matrix/Vector refactoring with mostly return types changed.
Thought that getSparcity was meaninful for SparseRealVector, and added a marker for SparseRealMatrix shape. Feel free to -1 either ;).
I found an error in the unit tests, so will commit the changes there shortly, after a review.
Added:
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java (with props)
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java (with props)
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java?rev=775784&r1=775783&r2=775784&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealMatrix.java Mon May 18 00:42:41 2009
@@ -25,7 +25,7 @@
* @version $Revision$ $Date$
* @since 2.0
*/
-public class OpenMapRealMatrix extends AbstractRealMatrix {
+public class OpenMapRealMatrix extends AbstractRealMatrix implements SparseRealMatrix {
/** Serializable version identifier. */
private static final long serialVersionUID = -5962461716457143437L;
@@ -63,13 +63,13 @@
/** {@inheritDoc} */
@Override
- public RealMatrix copy() {
+ public OpenMapRealMatrix copy() {
return new OpenMapRealMatrix(this);
}
/** {@inheritDoc} */
@Override
- public RealMatrix createMatrix(int rowDimension, int columnDimension)
+ public OpenMapRealMatrix createMatrix(int rowDimension, int columnDimension)
throws IllegalArgumentException {
return new OpenMapRealMatrix(rowDimension, columnDimension);
}
@@ -82,12 +82,12 @@
/** {@inheritDoc} */
@Override
- public RealMatrix add(final RealMatrix m)
+ public OpenMapRealMatrix add(final RealMatrix m)
throws IllegalArgumentException {
try {
return add((OpenMapRealMatrix) m);
} catch (ClassCastException cce) {
- return super.add(m);
+ return (OpenMapRealMatrix) super.add(m);
}
}
@@ -98,12 +98,12 @@
* @return this + m
* @throws IllegalArgumentException if m is not the same size as this
*/
- public RealMatrix add(OpenMapRealMatrix m) throws IllegalArgumentException {
+ public OpenMapRealMatrix add(OpenMapRealMatrix m) throws IllegalArgumentException {
// safety check
MatrixUtils.checkAdditionCompatible(this, m);
- final RealMatrix out = new OpenMapRealMatrix(this);
+ final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
iterator.advance();
final int row = iterator.key() / columnDimension;
@@ -117,12 +117,12 @@
/** {@inheritDoc} */
@Override
- public RealMatrix subtract(final RealMatrix m)
+ public OpenMapRealMatrix subtract(final RealMatrix m)
throws IllegalArgumentException {
try {
return subtract((OpenMapRealMatrix) m);
} catch (ClassCastException cce) {
- return super.add(m);
+ return (OpenMapRealMatrix) super.subtract(m);
}
}
@@ -133,12 +133,12 @@
* @return this - m
* @throws IllegalArgumentException if m is not the same size as this
*/
- public RealMatrix subtract(OpenMapRealMatrix m) throws IllegalArgumentException {
+ public OpenMapRealMatrix subtract(OpenMapRealMatrix m) throws IllegalArgumentException {
// safety check
MatrixUtils.checkAdditionCompatible(this, m);
- final RealMatrix out = new OpenMapRealMatrix(this);
+ final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
iterator.advance();
final int row = iterator.key() / columnDimension;
@@ -286,4 +286,9 @@
return row * columnDimension + column;
}
+ /** {@inheritDoc} */
+ public MatrixShape getShape() {
+ return MatrixShape.Any;
+ }
+
}
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java?rev=775784&r1=775783&r2=775784&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/OpenMapRealVector.java Mon May 18 00:42:41 2009
@@ -25,7 +25,7 @@
* @version $Revision: 728186 $ $Date$
* @since 2.0
*/
-public class OpenMapRealVector implements RealVector {
+public class OpenMapRealVector implements SparseRealVector {
/** Serializable version identifier. */
private static final long serialVersionUID = 8772222695580707260L;
@@ -46,7 +46,7 @@
* Build a 0-length vector.
* <p>Zero-length vectors may be used to initialized construction of vectors
* by data gathering. We start with zero-length and use either the {@link
- * #SparseRealVector(OpenMapRealVector, int)} constructor
+ * #OpenMapRealVector(OpenMapRealVector, int)} constructor
* or one of the <code>append</code> method ({@link #append(double)}, {@link
* #append(double[])}, {@link #append(RealVector)}) to gather data
* into this vector.</p>
@@ -220,7 +220,7 @@
}
/** {@inheritDoc} */
- public RealVector add(RealVector v) throws IllegalArgumentException {
+ public OpenMapRealVector add(RealVector v) throws IllegalArgumentException {
checkVectorDimensions(v.getDimension());
if (v instanceof OpenMapRealVector) {
return add((OpenMapRealVector) v);
@@ -229,7 +229,7 @@
}
/**
- * Optimized method to add two SparseRealVectors.
+ * Optimized method to add two OpenMapRealVectors.
* @param v Vector to add with
* @return The sum of <code>this</code> with <code>v</code>
* @throws IllegalArgumentException If the dimensions don't match
@@ -251,7 +251,7 @@
}
/** {@inheritDoc} */
- public RealVector add(double[] v) throws IllegalArgumentException {
+ public OpenMapRealVector add(double[] v) throws IllegalArgumentException {
checkVectorDimensions(v.length);
OpenMapRealVector res = new OpenMapRealVector(getDimension());
for (int i = 0; i < v.length; i++) {
@@ -261,7 +261,7 @@
}
/**
- * Optimized method to append a SparseRealVector.
+ * Optimized method to append a OpenMapRealVector.
* @param v vector to append
* @return The result of appending <code>v</code> to self
*/
@@ -276,7 +276,7 @@
}
/** {@inheritDoc} */
- public RealVector append(RealVector v) {
+ public OpenMapRealVector append(RealVector v) {
if (v instanceof OpenMapRealVector) {
return append((OpenMapRealVector) v);
}
@@ -284,15 +284,15 @@
}
/** {@inheritDoc} */
- public RealVector append(double d) {
- RealVector res = new OpenMapRealVector(this, 1);
+ public OpenMapRealVector append(double d) {
+ OpenMapRealVector res = new OpenMapRealVector(this, 1);
res.setEntry(virtualSize, d);
return res;
}
/** {@inheritDoc} */
- public RealVector append(double[] a) {
- RealVector res = new OpenMapRealVector(this, a.length);
+ public OpenMapRealVector append(double[] a) {
+ OpenMapRealVector res = new OpenMapRealVector(this, a.length);
for (int i = 0; i < a.length; i++) {
res.setEntry(i + virtualSize, a[i]);
}
@@ -300,7 +300,7 @@
}
/** {@inheritDoc} */
- public RealVector copy() {
+ public OpenMapRealVector copy() {
return new OpenMapRealVector(this);
}
@@ -333,7 +333,7 @@
}
/** {@inheritDoc} */
- public RealVector ebeDivide(RealVector v) throws IllegalArgumentException {
+ public OpenMapRealVector ebeDivide(RealVector v) throws IllegalArgumentException {
checkVectorDimensions(v.getDimension());
OpenMapRealVector res = new OpenMapRealVector(this);
Iterator iter = res.entries.iterator();
@@ -345,7 +345,7 @@
}
/** {@inheritDoc} */
- public RealVector ebeDivide(double[] v) throws IllegalArgumentException {
+ public OpenMapRealVector ebeDivide(double[] v) throws IllegalArgumentException {
checkVectorDimensions(v.length);
OpenMapRealVector res = new OpenMapRealVector(this);
Iterator iter = res.entries.iterator();
@@ -357,7 +357,7 @@
}
/** {@inheritDoc} */
- public RealVector ebeMultiply(RealVector v) throws IllegalArgumentException {
+ public OpenMapRealVector ebeMultiply(RealVector v) throws IllegalArgumentException {
checkVectorDimensions(v.getDimension());
OpenMapRealVector res = new OpenMapRealVector(this);
Iterator iter = res.entries.iterator();
@@ -369,7 +369,7 @@
}
/** {@inheritDoc} */
- public RealVector ebeMultiply(double[] v) throws IllegalArgumentException {
+ public OpenMapRealVector ebeMultiply(double[] v) throws IllegalArgumentException {
checkVectorDimensions(v.length);
OpenMapRealVector res = new OpenMapRealVector(this);
Iterator iter = res.entries.iterator();
@@ -381,7 +381,7 @@
}
/** {@inheritDoc} */
- public RealVector getSubVector(int index, int n) throws MatrixIndexException {
+ public OpenMapRealVector getSubVector(int index, int n) throws MatrixIndexException {
checkIndex(index);
checkIndex(index + n - 1);
OpenMapRealVector res = new OpenMapRealVector(n);
@@ -628,12 +628,12 @@
}
/** {@inheritDoc} */
- public RealVector mapAbs() {
+ public OpenMapRealVector mapAbs() {
return copy().mapAbsToSelf();
}
/** {@inheritDoc} */
- public RealVector mapAbsToSelf() {
+ public OpenMapRealVector mapAbsToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -643,12 +643,12 @@
}
/** {@inheritDoc} */
- public RealVector mapAcos() {
+ public OpenMapRealVector mapAcos() {
return copy().mapAcosToSelf();
}
/** {@inheritDoc} */
- public RealVector mapAcosToSelf() {
+ public OpenMapRealVector mapAcosToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, Math.acos(getEntry(i)));
}
@@ -656,12 +656,12 @@
}
/** {@inheritDoc} */
- public RealVector mapAdd(double d) {
+ public OpenMapRealVector mapAdd(double d) {
return copy().mapAddToSelf(d);
}
/** {@inheritDoc} */
- public RealVector mapAddToSelf(double d) {
+ public OpenMapRealVector mapAddToSelf(double d) {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, getEntry(i) + d);
}
@@ -669,12 +669,12 @@
}
/** {@inheritDoc} */
- public RealVector mapAsin() {
+ public OpenMapRealVector mapAsin() {
return copy().mapAsinToSelf();
}
/** {@inheritDoc} */
- public RealVector mapAsinToSelf() {
+ public OpenMapRealVector mapAsinToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -684,12 +684,12 @@
}
/** {@inheritDoc} */
- public RealVector mapAtan() {
+ public OpenMapRealVector mapAtan() {
return copy().mapAtanToSelf();
}
/** {@inheritDoc} */
- public RealVector mapAtanToSelf() {
+ public OpenMapRealVector mapAtanToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -699,12 +699,12 @@
}
/** {@inheritDoc} */
- public RealVector mapCbrt() {
+ public OpenMapRealVector mapCbrt() {
return copy().mapCbrtToSelf();
}
/** {@inheritDoc} */
- public RealVector mapCbrtToSelf() {
+ public OpenMapRealVector mapCbrtToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -714,12 +714,12 @@
}
/** {@inheritDoc} */
- public RealVector mapCeil() {
+ public OpenMapRealVector mapCeil() {
return copy().mapCeilToSelf();
}
/** {@inheritDoc} */
- public RealVector mapCeilToSelf() {
+ public OpenMapRealVector mapCeilToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -729,12 +729,12 @@
}
/** {@inheritDoc} */
- public RealVector mapCos() {
+ public OpenMapRealVector mapCos() {
return copy().mapCosToSelf();
}
/** {@inheritDoc} */
- public RealVector mapCosToSelf() {
+ public OpenMapRealVector mapCosToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, Math.cos(getEntry(i)));
}
@@ -742,12 +742,12 @@
}
/** {@inheritDoc} */
- public RealVector mapCosh() {
+ public OpenMapRealVector mapCosh() {
return copy().mapCoshToSelf();
}
/** {@inheritDoc} */
- public RealVector mapCoshToSelf() {
+ public OpenMapRealVector mapCoshToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, Math.cosh(getEntry(i)));
}
@@ -755,12 +755,12 @@
}
/** {@inheritDoc} */
- public RealVector mapDivide(double d) {
+ public OpenMapRealVector mapDivide(double d) {
return copy().mapDivideToSelf(d);
}
/** {@inheritDoc} */
- public RealVector mapDivideToSelf(double d) {
+ public OpenMapRealVector mapDivideToSelf(double d) {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -770,12 +770,12 @@
}
/** {@inheritDoc} */
- public RealVector mapExp() {
+ public OpenMapRealVector mapExp() {
return copy().mapExpToSelf();
}
/** {@inheritDoc} */
- public RealVector mapExpToSelf() {
+ public OpenMapRealVector mapExpToSelf() {
for (int i = 0; i < virtualSize; i++) {
entries.put(i, Math.exp(entries.get(i)));
}
@@ -783,12 +783,12 @@
}
/** {@inheritDoc} */
- public RealVector mapExpm1() {
+ public OpenMapRealVector mapExpm1() {
return copy().mapExpm1ToSelf();
}
/** {@inheritDoc} */
- public RealVector mapExpm1ToSelf() {
+ public OpenMapRealVector mapExpm1ToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -798,12 +798,12 @@
}
/** {@inheritDoc} */
- public RealVector mapFloor() {
+ public OpenMapRealVector mapFloor() {
return copy().mapFloorToSelf();
}
/** {@inheritDoc} */
- public RealVector mapFloorToSelf() {
+ public OpenMapRealVector mapFloorToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -813,12 +813,12 @@
}
/** {@inheritDoc} */
- public RealVector mapInv() {
+ public OpenMapRealVector mapInv() {
return copy().mapInvToSelf();
}
/** {@inheritDoc} */
- public RealVector mapInvToSelf() {
+ public OpenMapRealVector mapInvToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, 1.0/getEntry(i));
}
@@ -826,17 +826,17 @@
}
/** {@inheritDoc} */
- public RealVector mapLog() {
+ public OpenMapRealVector mapLog() {
return copy().mapLogToSelf();
}
/** {@inheritDoc} */
- public RealVector mapLog10() {
+ public OpenMapRealVector mapLog10() {
return copy().mapLog10ToSelf();
}
/** {@inheritDoc} */
- public RealVector mapLog10ToSelf() {
+ public OpenMapRealVector mapLog10ToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, Math.log10(getEntry(i)));
}
@@ -844,12 +844,12 @@
}
/** {@inheritDoc} */
- public RealVector mapLog1p() {
+ public OpenMapRealVector mapLog1p() {
return copy().mapLog1pToSelf();
}
/** {@inheritDoc} */
- public RealVector mapLog1pToSelf() {
+ public OpenMapRealVector mapLog1pToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -859,7 +859,7 @@
}
/** {@inheritDoc} */
- public RealVector mapLogToSelf() {
+ public OpenMapRealVector mapLogToSelf() {
for (int i = 0; i < virtualSize; i++) {
setEntry(i, Math.log(getEntry(i)));
}
@@ -867,12 +867,12 @@
}
/** {@inheritDoc} */
- public RealVector mapMultiply(double d) {
+ public OpenMapRealVector mapMultiply(double d) {
return copy().mapMultiplyToSelf(d);
}
/** {@inheritDoc} */
- public RealVector mapMultiplyToSelf(double d) {
+ public OpenMapRealVector mapMultiplyToSelf(double d) {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -881,12 +881,12 @@
return this;
}
/** {@inheritDoc} */
- public RealVector mapPow(double d) {
+ public OpenMapRealVector mapPow(double d) {
return copy().mapPowToSelf(d);
}
/** {@inheritDoc} */
- public RealVector mapPowToSelf(double d) {
+ public OpenMapRealVector mapPowToSelf(double d) {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -896,12 +896,12 @@
}
/** {@inheritDoc} */
- public RealVector mapRint() {
+ public OpenMapRealVector mapRint() {
return copy().mapRintToSelf();
}
/** {@inheritDoc} */
- public RealVector mapRintToSelf() {
+ public OpenMapRealVector mapRintToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -911,12 +911,12 @@
}
/** {@inheritDoc} */
- public RealVector mapSignum() {
+ public OpenMapRealVector mapSignum() {
return copy().mapSignumToSelf();
}
/** {@inheritDoc} */
- public RealVector mapSignumToSelf() {
+ public OpenMapRealVector mapSignumToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -926,12 +926,12 @@
}
/** {@inheritDoc} */
- public RealVector mapSin() {
+ public OpenMapRealVector mapSin() {
return copy().mapSinToSelf();
}
/** {@inheritDoc} */
- public RealVector mapSinToSelf() {
+ public OpenMapRealVector mapSinToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -941,12 +941,12 @@
}
/** {@inheritDoc} */
- public RealVector mapSinh() {
+ public OpenMapRealVector mapSinh() {
return copy().mapSinhToSelf();
}
/** {@inheritDoc} */
- public RealVector mapSinhToSelf() {
+ public OpenMapRealVector mapSinhToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
@@ -957,12 +957,12 @@
}
/** {@inheritDoc} */
- public RealVector mapSqrt() {
+ public OpenMapRealVector mapSqrt() {
return copy().mapSqrtToSelf();
}
/** {@inheritDoc} */
- public RealVector mapSqrtToSelf() {
+ public OpenMapRealVector mapSqrtToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -972,22 +972,22 @@
}
/** {@inheritDoc} */
- public RealVector mapSubtract(double d) {
+ public OpenMapRealVector mapSubtract(double d) {
return copy().mapSubtractToSelf(d);
}
/** {@inheritDoc} */
- public RealVector mapSubtractToSelf(double d) {
+ public OpenMapRealVector mapSubtractToSelf(double d) {
return mapAddToSelf(-d);
}
/** {@inheritDoc} */
- public RealVector mapTan() {
+ public OpenMapRealVector mapTan() {
return copy().mapTanToSelf();
}
/** {@inheritDoc} */
- public RealVector mapTanToSelf() {
+ public OpenMapRealVector mapTanToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -997,12 +997,12 @@
}
/** {@inheritDoc} */
- public RealVector mapTanh() {
+ public OpenMapRealVector mapTanh() {
return copy().mapTanhToSelf();
}
/** {@inheritDoc} */
- public RealVector mapTanhToSelf() {
+ public OpenMapRealVector mapTanhToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -1012,12 +1012,12 @@
}
/** {@inheritDoc} */
- public RealVector mapUlp() {
+ public OpenMapRealVector mapUlp() {
return copy().mapUlpToSelf();
}
/** {@inheritDoc} */
- public RealVector mapUlpToSelf() {
+ public OpenMapRealVector mapUlpToSelf() {
Iterator iter = entries.iterator();
while (iter.hasNext()) {
iter.advance();
@@ -1089,9 +1089,9 @@
}
/** {@inheritDoc} */
- public RealVector projection(double[] v) throws IllegalArgumentException {
+ public OpenMapRealVector projection(double[] v) throws IllegalArgumentException {
checkVectorDimensions(v.length);
- return projection(new OpenMapRealVector(v));
+ return (OpenMapRealVector) projection(new OpenMapRealVector(v));
}
/** {@inheritDoc} */
@@ -1128,7 +1128,7 @@
}
/**
- * Optimized method to subtract SparseRealVectors.
+ * Optimized method to subtract OpenMapRealVectors.
* @param v The vector to subtract from <code>this</code>
* @return The difference of <code>this</code> and <code>v</code>
* @throws IllegalArgumentException If the dimensions don't match
@@ -1150,7 +1150,7 @@
}
/** {@inheritDoc} */
- public RealVector subtract(RealVector v) throws IllegalArgumentException {
+ public OpenMapRealVector subtract(RealVector v) throws IllegalArgumentException {
checkVectorDimensions(v.getDimension());
if (v instanceof OpenMapRealVector) {
return subtract((OpenMapRealVector) v);
@@ -1159,7 +1159,7 @@
}
/** {@inheritDoc} */
- public RealVector subtract(double[] v) throws IllegalArgumentException {
+ public OpenMapRealVector subtract(double[] v) throws IllegalArgumentException {
checkVectorDimensions(v.length);
OpenMapRealVector res = new OpenMapRealVector(this);
for (int i = 0; i < v.length; i++) {
@@ -1174,8 +1174,8 @@
/** {@inheritDoc} */
- public RealVector unitVector() {
- RealVector res = copy();
+ public OpenMapRealVector unitVector() {
+ OpenMapRealVector res = copy();
res.unitize();
return res;
}
@@ -1297,4 +1297,9 @@
return true;
}
+ /** {@inheritDoc} */
+ public double getSparcity() {
+ return (double)entries.size()/(double)getDimension();
+ }
+
}
Added: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java?rev=775784&view=auto
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java (added)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java Mon May 18 00:42:41 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.linear;
+
+/**
+ * Marker interface for {@link RealMatrix} implementations that require sparse backing storage
+ *
+ * @version $Revision: 775768 $ $Date: 2009-05-17 15:12:50 -0700 (Sun, 17 May 2009) $
+ * @since 2.0
+ *
+ */
+public interface SparseRealMatrix extends RealMatrix {
+
+ /**
+ * Type to identify the shape of the matrix
+ */
+ public static enum MatrixShape {Any};
+
+ /**
+ *
+ * @return the shape of the matrix
+ */
+ MatrixShape getShape();
+
+}
Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealMatrix.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java?rev=775784&view=auto
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java (added)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java Mon May 18 00:42:41 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.linear;
+
+/**
+ * Marker interface for RealVectors that require sparse backing storage
+ * @version $Revision: 728186 $ $Date: 2009-05-17 15:12:50 -0700 (Sun, 17 May 2009) $
+ * @since 2.0
+ *
+ */
+public interface SparseRealVector extends RealVector {
+
+ /**
+ *
+ * @return the percentage of none zero elements as a decimal percent.
+ */
+ double getSparcity ();
+
+}
Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SparseRealVector.java
------------------------------------------------------------------------------
svn:keywords = Id