VectorView extends AbstractVector { @Override public double getQuick(int index) { return vector.getQuick(offset + index); } VectorView();  VectorView(Vector vector, int offset, int cardinality); @Override Vector clone(); @Override boolean isDense(); @Override boolean isSequentialAccess(); @Override VectorView like(); @Override Vector like(int cardinality); @Override double getQuick(int index); @Override void setQuick(int index, double value); @Override int getNumNondefaultElements(); @Override Vector viewPart(int offset, int length); @Override Iterator<Element> iterateNonZero(); @Override Iterator<Element> iterator(); @Override double getLengthSquared(); @Override double getDistanceSquared(Vector v); @Override double getLookupCost(); @Override double getIteratorAdvanceCost(); @Override boolean isAddConstantTime(); @Override void mergeUpdates(OrderedIntDoubleMapping updates);  }
@Test public void testAssignDouble() { test.assign(0); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', 0.0, test.getQuick(i), EPSILON); } }
@Test public void testAssignDoubleArray() throws Exception { double[] array = new double[test.size()]; test.assign(array); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', 0.0, test.getQuick(i), EPSILON); } }
@Test public void testAssignVector() throws Exception { Vector other = new DenseVector(test.size()); test.assign(other); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', 0.0, test.getQuick(i), EPSILON); } }
@Test public void testAssignUnaryFunction() { test.assign(Functions.NEGATE); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', -values[i + 1], test.getQuick(i), EPSILON); } }
@Test public void testAssignBinaryFunction() throws Exception { test.assign(test, Functions.PLUS); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', 2 * values[i + 1], test.getQuick(i), EPSILON); } }
@Test public void testAssignBinaryFunction2() throws Exception { test.assign(Functions.PLUS, 4); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', values[i + 1] + 4, test.getQuick(i), EPSILON); } }
@Test public void testAssignBinaryFunction3() throws Exception { test.assign(new TimesFunction(), 4); for (int i = 0; i < test.size(); i++) { assertEquals("value[" + i + ']', values[i + 1] * 4, test.getQuick(i), EPSILON); } }
@Test public void testCrossProduct() { Matrix result = test.cross(test); assertEquals("row size", test.size(), result.rowSize()); assertEquals("col size", test.size(), result.columnSize()); for (int row = 0; row < result.rowSize(); row++) { for (int col = 0; col < result.columnSize(); col++) { assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row) * test.getQuick(col), result.getQuick(row, col), EPSILON); } } }