use of org.apache.ignite.ml.math.primitives.vector.impl.VectorView in project ignite by apache.
the class VectorViewTest method setup.
/**
*/
@Before
public void setup() {
parentVector = new DenseVector(MathTestConstants.STORAGE_SIZE);
IntStream.range(0, MathTestConstants.STORAGE_SIZE).forEach(idx -> parentVector.set(idx, Math.random()));
parentData = parentVector.getStorage().data().clone();
testVector = new VectorView(parentVector, OFFSET, VIEW_LENGTH);
}
use of org.apache.ignite.ml.math.primitives.vector.impl.VectorView in project ignite by apache.
the class VectorViewTest method testWriteReadExternal.
/**
*/
@Test
public void testWriteReadExternal() throws Exception {
assertNotNull("Unexpected null parent data", parentData);
File f = new File(EXTERNALIZE_TEST_FILE_NAME);
try {
ObjectOutputStream objOutputStream = new ObjectOutputStream(new FileOutputStream(f));
objOutputStream.writeObject(testVector);
objOutputStream.close();
ObjectInputStream objInputStream = new ObjectInputStream(new FileInputStream(f));
VectorView readVector = (VectorView) objInputStream.readObject();
objInputStream.close();
assertTrue(MathTestConstants.VAL_NOT_EQUALS, testVector.equals(readVector));
} catch (ClassNotFoundException | IOException e) {
fail(e.getMessage());
}
}
Aggregations