<commit_before>package se.lu.esss.ics.jels.tools.math;

import xal.tools.math.fnc.poly.RealUnivariatePolynomial;

public class MeanFieldPolynomial extends RealUnivariatePolynomial {	
	private RealUnivariatePolynomial TTF, TTFPrime, STF, STFPrime;
	
	public MeanFieldPolynomial(RealUnivariatePolynomial TTF, RealUnivariatePolynomial TTFPrime, RealUnivariatePolynomial STF, RealUnivariatePolynomial STFPrime)
	{
		this.TTF = TTF;
		this.TTFPrime = TTFPrime;
		this.STF = STF;
		this.STFPrime = STFPrime;
	}

	@Override
    public double evaluateAt(double dblVal) {
    	/*double T = TTF.evaluateAt(dblVal);
    	double S = STF.evaluateAt(dblVal);
    	return Math.sqrt(T*T+S*S);*/
    	return TTF.evaluateAt(dblVal);
    }

    @Override
    public double derivativeAt(double dblVal) {
    	/*double T = TTF.evaluateAt(dblVal);
    	double S = STF.evaluateAt(dblVal);
    	double Tp = 0.01*TTFPrime.evaluateAt(dblVal);
    	double Sp = 0.01*STFPrime.evaluateAt(dblVal);
    	return (T*Sp-Tp*S)/Math.sqrt(T*T+S*S);*/
    	//return TTF.evaluateDerivativeAt(dblVal);
    	return 0.01*TTFPrime.evaluateAt(dblVal);
	}
    
    public double getCoef(int iOrder)   {
    	return 1.0;
    }
}
<commit_msg>Fixed types. derivativeAt() now computes the derivative from TTF if TTFPrime is not provided.<commit_after>package se.lu.esss.ics.jels.tools.math;

public class MeanFieldPolynomial extends InverseRealPolynomial {

    private InverseRealPolynomial TTF, TTFPrime, STF, STFPrime;

    public MeanFieldPolynomial(InverseRealPolynomial TTF, InverseRealPolynomial TTFPrime, InverseRealPolynomial STF, InverseRealPolynomial STFPrime) {
        this.TTF = TTF;
        this.TTFPrime = TTFPrime;
        this.STF = STF;
        this.STFPrime = STFPrime;
    }

    @Override
    public double evaluateAt(double dblVal) {
        return TTF.evaluateAt(dblVal);
    }

    @Override
    public double derivativeAt(double dblVal) {
        // If TTFPrime coefficients are not provided, it uses TTF
        if (TTFPrime.getCoef(0) != 0) {
            return 0.01 * TTFPrime.evaluateAt(dblVal);
        } else {
            return TTF.derivativeAt(dblVal);
        }
    }

    @Override
    public double getCoef(int iOrder) {
        return TTF.getCoef(iOrder); // TODO: return coefficients of all polynomials
    }
}

{'fraction_non_alphanumeric': 0.09730668983492616, 'fraction_numerical': 0.0069504778453518675, 'mean_word_length': 3.304672897196262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6649775', 'n_tokens_mistral': 884, 'n_tokens_neox': 808, 'n_words': 162}