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 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 dot(Vector x); @Override double getLengthSquared(); @Override double getDistanceSquared(Vector v); @Override void addTo(Vector v);  }
@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.size()[0]); assertEquals("col size", test.size(), result.size()[1]); for (int row = 0; row < result.size()[0]; row++) { for (int col = 0; col < result.size()[1]; col++) { assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row) * test.getQuick(col), result.getQuick(row, col), EPSILON); } } }