@Test public void testNormalize() { Vector val = test.normalize(); double mag = Math.sqrt(1.1 * 1.1 + 2.2 * 2.2 + 3.3 * 3.3); for (int i = 0; i < test.size(); i++) { if (i % 2 == 0) { assertEquals("get [" + i + ']', 0.0, val.get(i), EPSILON); } else { assertEquals("dot", values[i/2] / mag, val.get(i), EPSILON); } } }
@Override public Vector normalize() { return divide(Math.sqrt(getLengthSquared())); }
AbstractVector implements Vector, LengthCachingVector { @Override public Vector normalize() { return divide(Math.sqrt(getLengthSquared())); } }
AbstractVector implements Vector, LengthCachingVector { @Override public Vector normalize() { return divide(Math.sqrt(getLengthSquared())); } protected  AbstractVector(int size); }
AbstractVector implements Vector, LengthCachingVector { @Override public Vector normalize() { return divide(Math.sqrt(getLengthSquared())); } protected  AbstractVector(int size); @Override Iterable<Element> all(); @Override Iterable<Element> nonZeroes(); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Override double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction combiner); @Override Vector viewPart(int offset, int length); @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override Vector clone(); @Override Vector divide(double x); @Override double dot(Vector x); @Override double get(int index); @Override Element getElement(int index); @Override Vector normalize(); @Override Vector normalize(double power); @Override Vector logNormalize(); @Override Vector logNormalize(double power); Vector logNormalize(double power, double normLength); @Override double norm(double power); @Override double getLengthSquared(); @Override void invalidateCachedLength(); @Override double getDistanceSquared(Vector that); @Override double maxValue(); @Override int maxValueIndex(); @Override double minValue(); @Override int minValueIndex(); @Override Vector plus(double x); @Override Vector plus(Vector that); @Override Vector minus(Vector that); @Override void set(int index, double value); @Override void incrementQuick(int index, double increment); @Override Vector times(double x); @Override Vector times(Vector that); @Override double zSum(); @Override int getNumNonZeroElements(); @Override Vector assign(double value); @Override Vector assign(double[] values); @Override Vector assign(Vector other); @Override Vector assign(DoubleDoubleFunction f, double y); @Override Vector assign(DoubleFunction f); @Override Vector assign(Vector other, DoubleDoubleFunction function); @Override Matrix cross(Vector other); @Override final int size(); @Override String asFormatString(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); String toString(String[] dictionary); String sparseVectorToString(); }
AbstractVector implements Vector, LengthCachingVector { @Override public Vector normalize() { return divide(Math.sqrt(getLengthSquared())); } protected  AbstractVector(int size); @Override Iterable<Element> all(); @Override Iterable<Element> nonZeroes(); @Override double aggregate(DoubleDoubleFunction aggregator, DoubleFunction map); @Override double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction combiner); @Override Vector viewPart(int offset, int length); @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override Vector clone(); @Override Vector divide(double x); @Override double dot(Vector x); @Override double get(int index); @Override Element getElement(int index); @Override Vector normalize(); @Override Vector normalize(double power); @Override Vector logNormalize(); @Override Vector logNormalize(double power); Vector logNormalize(double power, double normLength); @Override double norm(double power); @Override double getLengthSquared(); @Override void invalidateCachedLength(); @Override double getDistanceSquared(Vector that); @Override double maxValue(); @Override int maxValueIndex(); @Override double minValue(); @Override int minValueIndex(); @Override Vector plus(double x); @Override Vector plus(Vector that); @Override Vector minus(Vector that); @Override void set(int index, double value); @Override void incrementQuick(int index, double increment); @Override Vector times(double x); @Override Vector times(Vector that); @Override double zSum(); @Override int getNumNonZeroElements(); @Override Vector assign(double value); @Override Vector assign(double[] values); @Override Vector assign(Vector other); @Override Vector assign(DoubleDoubleFunction f, double y); @Override Vector assign(DoubleFunction f); @Override Vector assign(Vector other, DoubleDoubleFunction function); @Override Matrix cross(Vector other); @Override final int size(); @Override String asFormatString(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); String toString(String[] dictionary); String sparseVectorToString();  }