SparseDoubleVector extends AbstractVector { @Override public double[] asArray() { double[] result = new double[this.internalVector.size()]; for (int i = 0; i < result.length; i++) { result[i] = this.internalVector.get(i); } return result; } 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 testAsArray() { double[] data = { 4, 2 }; IVector vector = new SparseDoubleVector(data); assertArrayEquals(data, vector.asArray(), DOUBLE_COMPARISON_DELTA); }