📄 polynomialcurvefitting.java
字号:
/**
* Description: Polynomial fitting function
*
* @ Author Create/Modi Note
* Xiaofeng Xie Jun 26, 2008
*
* @version 1.0
* @Since MAOS1.0
*
*/
package problem.custom;
public class PolynomialCurveFitting extends AbstractCurveFitting {
private static int NG = 2;
double[] xc = new double[NG];
private double minY = -100;
private double maxY = 100;
public PolynomialCurveFitting() throws Exception {
super(NG);
}
public void initEncoder() throws Exception {
if (NG!=2) {
initParams(NG);
xc = new double[NG];
}
super.initEncoder();
setDefaultXRanges();
}
public boolean setParameter(String name, String value) {
if (super.setParameter(name, value)) return true;
else if (name.equalsIgnoreCase("NG")) NG=new Integer(value).intValue();
else if (name.equalsIgnoreCase("minY")) minY=new Integer(value).intValue();
else if (name.equalsIgnoreCase("maxY")) maxY=new Integer(value).intValue();
else return false;
return true;
}
private void setDefaultXRanges() {
for(int i=0; i<NG; i++) {
setDefaultXAt(i, minY, maxY);
}
}
protected double getFuncValue(double x, double[] VX) {
return getBasicFuncValue(Math.abs(x), 0, VX);
}
protected double getBasicFuncValue(double x, int vxIndex, double[] VX) {
xc[0] = x;
int number = VX.length-1;
for (int i=1; i<number; i++) {
xc[i] = xc[0]*xc[i-1];
}
double realV = VX[vxIndex];
for (int i=0; i<number; i++) {
realV += VX[vxIndex+i+1]*xc[i];
}
return realV;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -