Make use of arange rather than manually initialising tensors
Fix up some spacing problems
@@ -13,14 +13,14 @@ public class MatrixInverseVertexTest {
@Test(expected = IllegalArgumentException.class)
public void rejectsNonSquareInput() {
- DoubleTensor matrix = DoubleTensor.create(new double[]{1, 2, 3, 4, 5, 6, 7, 8}, 4, 2);
+ DoubleTensor matrix = DoubleTensor.arange(1, 9).reshape(4, 2);
shouldReject(matrix);
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNonMatrix() {
- DoubleTensor tensor = DoubleTensor.create(new double[]{1, 2, 3, 4, 5, 6, 7, 8}, 2, 2, 2);
+ DoubleTensor tensor = DoubleTensor.arange(1,9).reshape(2, 2, 2);
shouldReject(tensor);
}
@@ -32,7 +32,7 @@ public class MatrixInverseVertexTest {
@Test
public void canTakeInverseCorrectly() {
- DoubleTensor matrix = DoubleTensor.create(new double[]{1, 2, 3, 4}, 2, 2);
+ DoubleTensor matrix = DoubleTensor.arange(1,5).reshape(2, 2);
DoubleVertex inputVertex = new ConstantDoubleVertex(matrix);
DoubleVertex inverseVertex = new MatrixInverseVertex(inputVertex);
@@ -46,7 +46,7 @@ public class MatrixInverseVertexTest {
@Test
public void canCalculateDualCorrectly() {
DoubleVertex matrix = new UniformVertex(1.0, 100.0);
- matrix.setValue(DoubleTensor.create(new double[]{1, 2, 3, 4}, 2, 2));
+ matrix.setValue(DoubleTensor.arange(1, 5).reshape(2, 2));
DoubleVertex inverse = new MatrixInverseVertex(matrix);
inverse.lazyEval();
