### Question:
Vectors { public static Long2DoubleMap unitVector(Long2DoubleMap v) { return multiplyScalar(v, 1.0 / euclideanNorm(v)); } private  Vectors(); static Iterator<Long2DoubleMap.Entry> fastEntryIterator(Long2DoubleMap map); static Iterable<Long2DoubleMap.Entry> fastEntries(final Long2DoubleMap map); static double sum(Long2DoubleMap v); static double sumAbs(Long2DoubleMap v); static double sumOfSquares(Long2DoubleMap v); static double sumOfSquares(Long2DoubleSortedArrayMap v); static double euclideanNorm(Long2DoubleMap v); static Long2DoubleMap unitVector(Long2DoubleMap v); static double dotProduct(Long2DoubleMap v1, Long2DoubleMap v2); static double dotProduct(Long2DoubleSortedArrayMap v1, Long2DoubleSortedArrayMap v2); static double mean(Long2DoubleMap vec); static Long2DoubleMap combine(Long2DoubleMap x, Long2DoubleFunction y, double sy, double o); static Long2DoubleMap addScalar(Long2DoubleMap vec, double val); @Nonnull static Long2DoubleMap multiplyScalar(Long2DoubleMap vector, double value); static Long2DoubleMap transform(Long2DoubleMap input, DoubleUnaryOperator function); static RealVector matrixRow(RealMatrix mat, int row);  }### Answer:
@Test public void testUnitEmpty() { Long2DoubleMap unit = Vectors.unitVector(Long2DoubleMaps.EMPTY_MAP); assertThat(unit.size(), equalTo(0)); }
@Test public void testUnitSingletonUnit() { Long2DoubleMap unit = Vectors.unitVector(Long2DoubleMaps.singleton(42L, 1.0)); assertThat(unit.size(), equalTo(1)); assertThat(unit, hasEntry(equalTo(42L), closeTo(1.0, 1.0e-6))); }
@Test public void testUnitSingleton() { Long2DoubleMap unit = Vectors.unitVector(Long2DoubleMaps.singleton(42L, 5.0)); assertThat(unit.size(), equalTo(1)); assertThat(unit, hasEntry(equalTo(42L), closeTo(1.0, 1.0e-6))); }
@Test public void testUnitVector() { for (Map<Long,Double> map: someMaps(longs(), doubles(-100, 100))) { if (map.isEmpty()) { continue; } Long2DoubleMap vec = LongUtils.frozenMap(map); double norm = Vectors.euclideanNorm(vec); Long2DoubleMap unit = Vectors.unitVector(vec); assertThat(unit.size(), equalTo(vec.size())); assertThat(unit.keySet(), equalTo(vec.keySet())); assertThat(Vectors.euclideanNorm(unit), closeTo(1.0, 1.0e-6)); Long2DoubleMaps.fastForEach(unit, e -> { assertThat(e.getDoubleValue() * norm, closeTo(vec.get(e.getLongKey()), 1.0e-6)); }); } }