package de.mpi.rgblab.math.numeric;
import java.util.Vector;
import de.mpi.rgblab.color.ColorModel;
public class testNumeric {
static Vector v = new Vector();
static Vector v1 = new Vector();
private static void init() {
v1.add(1);
v1.add(2);
v1.add(3);
Vector v2 = new Vector();
v2.add(4);
v2.add(5);
v2.add(6);
Vector v3 = new Vector();
v3.add(7);
v3.add(8);
v3.add(19);
v.add(v1);
v.add(v2);
v.add(v3);
}
/**
* @param args
*/
public static void main(String[] args) {
init();
if (testDet())
System.out.println("determinant test success");
test_compute_cov_matrix();
test_compute_moment();
test_compute_inverse_cov();
test_z_score();
}
public static boolean testDet() {
System.out.println("testDet");
// create matrix A = [1 2 3; 4 5 6; 7 8 19
boolean t = true;
double res = Numeric.compute_det_3_3(v);
System.out.println(res);
if (res != -30)
t = false;
return t;
}
public static boolean test_compute_moment(){
System.out.println("test_compute_moment");
boolean b = true;
Vector<Integer> v = new Vector<Integer>();
v.add(1);
v.add(10);
v.add(18);
v.add(55);
v.add(59);
Vector v1[] = new Vector[1];
v1[0] = v;
Double mean[] = new Double[1];
Double var[] = new Double[1];
Double sdev[] = new Double[1];
Numeric.compute_moment(v1, mean, var, sdev);
System.out.println(mean[0]);
System.out.println(var[0]);
System.out.println(sdev[0]);
return b;
}
public static boolean test_compute_cov_matrix() {
System.out.println("test_compute_cov_matrix");
boolean b = true;
ColorModel c1 = new ColorModel(1, 2, 3);
ColorModel c2 = new ColorModel(4, 5, 6);
ColorModel c3 = new ColorModel(7, 8, 19);
Vector v = new Vector();
v.add(c1);
v.add(c2);
v.add(c3);
System.out.println(Numeric.compute_covariance_matrix(v));
return b;
}
public static boolean test_compute_inverse_cov() {
System.out.println("test_compute_inverse_cov");
boolean b = true;
System.out.println(Numeric.compute_inverse_lab_covariance(v));
return b;
}
public static boolean test_z_score() {
System.out.println("test_z_score");
boolean b = true;
ColorModel c1 = new ColorModel(1, 2, 3);
ColorModel c2 = new ColorModel(4, 5, 6);
ColorModel c3 = new ColorModel(7, 8, 19);
ColorModel c = new ColorModel(1, 10, 5);
Vector v = new Vector();
v.add(c1);
v.add(c2);
v.add(c3);
System.out.println(Numeric.compute_z_score(c, v));
return b;
}
}