mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
added optional scale factor to v
This commit is contained in:
parent
83812ef8d3
commit
2db38fb041
@ -28,10 +28,16 @@ public class DNN_euclidean_v implements LongFunction<float[]> {
|
|||||||
|
|
||||||
private final int D;
|
private final int D;
|
||||||
private final long N;
|
private final long N;
|
||||||
|
private final double scale;
|
||||||
|
|
||||||
public DNN_euclidean_v(int D, long N) {
|
public DNN_euclidean_v(int D, long N) {
|
||||||
|
this(D,N,1.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DNN_euclidean_v(int D, long N, double scale) {
|
||||||
this.D = D;
|
this.D = D;
|
||||||
this.N = N;
|
this.N = N;
|
||||||
|
this.scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,7 +47,7 @@ public class DNN_euclidean_v implements LongFunction<float[]> {
|
|||||||
}
|
}
|
||||||
float[] vector = new float[D];
|
float[] vector = new float[D];
|
||||||
for (int idx = 0; idx < vector.length; idx++) {
|
for (int idx = 0; idx < vector.length; idx++) {
|
||||||
vector[idx]= (float)idx+value;
|
vector[idx]= (float)((idx+value)*scale);
|
||||||
}
|
}
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,14 @@ class DNNEuclideanVTest {
|
|||||||
assertThrows(RuntimeException.class, () -> vf.apply(7));
|
assertThrows(RuntimeException.class, () -> vf.apply(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBasicVectorsScaled() {
|
||||||
|
DNN_euclidean_v vf = new DNN_euclidean_v(5, 7, 3.0);
|
||||||
|
assertThat(vf.apply(3L)).isEqualTo(new float[]{9f,12f,15f,18f,21f});
|
||||||
|
assertThrows(RuntimeException.class, () -> vf.apply(7));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrappingVectors() {
|
public void testWrappingVectors() {
|
||||||
DNN_euclidean_v_wrap vf = new DNN_euclidean_v_wrap(5, 7);
|
DNN_euclidean_v_wrap vf = new DNN_euclidean_v_wrap(5, 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user