package ec.app.complexregression.func;

import org.apache.commons.math3.complex.Complex;

import ec.EvolutionState;
import ec.Problem;
import ec.app.complexregression.ComplexData;
import ec.gp.ADFStack;
import ec.gp.GPData;
import ec.gp.GPIndividual;
import ec.gp.GPNode;

public class Mul extends GPNode {

	@Override
	public String toString() {
		return "*";
	}

	@Override
	public void eval(EvolutionState state, int thread, GPData input, ADFStack stack, GPIndividual individual,
			Problem problem) {
		ComplexData data = (ComplexData) input;
		
		children[0].eval(state, thread, input, stack, individual, problem);
		Complex x = data.x;
		children[1].eval(state, thread, input, stack, individual, problem);
		data.x = data.x.multiply(x);
		data.x = ComplexData.fixInfinity(data.x);
	}

}
