SparseDoubleVector extends AbstractVector { @Override public void subtractConstant(final double constant) { this.setIsChanged(); this.addConstant(-1 * constant); } SparseDoubleVector(final int[] indices, final double[] values, final int dimension);  SparseDoubleVector(final int dimension);  SparseDoubleVector(final double[] data);  SparseDoubleVector(final SparseVector mtjVector); @Override void addVector(final double[] vectorAsArray); @Override void subtractVector(final double[] vectorAsArray); @Override void multiplyByVectorPairwise(final double[] vectorAsArray); @Override void divideByVectorPairwise(final double[] vectorAsArray); @Override double dotProduct(final double[] vectorAsArray); @Override int length(); @Override double getValue(final int index); @Override void setValue(final int index, final double value); @Override void addVector(final IVector vector); @Override void subtractVector(final IVector vector); @Override void multiplyByVectorPairwise(final IVector secondVector); @Override void multiplyByConstant(final double constant); @Override void divideByVectorPairwise(final IVector secondVector); @Override void divideByConstant(final double constant); @Override double dotProduct(final IVector vector); @Override boolean isSparse(); @Override double[] asArray(); @Override DenseDoubleVector toDenseVector(); @Override SparseDoubleVector toSparseVector(); @Override IVector duplicate(); @Override void normalize(); @Override void addConstant(final double constant); @Override void subtractConstant(final double constant); @Override void fillRandomly(); int[] getNonZeroIndices(); @Override IVector kroneckerProduct(final double[] vectorAsArray); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testSubtractConstantWithoutCopy() { double[] data = { 8, 8 }; double toSubtract = 4; IVector vector = new SparseDoubleVector(data); vector.subtractConstant(toSubtract); this.assertResultVectorIs4(vector); }