public SumProduct(ChainMRFPotentials p) {
		this.potentials = p;
		
		int n = this.potentials.chainLength();
		int k = this.potentials.numXValues();
		
		this.descXtoF = new double[n+1][k+1][1];
		this.descFtoX = new double[n+1][k+1][1];
		this.ascXtoF = new double[n+1][k+1][1];
		this.ascFtoX = new double[n+1][k+1][1];
//		double[][] init = new double[k][1];
//		for (int i=0; i<init.length; i++) {
//			init[i][0] = 0;
//		}
//		this.descXtoF[0] = init;
//		this.descFtoX[0] = init;
//		this.ascXtoF[0] = init;
//		this.ascFtoX[0] = init;
		
		for (int idx=n; idx>=1; idx--) {
			if (idx == n) {
				descXtoF[n] = msgFtoX(n,n);
			} else if (idx == 1) {
				descFtoX[1] = msgFtoX(n+1,1);
			} else {
				descFtoX[idx] = msgFtoX(idx+n, idx);
				descXtoF[idx] = msgXtoF(idx, idx-1+n);
			}
		}
		
		for (int idx=1; idx<=n; idx++) {
			if (idx == 1) {
				ascXtoF[1] = msgXtoF(1,n+1);
			} else if (idx == n) {
				ascFtoX[n] = msgFtoX(idx+n-1,n);
			} else {
				ascFtoX[idx] = msgFtoX(idx-1+n, idx);
				ascXtoF[idx] = msgXtoF(idx, idx+n);
			}
		}
	}