use of jcog.math.tensor.ArrayTensor in project narchy by automenta.
the class TriangularWindow method get.
@Override
public ArrayTensor get(int bufferSize) {
int size = bufferSize;
ArrayTensor b = new ArrayTensor(size);
for (int i = 0; i < bufferSize; i++) {
b.data[i] = tri((i + 0.5f) / bufferSize) / bufferSize;
}
return b;
}
use of jcog.math.tensor.ArrayTensor in project narchy by automenta.
the class MeanFilter method get.
@Override
public ArrayTensor get(int bufferSize) {
int size = bufferSize;
ArrayTensor b = new ArrayTensor(size);
Arrays.fill(b.data, 1.f / bufferSize);
return b;
}
use of jcog.math.tensor.ArrayTensor in project narchy by automenta.
the class OneWindow method get.
/* (non-Javadoc)
* @see net.beadsproject.beads.data.BufferFactory#generateBuffer(int)
*/
@Override
public ArrayTensor get(int bufferSize) {
int size = bufferSize;
ArrayTensor b = new ArrayTensor(size);
Arrays.fill(b.data, 1.f);
return b;
}
use of jcog.math.tensor.ArrayTensor in project narchy by automenta.
the class TensorTest method testMatrix.
@Test
public void testMatrix() {
ArrayTensor t = new ArrayTensor(2, 2);
t.set(0.5f, 0, 0);
t.set(0.25f, 1, 0);
t.set(0.5f, 1, 1);
assertEquals(0, t.index(0, 0));
assertEquals(1, t.index(1, 0));
assertEquals(2, t.index(0, 1));
assertEquals(3, t.index(1, 1));
final String[] s = { "" };
t.forEach((i, v) -> s[0] += v + " ");
assertEquals("[0.5 0.25 0.0 0.5 ]", Arrays.toString(s));
// assertEquals(0, t.coord(0, new int[2])[0]);
// assertEquals(0, t.coord(0, new int[2])[1]);
//
// assertEquals("",Arrays.toString(t.coord(1, new int[2])));
// assertEquals(1, t.coord(1, new int[2])[0]);
// assertEquals(0, t.coord(1, new int[2])[1]);
//
// assertEquals(1, t.coord(2, new int[2])[0]);
// assertEquals(0, t.coord(2, new int[2])[1]);
//
// assertEquals(1, t.coord(3, new int[2])[0]);
// assertEquals(1, t.coord(3, new int[2])[1]);
assertEquals(0.25f, t.get(1, 0), 0.005f);
assertEquals("[2, 2]<0.5000\t0.2500\t0.0000\t0.5000>", t.toString());
}
use of jcog.math.tensor.ArrayTensor in project narchy by automenta.
the class TensorTest method testVector.
@Test
public void testVector() {
ArrayTensor t = new ArrayTensor(2);
t.set(0.1f, 0);
t.set(0.2f, 1);
assertEquals(0, t.index(0));
// assertEquals(0, t.coord(0, new int[1])[0]);
// assertEquals(1, t.coord(1, new int[1])[0]);
assertEquals("[2]<0.1000\t0.2000>", t.toString());
}
Aggregations