Adding sypet to repo
[Benchmarks_CSolver.git] / sypet / benchmarks / math / 9 / TestSource.java
diff --git a/sypet/benchmarks/math/9/TestSource.java b/sypet/benchmarks/math/9/TestSource.java
new file mode 100644 (file)
index 0000000..ad951cc
--- /dev/null
@@ -0,0 +1,19 @@
+public static boolean test0() throws Throwable {
+       double[][] mat = new double[][] { { 0, -20 }, { 10, 10 } };
+       org.apache.commons.math3.linear.RealMatrix matrix = new org.apache.commons.math3.linear.Array2DRowRealMatrix(mat);
+       org.apache.commons.math3.geometry.euclidean.twod.Vector2D result = eigenvalue(matrix, 0);
+       org.apache.commons.math3.geometry.euclidean.twod.Vector2D target = new org.apache.commons.math3.geometry.euclidean.twod.Vector2D(5, 5*Math.sqrt(7));
+       return Math.abs(result.getX() - target.getX()) < 1e-6 && Math.abs(result.getY() - target.getY()) < 1e-6;
+}
+
+public static boolean test1() throws Throwable {
+       double[][] mat = new double[][] { { 0, 2 }, { 2, 0 } };
+       org.apache.commons.math3.linear.RealMatrix matrix = new org.apache.commons.math3.linear.Array2DRowRealMatrix(mat);
+       org.apache.commons.math3.geometry.euclidean.twod.Vector2D result = eigenvalue(matrix, 1);
+       org.apache.commons.math3.geometry.euclidean.twod.Vector2D target = new org.apache.commons.math3.geometry.euclidean.twod.Vector2D(-2, 0);
+       return Math.abs(result.getX() - target.getX()) < 1e-6 && Math.abs(result.getY() - target.getY()) < 1e-6;
+}
+
+public static boolean test() throws Throwable {
+       return test0() && test1();
+}
\ No newline at end of file