property sets mostly, some broken method fixes
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@739908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ce2128585
commit
117175bc83
|
@ -22,12 +22,12 @@ import org.apache.commons.math.util.OpenIntToDoubleHashMap.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the {@link RealVector} interface with a {@link OpenIntToDoubleHashMap}.
|
* This class implements the {@link RealVector} interface with a {@link OpenIntToDoubleHashMap}.
|
||||||
* @version $Revision: 728186 $ $Date: 2008-12-19 16:03:13 -0800 (Fri, 19 Dec 2008) $
|
* @version $Revision: 728186 $ $Date$
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class SparseRealVector implements RealVector {
|
public class SparseRealVector implements RealVector {
|
||||||
|
|
||||||
private OpenIntToDoubleHashMap entries;
|
private final OpenIntToDoubleHashMap entries;
|
||||||
private final int virtualSize;
|
private final int virtualSize;
|
||||||
private double epsilon = 1.0e-12;
|
private double epsilon = 1.0e-12;
|
||||||
|
|
||||||
|
@ -805,10 +805,8 @@ public class SparseRealVector implements RealVector {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public RealVector mapInvToSelf() {
|
public RealVector mapInvToSelf() {
|
||||||
Iterator iter = entries.iterator();
|
for(int i=0; i < virtualSize; i++){
|
||||||
while (iter.hasNext()) {
|
set(i, 1.0/getEntry(i));
|
||||||
iter.advance();
|
|
||||||
entries.put(iter.key(), 1 / iter.value());
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -825,10 +823,8 @@ public class SparseRealVector implements RealVector {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public RealVector mapLog10ToSelf() {
|
public RealVector mapLog10ToSelf() {
|
||||||
Iterator iter = entries.iterator();
|
for(int i=0; i < virtualSize; i++){
|
||||||
while (iter.hasNext()) {
|
set(i, Math.log10(getEntry(i)));
|
||||||
iter.advance();
|
|
||||||
entries.put(iter.key(), Math.log10(iter.value()));
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -850,10 +846,8 @@ public class SparseRealVector implements RealVector {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public RealVector mapLogToSelf() {
|
public RealVector mapLogToSelf() {
|
||||||
Iterator iter = entries.iterator();
|
for(int i=0; i < virtualSize; i++){
|
||||||
while (iter.hasNext()) {
|
set(i, Math.log(getEntry(i)));
|
||||||
iter.advance();
|
|
||||||
entries.put(iter.key(), Math.log(iter.value()));
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1107,9 @@ public class SparseRealVector implements RealVector {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void set(double value) {
|
public void set(double value) {
|
||||||
entries = new OpenIntToDoubleHashMap(value);
|
for(int i=0; i < virtualSize; i++){
|
||||||
|
set(i, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
Loading…
Reference in New Issue