// test_math_64.java test dot and cross product of two vectors public class test_math_64 { public test_math_64() { int n = 4; double x[] = {2.0, 3.0, 4.0, 5.0}; double y[] = {5.0, -3.0, 2.0, 4.0}; double z[] = {-1.0, -1.0, -1.0, 1.0}; // initial junk double sum; System.out.println("test_math_64.c running n = "+n); System.out.println("x = "+x[0]+", "+x[1]+", "+x[2]+", "+x[3]); System.out.println("y = "+y[0]+", "+y[1]+", "+y[2]+", "+y[3]); sum = dot(x, y); System.out.println("dot(n, x, y) = "+sum); System.out.println(" "); System.out.println("x = "+x[0]+", "+x[1]+", "+x[2]+", "+x[3]); System.out.println("y = "+y[0]+", "+y[1]+", "+y[2]+", "+y[3]); cross(x, y, z); System.out.println("x cross y = z = "+z[0]+", "+z[1]+", "+z[2]+", "+z[3]); } // end test_math_64 public double dot(double x[], double y[]) { double sum = 0.0; int n = x.length; for(int i=0; i=n) k = k-n; z[m] = z[m] + x[j]*y[k]; } // end j z[m] = sign*z[m]; sign = -sign; } // end m } // end cross public static void main (String[] args) { new test_math_64(); } } // end test_math_64.java