diff --git a/Equivalent mutations/twodmatrix.class b/Equivalent mutations/twodmatrix.class new file mode 100644 index 0000000000000000000000000000000000000000..4ab1782d5139af8f3f597b41d4d01735b25fdeab Binary files /dev/null and b/Equivalent mutations/twodmatrix.class differ diff --git a/Results/Daikon results.txt b/Results/Daikon results.txt index 1bddbc38655d26470f1040d54b7423996338575c..4dd99b357566b0489de3c070094188bf2899cfb6 100644 --- a/Results/Daikon results.txt +++ b/Results/Daikon results.txt @@ -10,7 +10,7 @@ GradientFunction: 0 mutations with unterminated calls 0 mutations stuck in a loop -BaseSecantSolver (doSolve not checked yet): +BaseSecantSolver: 0 mutations with error found: 0 mutations with error found not detected by wlp: 0 mutations with unterminated calls diff --git a/Tests/BaseSecantSolver.java b/Tests/BaseSecantSolver.java index 2bcf1dce105e49ec16ae820411a7ba78518107f2..b73e491db4e04bb6a0434dab36821b65cd442ca5 100644 --- a/Tests/BaseSecantSolver.java +++ b/Tests/BaseSecantSolver.java @@ -28,6 +28,9 @@ import org.apache.commons.math3.exception.NullArgumentException; import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.commons.math3.util.FastMath; +import org.apache.commons.math3.exception.TooManyEvaluationsException; + +import org.apache.commons.math3.analysis.function.Abs; /** * Base class for all bracketing <em>Secant</em>-based methods for root-finding @@ -109,13 +112,11 @@ public class BaseSecantSolver this.method = method3; } - public final double doSolve() + public static double doSolve1(final double ftol, final double atol, final double rtol, double x0, double x1, Method method, AllowedSolution allowed, Abs function) throws ConvergenceException { - // Get initial solution - double x0 = getMin(); - double x1 = getMax(); - double f0 = computeObjectiveValue(x0); - double f1 = computeObjectiveValue(x1); + + double f0 = computeObjectiveValue1(x0, function); + double f1 = computeObjectiveValue1(x1, function); // If one of the bounds is the exact root, return it. Since these are // not under-approximations or over-approximations, we can return them @@ -128,22 +129,17 @@ public class BaseSecantSolver } // Verify bracketing of initial solution. - verifyBracketing(x0, x1); - - // Get accuracies. - final double ftol = getFunctionValueAccuracy(); - final double atol = getAbsoluteAccuracy(); - final double rtol = getRelativeAccuracy(); + // verifyBracketing(x0, x1); // Keep track of inverted intervals, meaning that the left bound is // larger than the right bound. boolean inverted = false; - + // Keep finding better approximations. - while (true) { + for(int i = 0; i < 100; i++) { // Calculate the next approximation. final double x = x1 - ((f1 * (x1 - x0)) / (f1 - f0)); - final double fx = computeObjectiveValue(x); + final double fx = computeObjectiveValue1(x, function); // If the new approximation is the exact root, return it. Since // this is not an under-approximation or an over-approximation, @@ -160,7 +156,7 @@ public class BaseSecantSolver f0 = f1; inverted = !inverted; } else { - switch (this.method) { + switch (method) { case ILLINOIS: f0 *= 0.5; break; @@ -187,7 +183,7 @@ public class BaseSecantSolver // given the function value accuracy, then we can't get closer to // the root than we already are. if (FastMath.abs(f1) <= ftol) { - switch (this.allowed) { + switch (allowed) { case ANY_SIDE: return x1; case LEFT_SIDE: @@ -219,7 +215,7 @@ public class BaseSecantSolver // are satisfied with the current approximation. if (FastMath.abs(x1 - x0) < FastMath.max(rtol * FastMath.abs(x1), atol)) { - switch (this.allowed) { + switch (allowed) { case ANY_SIDE: return x1; case LEFT_SIDE: @@ -235,6 +231,7 @@ public class BaseSecantSolver } } } + throw new ConvergenceException(); } protected enum Method { @@ -251,7 +248,7 @@ public class BaseSecantSolver return (a + b) * 0.5; } - public static boolean isBracketing(UnivariateFunction function1, + public static boolean isBracketing(Abs function1, final double lower1, final double upper1) throws NullArgumentException { @@ -286,7 +283,7 @@ public class BaseSecantSolver verifyInterval1(initial, upper3); } - public static void verifyBracketing(UnivariateFunction function2, + public static void verifyBracketing(Abs function2, final double lower4, final double upper4) throws NullArgumentException, @@ -318,4 +315,17 @@ public class BaseSecantSolver { return 0; } + + + public final double doSolve() + throws ConvergenceException + { + return 0; + } + + + protected static double computeObjectiveValue1(double point, Abs function) + { + return function.value(point); + } } diff --git a/daikon equivalent mutations/2D_to_1D.java b/daikon equivalent mutations/2D_to_1D.java new file mode 100644 index 0000000000000000000000000000000000000000..fa8d22ac63b0e7a6794243d9585eedfd1ffbfc1b --- /dev/null +++ b/daikon equivalent mutations/2D_to_1D.java @@ -0,0 +1,71 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + this.b = new int[this.m * this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + //System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = 1;//System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + //System.out.printf("{0}\t", this.a[i2][j2]); + + } + //System.out.printf("\n"); + } + } + public void convert() + { + int k = 0; + for (int i3 = 0; i3 < this.m; i3++) + { + for (int j3 = 0; j3 < this.n; j3++) + { + this.b[k++] = this.a[i3][j3]; + } + } + } + public void printoned() + { + this.convert(); + + for (int i4 = 0; i4 < this.m * this.n; i4++) + { + //System.out.printf("{0}\t", this.b[i4]); + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + //System.out.printf("Enter the Elements : "); + obj.readmatrix(); + //System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + //System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/BST.java b/daikon equivalent mutations/BST.java new file mode 100644 index 0000000000000000000000000000000000000000..bfd412b89062bfc3a6b3fd77a704cd32f7d0668d --- /dev/null +++ b/daikon equivalent mutations/BST.java @@ -0,0 +1,136 @@ +// http://www.sanfoundry.com/csharp-program-binary-search-tree-linked-list/ + +/* + * C# Program to Implement Binary Search Tree using Linked List + */ + +class Node +{ + public int item; + public Node leftc; + public Node rightc; + + public Node(int item, Node leftc, Node rightc) + { + this.item = item; + this.leftc = leftc; + this.rightc = rightc; + } + + public Node() + {} + + public void display() + { + //System.out.print("["); + //System.out.print(this.item); + //System.out.print("]"); + } +} + +class Tree +{ + public Node root; + + public Tree() + { + this.root = null; + } + public Node ReturnRoot() + { + return this.root; + } + public void Insert(int id) + { + Node newNode = new Node(); + newNode.item = id; + if (this.root == null) + this.root = newNode; + else + { + Node current = this.root; + Node parent; + + while (true) + { + parent = current; + if (id < current.item) + { + current = current.leftc; + if (current == null) + { + parent.leftc = newNode; + return; + } + } + else + { + current = current.rightc; + if (current == null) + { + parent.rightc = newNode; + return; + } + } + } + } + } + public void Preorder(Node root1) + { + if (root1 != null) + { + //System.out.print(root1.item + " "); + Preorder(root1.leftc); + Preorder(root1.rightc); + } + } + public void Inorder(Node root2) + { + if (root2 != null) + { + Inorder(root2.leftc); + //System.out.print(root2.item + " "); + Inorder(root2.rightc); + } + } + public void Postorder(Node root3) + { + if (root3 != null) + { + Postorder(root3.leftc); + Postorder(root3.rightc); + //System.out.print(root3.item + " "); + } + } +} + +class Program +{ + static void main(String[] args) + { + Tree theTree = new Tree(); + theTree.Insert(20); + theTree.Insert(25); + theTree.Insert(45); + theTree.Insert(15); + theTree.Insert(67); + theTree.Insert(43); + theTree.Insert(80); + theTree.Insert(33); + theTree.Insert(67); + theTree.Insert(99); + theTree.Insert(91); + //System.out.println("Inorder Traversal : "); + theTree.Inorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.out.println(); + //System.out.println("Preorder Traversal : "); + theTree.Preorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.out.println(); + //System.out.println("Postorder Traversal : "); + theTree.Postorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.in.read(); + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/Fibonacci.java b/daikon equivalent mutations/Fibonacci.java new file mode 100644 index 0000000000000000000000000000000000000000..c8a9a179e02052462280fc1d88115f861e2c22ad --- /dev/null +++ b/daikon equivalent mutations/Fibonacci.java @@ -0,0 +1,26 @@ +// http://www.sanfoundry.com/csharp-program-generate-fibonocci-series/ + +/* + * C# Program to Generate Fibonacci Series + */ + +class Program +{ + static void main(String[] args) + { + int i, count, f1 = 0, f2 = 1, f3 = 0; + System.out.print("Enter the Limit : "); + count = System.in.read(); + System.out.println(f1); + System.out.println(f2); + for (i = 0; i <= count; i++) + { + f3 = f1 + f2; + System.out.println(f3); + f1 = f2; + f2 = f3; + } + System.in.read(); + + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/MinsMaxs.class b/daikon equivalent mutations/MinsMaxs.class new file mode 100644 index 0000000000000000000000000000000000000000..5f83d096ab741961b9ef06e1f0ca6685b6ac9932 Binary files /dev/null and b/daikon equivalent mutations/MinsMaxs.class differ diff --git a/daikon equivalent mutations/MinsMaxs.java b/daikon equivalent mutations/MinsMaxs.java new file mode 100644 index 0000000000000000000000000000000000000000..bb10fc1e684bb631b9ffd7cb7d8143a01892cadf --- /dev/null +++ b/daikon equivalent mutations/MinsMaxs.java @@ -0,0 +1,37 @@ + +public class MinsMaxs { + + /** + * Given an NxM matrix of double-values, calculate the minimum and maximum of every column in the matrix. + * The mins and maxs are returned as a pair of arrays. + */ + static public double[][] getMinsMaxs(double[][] data) { + int N = data.length ; + if (N < 1) throw new IllegalArgumentException() ; + int rowWidth = data[0].length ; + // check if every row has the same length: + for (int r1=1; r1<N; r1++) + if (data[r1].length != rowWidth) throw new IllegalArgumentException() ; + + double[] mins = new double[rowWidth] ; + double[] maxs = new double[rowWidth] ; + // initialize mins and maxs: + for (int c1=0; c1<rowWidth; c1++) { + mins[c1] =data[0][c1] ; + maxs[c1] =data[0][c1] ; + } + // iterate over the matrix: + for (int r=1; r<N; r++) { + for (int c=0; c<rowWidth; c++) { + if (data[r][c] <= mins[c]) mins[c] = data[r][c] ; // mutate this + if (data[r][c] >= maxs[c]) maxs[c] = data[r][c] ; // mutate this + } + } + double[][] output = new double[2][] ; + output[0] = mins ; + output[1] = maxs ; + return output ; + } + + +} diff --git a/daikon equivalent mutations/Mutants/2D_to_1D_no_1D.java b/daikon equivalent mutations/Mutants/2D_to_1D_no_1D.java new file mode 100644 index 0000000000000000000000000000000000000000..ce06d680ede3e147dc5e1420d5d8917281645b96 --- /dev/null +++ b/daikon equivalent mutations/Mutants/2D_to_1D_no_1D.java @@ -0,0 +1,60 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + //System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = 1; //System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + //System.out.printf("{0}\t", this.a[i2][j2]); + + } + //System.out.printf("\n"); + } + } + public void printoned() + { + for (int i4 = 0; i4 < this.m; i4++) + { + for (int j4 = 0; j4 < this.n; j4++) + { + //Console.WriteLine("{0}\t", a[i*n+j]); + } + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + //System.out.printf("Enter the Elements : "); + obj.readmatrix(); + //System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + //System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/Mutants/2D_to_1D_no_counter.java b/daikon equivalent mutations/Mutants/2D_to_1D_no_counter.java new file mode 100644 index 0000000000000000000000000000000000000000..f4baed1fbb10f4aa343c6a970c0e1c2397a2a964 --- /dev/null +++ b/daikon equivalent mutations/Mutants/2D_to_1D_no_counter.java @@ -0,0 +1,70 @@ +//http://www.sanfoundry.com/csharp-program-convert-2darray-1darray/ + + +class twodmatrix +{ + int m, n; + int[][] a; + int[] b; + twodmatrix(int x, int y) + { + this.m = x; + this.n = y; + this.a = new int[this.m][this.n]; + this.b = new int[this.m * this.n]; + } + public void readmatrix() + { + for (int i1 = 0; i1 < this.m; i1++) + { + for (int j1 = 0; j1 < this.n; j1++) + { + //System.out.printf("a[{0},{1}]=", i1, j1); + this.a[i1][j1] = 1; //System.in.read(); + } + } + } + public void printd() + { + for (int i2 = 0; i2 < this.m; i2++) + { + for (int j2 = 0; j2 < this.n; j2++) + { + //System.out.printf("{0}\t", this.a[i2][j2]); + + } + //System.out.printf("\n"); + } + } + public void convert() + { + for (int i3 = 0; i3 < this.m; i3++) + { + for (int j3 = 0; j3 < this.n; j3++) + { + this.b[i3*this.n+j3] = this.a[i3][j3]; + } + } + } + public void printoned() + { + this.convert(); + + for (int i4 = 0; i4 < this.m * this.n; i4++) + { + //System.out.printf("{0}\t", this.b[i4]); + } + } + + + public static void main(String[] args) + { + twodmatrix obj = new twodmatrix(2,3); + //System.out.printf("Enter the Elements : "); + obj.readmatrix(); + //System.out.printf("\t\t Given 2-D Array(Matrix) is : "); + obj.printd(); + //System.out.printf("\t\t Converted 1-D Array is : "); + obj.printoned(); + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/Mutants/BST_no_parent.java b/daikon equivalent mutations/Mutants/BST_no_parent.java new file mode 100644 index 0000000000000000000000000000000000000000..48b1971c472f8e3c82d167565b0a4e94e46acec6 --- /dev/null +++ b/daikon equivalent mutations/Mutants/BST_no_parent.java @@ -0,0 +1,133 @@ +// http://www.sanfoundry.com/csharp-program-binary-search-tree-linked-list/ + +/* + * C# Program to Implement Binary Search Tree using Linked List + */ + +class Node +{ + public int item; + public Node leftc; + public Node rightc; + + public Node(int item, Node leftc, Node rightc) + { + this.item = item; + this.leftc = leftc; + this.rightc = rightc; + } + + public Node() + {} + + public void display() + { + //System.out.print("["); + //System.out.print(this.item); + //System.out.print("]"); + } +} + +class Tree +{ + public Node root; + + public Tree() + { + this.root = null; + } + public Node ReturnRoot() + { + return this.root; + } + public void Insert(int id) + { + Node newNode = new Node(); + newNode.item = id; + if (this.root == null) + this.root = newNode; + else + { + Node current = this.root; + while (true) + { + if (id < current.item) + { + if (current.leftc == null) + { + current.leftc = newNode; + return; + } + current = current.leftc; + } + else + { + if (current.rightc == null) + { + current.rightc = newNode; + return; + } + current = current.rightc; + } + } + } + } + public void Preorder(Node root1) + { + if (root1 != null) + { + //System.out.print(root1.item + " "); + Preorder(root1.leftc); + Preorder(root1.rightc); + } + } + public void Inorder(Node root2) + { + if (root2 != null) + { + Inorder(root2.leftc); + //System.out.print(root2.item + " "); + Inorder(root2.rightc); + } + } + public void Postorder(Node root3) + { + if (root3 != null) + { + Postorder(root3.leftc); + Postorder(root3.rightc); + //System.out.print(root3.item + " "); + } + } +} + +class Program +{ + static void main(String[] args) + { + Tree theTree = new Tree(); + theTree.Insert(20); + theTree.Insert(25); + theTree.Insert(45); + theTree.Insert(15); + theTree.Insert(67); + theTree.Insert(43); + theTree.Insert(80); + theTree.Insert(33); + theTree.Insert(67); + theTree.Insert(99); + theTree.Insert(91); + //System.out.println("Inorder Traversal : "); + theTree.Inorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.out.println(); + //System.out.println("Preorder Traversal : "); + theTree.Preorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.out.println(); + //System.out.println("Postorder Traversal : "); + theTree.Postorder(theTree.ReturnRoot()); + //System.out.println(" "); + //System.in.read(); + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/Mutants/Fibonacci_no_extra_prints.java b/daikon equivalent mutations/Mutants/Fibonacci_no_extra_prints.java new file mode 100644 index 0000000000000000000000000000000000000000..e45c9c68f43cd54b05b24d83afc9054637219906 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Fibonacci_no_extra_prints.java @@ -0,0 +1,24 @@ +// http://www.sanfoundry.com/csharp-program-generate-fibonocci-series/ + +/* + * C# Program to Generate Fibonacci Series + */ + +class Program +{ + static void main(String[] args) + { + int i, count, f1 = 0, f2 = 1, f3 = 0; + System.out.print("Enter the Limit : "); + count = System.in.read(); + for (i = 0; i <= count + 2; i++) + { + f3 = f1 + f2; + System.out.println(f1); + f1 = f2; + f2 = f3; + } + System.in.read(); + + } +} \ No newline at end of file diff --git a/daikon equivalent mutations/Mutants/MinsMaxs_R1.java b/daikon equivalent mutations/Mutants/MinsMaxs_R1.java new file mode 100644 index 0000000000000000000000000000000000000000..36c873adceacdc79b26e07578c3d6f3d9273ec4e --- /dev/null +++ b/daikon equivalent mutations/Mutants/MinsMaxs_R1.java @@ -0,0 +1,36 @@ + + +public class MinsMaxs_R1 { + + /** + * Refactoring R1: replacing some <= and >= to improve efficiency. + */ + static public double[][] getMinsMaxs(double[][] data) { + int N = data.length ; + if (N < 1) throw new IllegalArgumentException() ; + int rowWidth = data[0].length ; + // check if every row has the same lenght: + for (int r1=1; r1<N; r1++) + if (data[r1].length != rowWidth) throw new IllegalArgumentException() ; + + double[] mins = new double[rowWidth] ; + double[] maxs = new double[rowWidth] ; + // initialize mins and maxs: + for (int c1=0; c1<rowWidth; c1++) { + mins[c1] =data[0][c1] ; + maxs[c1] =data[0][c1] ; + } + // iterate over the matrix: + for (int r=1; r<data.length; r++) { + for (int c=0; c<rowWidth; c++) { + if (data[r][c] < mins[c]) mins[c] = data[r][c] ; // more efficient + if (data[r][c] > maxs[c]) maxs[c] = data[r][c] ; // more efficient + } + } + double[][] output = new double[2][] ; + output[0] = mins ; + output[1] = maxs ; + return output ; + } + +} diff --git a/daikon equivalent mutations/Mutants/MinsMaxs_R2.java b/daikon equivalent mutations/Mutants/MinsMaxs_R2.java new file mode 100644 index 0000000000000000000000000000000000000000..461b1585cf5d2b24cae15b82c8d0c54816f83a53 --- /dev/null +++ b/daikon equivalent mutations/Mutants/MinsMaxs_R2.java @@ -0,0 +1,35 @@ + +public class MinsMaxs_R2 { + + /** + * Refactoring R2: moving the check for equal length rows to inside the main loop. + */ + static public double[][] getMinsMaxs(double[][] data) { + int N = data.length ; + if (N < 1) throw new IllegalArgumentException() ; + int rowWidth = data[0].length ; + + double[] mins = new double[rowWidth] ; + double[] maxs = new double[rowWidth] ; + + // initialize mins and maxs: + for (int c1=0; c1<rowWidth; c1++) { + mins[c1] =data[0][c1] ; + maxs[c1] =data[0][c1] ; + } + // iterate over the matrix: + for (int r=1; r<data.length; r++) { + // first check if the row has the same length as data[0]: + if (data[r].length != rowWidth) throw new IllegalArgumentException() ; + for (int c=0; c<rowWidth; c++) { + if (data[r][c] <= mins[c]) mins[c] = data[r][c] ; + if (data[r][c] >= maxs[c]) maxs[c] = data[r][c] ; + } + } + double[][] output = new double[2][] ; + output[0] = mins ; + output[1] = maxs ; + return output ; + } + +} diff --git a/daikon equivalent mutations/Mutants/MinsMaxs_R3.java b/daikon equivalent mutations/Mutants/MinsMaxs_R3.java new file mode 100644 index 0000000000000000000000000000000000000000..9bc04396f7430e398bf23b3965e3b3439bab2f74 --- /dev/null +++ b/daikon equivalent mutations/Mutants/MinsMaxs_R3.java @@ -0,0 +1,35 @@ + +public class MinsMaxs_R3 { + + /** + * Refactoring R3: changing the main loop from a row-column loop, to column-row loop. + */ + static public double[][] getMinsMaxs(double[][] data) { + int N = data.length ; + if (N < 1) throw new IllegalArgumentException() ; + int rowWidth = data[0].length ; + // check if every row has the same length: + for (int r1=1; r1<N; r1++) + if (data[r1].length != rowWidth) throw new IllegalArgumentException() ; + + double[] mins = new double[rowWidth] ; + double[] maxs = new double[rowWidth] ; + // initialize mins and maxs: + for (int c1=0; c1<rowWidth; c1++) { + mins[c1] =data[0][c1] ; + maxs[c1] =data[0][c1] ; + } + // iterate over the matrix: + for (int c=0; c<rowWidth; c++) { + for (int r=1; r<N; r++) { + if (data[r][c] <= mins[c]) mins[c] = data[r][c] ; // mutate this + if (data[r][c] >= maxs[c]) maxs[c] = data[r][c] ; // mutate this + } + } + double[][] output = new double[2][] ; + output[0] = mins ; + output[1] = maxs ; + return output ; + } + +} diff --git a/daikon equivalent mutations/Mutants/Node.class b/daikon equivalent mutations/Mutants/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..f0a645ef9eb9cc339497e7914d655c0ed80cafb7 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Node.class differ diff --git a/daikon equivalent mutations/Mutants/Normalizer_R1.class b/daikon equivalent mutations/Mutants/Normalizer_R1.class new file mode 100644 index 0000000000000000000000000000000000000000..09fe05f6a43ac426feb3eff2dcd6cf8adf53e80d Binary files /dev/null and b/daikon equivalent mutations/Mutants/Normalizer_R1.class differ diff --git a/daikon equivalent mutations/Mutants/Normalizer_R1.java b/daikon equivalent mutations/Mutants/Normalizer_R1.java new file mode 100644 index 0000000000000000000000000000000000000000..860000070c4a436775cdac274fc098f11ae6ee5d --- /dev/null +++ b/daikon equivalent mutations/Mutants/Normalizer_R1.java @@ -0,0 +1,26 @@ +import java.lang.IllegalArgumentException; + +public class Normalizer_R1 { + + /** + * R1: Restructuring the check that mins and max should be of the same length. + */ + static public void normalize(double[] mins, double[] maxs, double[][] data) { + int rowWidth = mins.length ; + if (maxs.length != rowWidth) { throw new IllegalArgumentException() ; } + int row = 0 ; + while (row < data.length) { + if (data[row].length != rowWidth) { throw new IllegalArgumentException() ; } + int col = 0 ; + while (col < rowWidth) { + double delta = maxs[col] - mins[col] ; + if (delta == 0) throw new IllegalArgumentException() ; + double x = data[row][col] ; + data[row][col] = (x - mins[col])/delta ; + col++ ; + } + row++ ; + } + } + +} diff --git a/daikon equivalent mutations/Mutants/Normalizer_R2.class b/daikon equivalent mutations/Mutants/Normalizer_R2.class new file mode 100644 index 0000000000000000000000000000000000000000..202c7bf827c8a767d3ea22e6c2302515ad3e4cf9 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Normalizer_R2.class differ diff --git a/daikon equivalent mutations/Mutants/Normalizer_R2.java b/daikon equivalent mutations/Mutants/Normalizer_R2.java new file mode 100644 index 0000000000000000000000000000000000000000..062d11479f790ce04bd7657e4e999b59d1593ab3 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Normalizer_R2.java @@ -0,0 +1,31 @@ +import java.lang.IllegalArgumentException; + +public class Normalizer_R2 { + + /** + * R2: moving the element-level normalization to a separate method. + */ + static public void normalize(double[] mins, double[] maxs, double[][] data) { + int rowWidth = mins.length ; + int row = 0 ; + if (maxs.length == rowWidth) { + while (row < data.length) { + if (data[row].length != rowWidth) { throw new IllegalArgumentException() ; } + int col = 0 ; + while (col < rowWidth) { + data[row][col] = normalizeValue(data[row][col] ,mins[col],maxs[col]) ; + col++ ; + } + row++ ; + } + } + else { throw new IllegalArgumentException() ; } + } + + static private double normalizeValue(double x, double min, double max) throws IllegalArgumentException { + double delta = max - min ; + if (delta == 0) throw new IllegalArgumentException() ; + return (x - min)/delta ; + } + +} diff --git a/daikon equivalent mutations/Mutants/Normalizer_R3.class b/daikon equivalent mutations/Mutants/Normalizer_R3.class new file mode 100644 index 0000000000000000000000000000000000000000..22fff9315e7ef23deb9f7feb729799f6bcade977 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Normalizer_R3.class differ diff --git a/daikon equivalent mutations/Mutants/Normalizer_R3.java b/daikon equivalent mutations/Mutants/Normalizer_R3.java new file mode 100644 index 0000000000000000000000000000000000000000..2572093b4c82fe5f1db5cc8d4febe1f9a1ee46a7 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Normalizer_R3.java @@ -0,0 +1,24 @@ +import java.lang.IllegalArgumentException; + +public class Normalizer_R3 { + + /** + * R3: converting while loop to for loop. + */ + static public void normalize(double[] mins, double[] maxs, double[][] data) { + int rowWidth = mins.length ; + if (maxs.length == rowWidth) { + for (int row=0; row < data.length; row++) { + if (data[row].length != rowWidth) { throw new IllegalArgumentException() ; } + for (int col=0; col < rowWidth; col++) { + double delta = maxs[col] - mins[col] ; + if (delta == 0) throw new IllegalArgumentException() ; + double x = data[row][col] ; + data[row][col] = (x - mins[col])/delta ; + } + } + } + else { throw new IllegalArgumentException() ; } + } + +} diff --git a/daikon equivalent mutations/Mutants/Normalizer_R4.class b/daikon equivalent mutations/Mutants/Normalizer_R4.class new file mode 100644 index 0000000000000000000000000000000000000000..2e7b402415d9655d8ec93608c648a7859ae83880 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Normalizer_R4.class differ diff --git a/daikon equivalent mutations/Mutants/Normalizer_R4.java b/daikon equivalent mutations/Mutants/Normalizer_R4.java new file mode 100644 index 0000000000000000000000000000000000000000..9ead7687f020082b342ae24e505078f71b9e7506 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Normalizer_R4.java @@ -0,0 +1,34 @@ +import java.lang.IllegalArgumentException; +import java.lang.ArithmeticException; + +public class Normalizer_R4 { + + /** + * R4: Re-routing exceptional control flow via a different exception. + */ + static public void normalize(double[] mins, double[] maxs, double[][] data) { + int rowWidth = mins.length ; + int row = 0 ; + try { + if (maxs.length == rowWidth) { + while (row < data.length) { + if (data[row].length != rowWidth) { throw new ArithmeticException() ; } + int col = 0 ; + while (col < rowWidth) { + double delta = maxs[col] - mins[col] ; + if (delta == 0) throw new ArithmeticException() ; + double x = data[row][col] ; + data[row][col] = (x - mins[col])/delta ; + col++ ; + } + row++ ; + } + } + else { throw new IllegalArgumentException() ; } + } + catch (ArithmeticException e) { + throw new IllegalArgumentException(e) ; + } + } + +} diff --git a/daikon equivalent mutations/Mutants/Program.class b/daikon equivalent mutations/Mutants/Program.class new file mode 100644 index 0000000000000000000000000000000000000000..49448c3e5caa4f88c732917d0f22aa518d60c376 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Program.class differ diff --git a/daikon equivalent mutations/Mutants/Stack_bool_is_result.java b/daikon equivalent mutations/Mutants/Stack_bool_is_result.java new file mode 100644 index 0000000000000000000000000000000000000000..89a8d19819fef786d742b73d7e4843b90b80da6b --- /dev/null +++ b/daikon equivalent mutations/Mutants/Stack_bool_is_result.java @@ -0,0 +1,126 @@ +// http://www.sanfoundry.com/csharp-program-stack-push-pop/ + +/* + * C# Program to Implement Stack with Push and Pop operations + */ + +class Program +{ + static void main(String[] args) + { + stack st = new stack(); + while (true) + { + System.out.println("\nStack MENU(size -- 10)"); + System.out.println("1. Add an element"); + System.out.println("2. See the Top element."); + System.out.println("3. Remove top element."); + System.out.println("4. Display stack elements."); + System.out.println("5. Exit"); + System.out.print("Select your choice: "); + int choice = System.in.read(); + switch (choice) + { + case 1: + System.out.println("Enter an Element : "); + st.Push(System.in.read()); + break; + + case 2: System.out.printf("Top element is: {0}", st.Peek()); + break; + + case 3: System.out.printf("Element removed: {0}", st.Pop()); + break; + + case 4: st.Display(); + break; + + case 5: System.exit(1); + break; + } + System.in.read(); + } + } + } + + interface StackADT + { + boolean isEmpty(); + void Push(Object element); + Object Pop(); + Object Peek(); + void Display(); + } + + class stack implements StackADT + { + public int StackSize; + public int top; + Object[] item; + + public stack() + { + this.StackSize = 10; + this.item = new Object[this.StackSize]; + this.top = -1; + } + public stack(int capacity) + { + this.StackSize = capacity; + this.item = new Object[this.StackSize]; + this.top = -1; + } + public boolean isEmpty() + { + return this.top == -1; + } + public void Push(Object element) + { + if (this.top == (this.StackSize - 1)) + { + System.out.println("Stack is full!"); + } + + else + { + + this.item[++this.top] = element; + System.out.println("Item pushed successfully!"); + } + } + public Object Pop() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + + return this.item[this.top--]; + } + } + public Object Peek() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + return this.item[this.top]; + } + } + + + public void Display() + { + for (int i = this.top; i > -1; i--) + { + + System.out.printf("Item {0}: {1}", (i + 1), this.item[i]); + } + } +} diff --git a/daikon equivalent mutations/Mutants/Stack_constructor_duplication.java b/daikon equivalent mutations/Mutants/Stack_constructor_duplication.java new file mode 100644 index 0000000000000000000000000000000000000000..04c4580b8bd56facfd7bc7483a1242b327979ae3 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Stack_constructor_duplication.java @@ -0,0 +1,126 @@ +// http://www.sanfoundry.com/csharp-program-stack-push-pop/ + +/* + * C# Program to Implement Stack with Push and Pop operations + */ + +class Program +{ + static void main(String[] args) + { + stack st = new stack(); + while (true) + { + System.out.println("\nStack MENU(size -- 10)"); + System.out.println("1. Add an element"); + System.out.println("2. See the Top element."); + System.out.println("3. Remove top element."); + System.out.println("4. Display stack elements."); + System.out.println("5. Exit"); + System.out.print("Select your choice: "); + int choice = System.in.read(); + switch (choice) + { + case 1: + System.out.println("Enter an Element : "); + st.Push(System.in.read()); + break; + + case 2: System.out.printf("Top element is: {0}", st.Peek()); + break; + + case 3: System.out.printf("Element removed: {0}", st.Pop()); + break; + + case 4: st.Display(); + break; + + case 5: System.exit(1); + break; + } + System.in.read(); + } + } + } + + interface StackADT + { + boolean isEmpty(); + void Push(Object element); + Object Pop(); + Object Peek(); + void Display(); + } + + class stack implements StackADT + { + public int StackSize; + public int top; + Object[] item; + + public stack() + { + this(10); + } + public stack(int capacity) + { + this.StackSize = capacity; + this.item = new Object[this.StackSize]; + this.top = -1; + } + public boolean isEmpty() + { + if (this.top == -1) return true; + + return false; + } + public void Push(Object element) + { + if (this.top == (this.StackSize - 1)) + { + System.out.println("Stack is full!"); + } + + else + { + + this.item[++this.top] = element; + System.out.println("Item pushed successfully!"); + } + } + public Object Pop() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + + return this.item[this.top--]; + } + } + public Object Peek() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + return this.item[this.top]; + } + } + + + public void Display() + { + for (int i = this.top; i > -1; i--) + { + + System.out.printf("Item {0}: {1}", (i + 1), this.item[i]); + } + } +} diff --git a/daikon equivalent mutations/Mutants/Stack_useless_property.java b/daikon equivalent mutations/Mutants/Stack_useless_property.java new file mode 100644 index 0000000000000000000000000000000000000000..525c7c2005cf356a4083092926a465d9b7513606 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Stack_useless_property.java @@ -0,0 +1,126 @@ +// http://www.sanfoundry.com/csharp-program-stack-push-pop/ + +/* + * C# Program to Implement Stack with Push and Pop operations + */ + +class Program +{ + static void main(String[] args) + { + stack st = new stack(); + while (true) + { + System.out.println("\nStack MENU(size -- 10)"); + System.out.println("1. Add an element"); + System.out.println("2. See the Top element."); + System.out.println("3. Remove top element."); + System.out.println("4. Display stack elements."); + System.out.println("5. Exit"); + System.out.print("Select your choice: "); + int choice = System.in.read(); + switch (choice) + { + case 1: + System.out.println("Enter an Element : "); + st.Push(System.in.read()); + break; + + case 2: System.out.printf("Top element is: {0}", st.Peek()); + break; + + case 3: System.out.printf("Element removed: {0}", st.Pop()); + break; + + case 4: st.Display(); + break; + + case 5: System.exit(1); + break; + } + System.in.read(); + } + } + } + + interface StackADT + { + boolean isEmpty(); + void Push(Object element); + Object Pop(); + Object Peek(); + void Display(); + } + + class stack implements StackADT + { + public int StackSize; + public int top; + Object[] item; + + public stack() + { + this.item = new Object[10]; + this.top = -1; + } + public stack(int capacity) + { + this.item = new Object[capacity]; + this.top = -1; + } + public boolean isEmpty() + { + if (this.top == -1) return true; + + return false; + } + public void Push(Object element) + { + if (this.top == (this.StackSize - 1)) + { + System.out.println("Stack is full!"); + } + + else + { + + this.item[++this.top] = element; + System.out.println("Item pushed successfully!"); + } + } + public Object Pop() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + + return this.item[this.top--]; + } + } + public Object Peek() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + return this.item[this.top]; + } + } + + + public void Display() + { + for (int i = this.top; i > -1; i--) + { + + System.out.printf("Item {0}: {1}", (i + 1), this.item[i]); + } + } +} diff --git a/daikon equivalent mutations/Mutants/Tree.class b/daikon equivalent mutations/Mutants/Tree.class new file mode 100644 index 0000000000000000000000000000000000000000..1e07da83109b20a76bd7c38c2b6284ebe6308b26 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Tree.class differ diff --git a/daikon equivalent mutations/Mutants/Vector_R1.class b/daikon equivalent mutations/Mutants/Vector_R1.class new file mode 100644 index 0000000000000000000000000000000000000000..f314681b8d3ff54019a262960baa855eb8a97365 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Vector_R1.class differ diff --git a/daikon equivalent mutations/Mutants/Vector_R1.java b/daikon equivalent mutations/Mutants/Vector_R1.java new file mode 100644 index 0000000000000000000000000000000000000000..2bb0591bfee54b436754637bcc8b09f7b1ad5359 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Vector_R1.java @@ -0,0 +1,50 @@ + +public class Vector_R1 { + + private double[] vector; + + public Vector_R1(double[] vec) { + this.vector = new double[vec.length] ; + System.arraycopy(vec, 0, this.vector, 0, vec.length); + } + + public double[] getVector() { + int N = this.vector.length ; + double[] V = new double[N] ; + for (int k=0; k<N; k++) V[k] = this.vector[k] ; + return V ; + } + + public int getSize() { return this.vector.length ; } + + + /** + * R1 replaces the return in the INPRODUCT-case with a break. + */ + public Vector_R1 combine(int operation, Vector_R1 Z) { + final int ACCUMULATE = 1; + final int INPRODUCT = 2; + final int PLUS = 3; + if (Z.getSize() != this.vector.length) throw new IllegalArgumentException() ; + double[] result = new double[this.vector.length] ; + double[] vector2 = Z.getVector() ; + switch (operation) { + case ACCUMULATE: ; // does nothing, deliberately falling through to the code of INPRODUCT + case INPRODUCT: { + int r = 0 ; + for (int k1=0; k1<this.vector.length; k1++) r += this.vector[k1]*vector2[k1] ; + double[] rr = new double[1]; + rr[0] = r; + result = rr ; + break ; + } + case PLUS: { + for (int k2=0; k2<this.vector.length; k2++) result[k2] = this.vector[k2] + vector2[k2] ; + break ; + } + default: return null ; + } + return new Vector_R1(result) ; + } + +} diff --git a/daikon equivalent mutations/Mutants/Vector_R2.class b/daikon equivalent mutations/Mutants/Vector_R2.class new file mode 100644 index 0000000000000000000000000000000000000000..24b58c3a27a6ba06f7f612d6a540fc50d5bff844 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Vector_R2.class differ diff --git a/daikon equivalent mutations/Mutants/Vector_R2.java b/daikon equivalent mutations/Mutants/Vector_R2.java new file mode 100644 index 0000000000000000000000000000000000000000..06367dfef459ebdf1a5ed9dc32d669642a045d53 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Vector_R2.java @@ -0,0 +1,49 @@ + +public class Vector_R2 { + + private double[] vector; + + public Vector_R2(double[] vec) { + this.vector = new double[vec.length] ; + System.arraycopy(vec, 0, this.vector, 0, vec.length); + } + + public double[] getVector() { + int N = this.vector.length ; + double[] V = new double[N] ; + for (int k=0; k<N; k++) V[k] = this.vector[k] ; + return V ; + } + + public int getSize() { return this.vector.length ; } + + + /** + * R2 replaces the fall through in the ACCUMULATE case with a recursive call with INPRODUCT. + */ + public Vector_R2 combine(int operation, Vector_R2 Z) { + final int ACCUMULATE = 1; + final int INPRODUCT = 2; + final int PLUS = 3; + if (Z.getSize() != this.vector.length) throw new IllegalArgumentException() ; + double[] result = new double[this.vector.length] ; + double[] vector2 = Z.getVector() ; + switch (operation) { + case ACCUMULATE: return this.combine(INPRODUCT,Z) ; + case INPRODUCT: { + int r = 0 ; + for (int k1=0; k1<this.vector.length; k1++) r += this.vector[k1]*vector2[k1] ; + double[] rr = new double[1]; + rr[0] = r; + return new Vector_R2(rr) ; + } + case PLUS: { + for (int k2=0; k2<this.vector.length; k2++) result[k2] = this.vector[k2] + vector2[k2] ; + break ; + } + default: return null ; + } + return new Vector_R2(result) ; + } + +} diff --git a/daikon equivalent mutations/Mutants/Vector_R3.class b/daikon equivalent mutations/Mutants/Vector_R3.class new file mode 100644 index 0000000000000000000000000000000000000000..8486043ae30c9c6fe00cec33af0a5ac924dbeb60 Binary files /dev/null and b/daikon equivalent mutations/Mutants/Vector_R3.class differ diff --git a/daikon equivalent mutations/Mutants/Vector_R3.java b/daikon equivalent mutations/Mutants/Vector_R3.java new file mode 100644 index 0000000000000000000000000000000000000000..07a5d4535f8092d6f44645895a67ff1922ad50e9 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Vector_R3.java @@ -0,0 +1,50 @@ + +public class Vector_R3 { + + private double[] vector; + + public Vector_R3(double[] vec) { + this.vector = new double[vec.length] ; + System.arraycopy(vec, 0, this.vector, 0, vec.length); + } + + public double[] getVector() { + int N = this.vector.length ; + double[] V = new double[N] ; + for (int k=0; k<N; k++) V[k] = this.vector[k] ; + return V ; + } + + public int getSize() { return this.vector.length ; } + + + /** + * R3 reorder the cases, and remove the use of return from the case arms. + */ + public Vector_R3 combine(int operation, Vector_R3 Z) { + final int ACCUMULATE = 1; + final int INPRODUCT = 2; + final int PLUS = 3; + if (Z.getSize() != this.vector.length) throw new IllegalArgumentException() ; + double[] result = new double[this.vector.length] ; + double[] vector2 = Z.getVector() ; + Vector_R3 resultingVector = null ; + switch (operation) { + case PLUS: { + for (int k1=0; k1<this.vector.length; k1++) result[k1] = this.vector[k1] + vector2[k1] ; + resultingVector = new Vector_R3(result) ; + break ; } + case ACCUMULATE: ; // does nothing, deliberately falling through to the code of INPRODUCT + case INPRODUCT: { + int r = 0 ; + for (int k2=0; k2<this.vector.length; k2++) r += this.vector[k2]*vector2[k2] ; + double[] rr = new double[1]; + rr[0] = r; + resultingVector = new Vector_R3(rr) ; // we will just let it fall through + } + default: ; + } + return resultingVector ; + } + +} diff --git a/daikon equivalent mutations/Mutants/Vectors01Generator_no_for.java b/daikon equivalent mutations/Mutants/Vectors01Generator_no_for.java new file mode 100644 index 0000000000000000000000000000000000000000..0e9ba54c7962a9ec0fffe060bf0c5226d0c08b76 --- /dev/null +++ b/daikon equivalent mutations/Mutants/Vectors01Generator_no_for.java @@ -0,0 +1,38 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + vector1[index] = 0; + Gen01(index - 1, vector1); + vector1[index] = 1; + Gen01(index - 1, vector1); + } + } + + static void Print(int[] vector2) + { + for (int i2 = 0; i2 < vector2.length; i2++) + { + System.out.printf("{0} ", i2); + } + System.out.println(); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/daikon equivalent mutations/Mutants/Vectors01Generator_print_string.java b/daikon equivalent mutations/Mutants/Vectors01Generator_print_string.java new file mode 100644 index 0000000000000000000000000000000000000000..99c44ec3a08b8b6a18df1746f27f17457650aa8b --- /dev/null +++ b/daikon equivalent mutations/Mutants/Vectors01Generator_print_string.java @@ -0,0 +1,40 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + for (int i1 = 0; i1 <= 1; i1++) + { + vector1[index] = i1; + Gen01(index - 1, vector1); + } + } + } + + static void Print(int[] vector2) + { + String str = ""; + for (int i2 = 0; i2 < vector2.length; i2++) + { + str = str + Integer.toString(i2) + " "; + } + System.out.println(str); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/daikon equivalent mutations/Mutants/twodmatrix.class b/daikon equivalent mutations/Mutants/twodmatrix.class new file mode 100644 index 0000000000000000000000000000000000000000..82ba15649d47f14feccd529f953d666fb11e38ae Binary files /dev/null and b/daikon equivalent mutations/Mutants/twodmatrix.class differ diff --git a/daikon equivalent mutations/Node.class b/daikon equivalent mutations/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..4e554cd554ba44810453bc071d5a4d6fae30b7d5 Binary files /dev/null and b/daikon equivalent mutations/Node.class differ diff --git a/daikon equivalent mutations/Normalizer.class b/daikon equivalent mutations/Normalizer.class new file mode 100644 index 0000000000000000000000000000000000000000..b54f289af14676159d8883ab4f71e93fe6cf5aa9 Binary files /dev/null and b/daikon equivalent mutations/Normalizer.class differ diff --git a/daikon equivalent mutations/Normalizer.java b/daikon equivalent mutations/Normalizer.java new file mode 100644 index 0000000000000000000000000000000000000000..558bfbba3679a17d570c9a199bde1c68fa8dd886 --- /dev/null +++ b/daikon equivalent mutations/Normalizer.java @@ -0,0 +1,25 @@ +import java.lang.IllegalArgumentException; + +public class Normalizer { + + static public void normalize(double[] mins, double[] maxs, double[][] data) { + int rowWidth = mins.length ; + int row = 0 ; + if (maxs.length == rowWidth) { + while (row < data.length) { + if (data[row].length != rowWidth) { throw new IllegalArgumentException() ; } + int col = 0 ; + while (col < rowWidth) { + double delta = maxs[col] - mins[col] ; + if (delta == 0) throw new IllegalArgumentException() ; + double x = data[row][col] ; + data[row][col] = (x - mins[col])/delta ; + col++ ; + } + row++ ; + } + } + else { throw new IllegalArgumentException() ; } + } + +} diff --git a/daikon equivalent mutations/Program.class b/daikon equivalent mutations/Program.class new file mode 100644 index 0000000000000000000000000000000000000000..d6bb5df447a9f89c978cc8e8132c16f574f57650 Binary files /dev/null and b/daikon equivalent mutations/Program.class differ diff --git a/daikon equivalent mutations/Stack.java b/daikon equivalent mutations/Stack.java new file mode 100644 index 0000000000000000000000000000000000000000..cfbd48669d6abf6281a598be471feb75ad3a2eea --- /dev/null +++ b/daikon equivalent mutations/Stack.java @@ -0,0 +1,128 @@ +// http://www.sanfoundry.com/csharp-program-stack-push-pop/ + +/* + * C# Program to Implement Stack with Push and Pop operations + */ + +class Program +{ + static void main(String[] args) + { + stack st = new stack(); + while (true) + { + System.out.println("\nStack MENU(size -- 10)"); + System.out.println("1. Add an element"); + System.out.println("2. See the Top element."); + System.out.println("3. Remove top element."); + System.out.println("4. Display stack elements."); + System.out.println("5. Exit"); + System.out.print("Select your choice: "); + int choice = System.in.read(); + switch (choice) + { + case 1: + System.out.println("Enter an Element : "); + st.Push(System.in.read()); + break; + + case 2: System.out.printf("Top element is: {0}", st.Peek()); + break; + + case 3: System.out.printf("Element removed: {0}", st.Pop()); + break; + + case 4: st.Display(); + break; + + case 5: System.exit(1); + break; + } + System.in.read(); + } + } + } + + interface StackADT + { + boolean isEmpty(); + void Push(Object element); + Object Pop(); + Object Peek(); + void Display(); + } + + class stack implements StackADT + { + public int StackSize; + public int top; + Object[] item; + + public stack() + { + this.StackSize = 10; + this.item = new Object[this.StackSize]; + this.top = -1; + } + public stack(int capacity) + { + this.StackSize = capacity; + this.item = new Object[this.StackSize]; + this.top = -1; + } + public boolean isEmpty() + { + if (this.top == -1) return true; + + return false; + } + public void Push(Object element) + { + if (this.top == (this.StackSize - 1)) + { + System.out.println("Stack is full!"); + } + + else + { + + this.item[++this.top] = element; + System.out.println("Item pushed successfully!"); + } + } + + public Object Pop() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + return this.item[this.top--]; + } + } + public Object Peek() + { + if (this.isEmpty()) + { + System.out.println("Stack is empty!"); + return "No elements"; + } + else + { + return this.item[this.top]; + } + } + + + public void Display() + { + for (int i = this.top; i > -1; i--) + { + + System.out.printf("Item {0}: {1}", (i + 1), this.item[i]); + } + } +} diff --git a/daikon equivalent mutations/Tree.class b/daikon equivalent mutations/Tree.class new file mode 100644 index 0000000000000000000000000000000000000000..64be6a4a4679c2bbbca625f2edb16a53109c8b51 Binary files /dev/null and b/daikon equivalent mutations/Tree.class differ diff --git a/daikon equivalent mutations/Vector.class b/daikon equivalent mutations/Vector.class new file mode 100644 index 0000000000000000000000000000000000000000..299a1e2258e383e56fd49b71b8749e89a4011330 Binary files /dev/null and b/daikon equivalent mutations/Vector.class differ diff --git a/daikon equivalent mutations/Vector.java b/daikon equivalent mutations/Vector.java new file mode 100644 index 0000000000000000000000000000000000000000..24b4b6eac60258f7904e1df7e614043b7345a994 --- /dev/null +++ b/daikon equivalent mutations/Vector.java @@ -0,0 +1,45 @@ + + +public class Vector { + + private double[] vector; + + public Vector(double[] vec) { + this.vector = new double[vec.length] ; + System.arraycopy(vec, 0, this.vector, 0, vec.length); + } + + public double[] getVector() { + int N = this.vector.length ; + double[] V = new double[N] ; + for (int k=0; k<N; k++) V[k] = this.vector[k] ; + return V ; + } + + public int getSize() { return this.vector.length ; } + + public Vector combine(int operation, Vector Z) { + final int ACCUMULATE = 1; + final int INPRODUCT = 2; + final int PLUS = 3; + if (Z.getSize() != this.vector.length) throw new IllegalArgumentException() ; + double[] result = new double[this.vector.length] ; + double[] vector2 = Z.getVector() ; + switch (operation) { + case ACCUMULATE: ; // does nothing, deliberately falling through to the code of INPRODUCT + case INPRODUCT: { + int r = 0 ; + for (int k1=0; k1<this.vector.length; k1++) r += this.vector[k1]*vector2[k1] ; + double[] rr = new double[1]; + rr[0] = r; + return new Vector(rr) ; + } + case PLUS: { + for (int k2=0; k2<this.vector.length; k2++) result[k2] = this.vector[k2] + vector2[k2] ; + break ; + } + default: return null ; + } + return new Vector(result) ; + } +} diff --git a/daikon equivalent mutations/Vectors01Generator.java b/daikon equivalent mutations/Vectors01Generator.java new file mode 100644 index 0000000000000000000000000000000000000000..785438cf48fa8546478f3772d9a9c69776e8e4b3 --- /dev/null +++ b/daikon equivalent mutations/Vectors01Generator.java @@ -0,0 +1,39 @@ +//http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-10-recursion/#demos-source-code + +class Vectors01Generator +{ + static void Gen01(int index, int[] vector1) + { + if (index == -1) + { + Print(vector1); + } + else + { + for (int i1 = 0; i1 <= 1; i1++) + { + vector1[index] = i1; + Gen01(index - 1, vector1); + } + } + } + + static void Print(int[] vector2) + { + for (int i2 = 0; i2 < vector2.length; i2++) + { + System.out.printf("{0} ", i2); + } + System.out.println(); + } + + static void main() + { + System.out.print("n = "); + int number = System.in.read(); + + int[] vector3 = new int[number]; + + Gen01(number - 1, vector3); + } +} diff --git a/daikon equivalent mutations/twodmatrix.class b/daikon equivalent mutations/twodmatrix.class new file mode 100644 index 0000000000000000000000000000000000000000..f8fb249f0702d4a3d003edb0cf96791cf34a9533 Binary files /dev/null and b/daikon equivalent mutations/twodmatrix.class differ