package analyzer;

public class FeedForward {
	private float[][] mWeightO;
	private float[][] mWeightH;
	private float[] mX;
	private float[] mI;
	private float[] mO;
	private float[] mNetInputH;
	private float[] mNetInputO;
	private ActivationFunction activationFunction;
	private boolean isCorrectState = false;
	private boolean mNormalize;

	public FeedForward(float[] x, float[][] weightH, float[][] weightO, boolean normalize) {
		mWeightO = weightO;
		mWeightH = weightH;
		mX = x;
		mNormalize = normalize;
		activationFunction = new ActivationFunction();
	}

	public void applyFeedForward() {
		NetInputCalculator netInputCalculator = new NetInputCalculator(mX, mWeightH, mWeightH.length, mNormalize);
		mNetInputH = netInputCalculator.getNetInput();
		// System.out.println("netinputH");
		// for(int i=0;i<mNetInputH.length;i++)
		// System.out.println(mNetInputH[i]);
		// System.out.println();
		// System.out.println();
		mI = activationFunction.applySigmoid(mNetInputH);

		netInputCalculator = new NetInputCalculator(mI, mWeightO, mWeightO.length, mNormalize);
		mNetInputO = netInputCalculator.getNetInput();
		mO = activationFunction.applySigmoid(mNetInputO);

		isCorrectState = true;
	}

	public float[] getNetOutputI() {
		if (isCorrectState)
			return mI;
		else
			return null;
	}

	public float[] getNetOutputO() {
		if (isCorrectState)
			return mO;
		else
			return null;
	}

	public float[] getNetInputH() {
		if (isCorrectState)
			return mNetInputH;
		else
			return null;
	}

	public float[] getNetInputO() {
		if (isCorrectState)
			return mNetInputO;
		else
			return null;
	}
}
