package exp.twostep;

import java.security.InvalidAlgorithmParameterException;

public class FuncTest {

	public static void main(String[] args) throws InvalidAlgorithmParameterException {
		
		System.out.println(System.getProperty("java.library.path"));
		MI m = new MI();
		System.out.println(System.getProperty("java.library.path"));
		
		double[][] a = new double[1][300];
		double[][] b = new double[1][300];
		double[][] c = new double[2][300];
		int k = (int)Math.ceil(300*0.16);
		System.out.println("k = " + k);
		for (int i = 0; i < 300; i++){
			a[0][i] = Math.tan(i);
			b[0][i] = Math.cos(i);
			c[0][i] = Math.sin(i);
		}
		System.out.println("k = " + k);
		
		
		
		
		double d = 0;
		d = m.partialMutualInformation(a, b, c, k);
		long t1 = System.currentTimeMillis();
		for (int i = 0; i < 10; i++){
			d = m.partialMutualInformation(a, b, c, k);

		}
		
		System.out.println(String.format("C++ based time = %1.6fs", (System.currentTimeMillis()-t1)/1000.0/10));
		System.out.println("C++ based result = " + d);
		
		partialMutualInfomation.PartialMutualInformationCalculator c2 = new partialMutualInfomation.PartialMutualInformationCalculator(a[0].length,k);
		double mi1 = c2.calculateMI(a[0], b[0]);
		double cmi1 = c2.calculatePMI(a[0], b[0], c[0]);
		System.out.println(String.format("Java based ver1 MI result = %1.6f", mi1));
		System.out.println(String.format("Java based ver1 cMI result = %1.6f", cmi1));

		partialMutualInformation2.PartialMutualInformation c3 = new partialMutualInformation2.PartialMutualInformation(k, a[0].length);
		double mi2 = c3.calculateMutualInformation(a[0], b[0]);
		double cmi2 = c3.calculatePartialMutualInformation(a[0], b[0], c[0]);
		double cmi2_1 = c3.calculatePartialMutualInformation_m(a, b, c);
		double cmi2_2 = c3.calculatePartialMutualInformation_m2(a, b, c);

		System.out.println(String.format("Java based ver2 MI result = %1.6f", mi2));
		System.out.println(String.format("Java based ver2 cMI0 result = %1.6f", cmi2));
		System.out.println(String.format("Java based ver2 cMI m1 result = %1.6f", cmi2_1));
		System.out.println(String.format("Java based ver2 cMI m2 result = %1.6f", cmi2_2));
		
		System.out.println(String.format("Java based ver1 MI result = %1.6f", mi1));
		System.out.println(String.format("Java based ver1 MI result = %1.6f", c2.calculateMI(a[0], c[0])));
		System.out.println(String.format("Java based ver1 MI result = %1.6f", c2.calculateMI(b[0], c[0])));
		
		
	}

}
