//+++++++++++++++++++++++++++++++++++++++++++++++++++++
// File automatically generated by Xfuzzy - DO NOT EDIT
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
package pkg.xfsg.mfunc;
import xfuzzy.lang.*;
public class rectangle extends ParamMemFunc {
public rectangle() {
super("xfsg","rectangle");
Parameter single[] = new Parameter[2];
single[0] = new Parameter("a");
single[1] = new Parameter("b");
setSingleParameters(single);
}
public double compute(double x) {
double a = singleparam[0].value;
double b = singleparam[1].value;
return (a<=x && x<=b? 1 : 0);
}
public double greatereq(double x) {
double a = singleparam[0].value;
double b = singleparam[1].value;
return (x>=a? 1 : 0);
}
public double smallereq(double x) {
double a = singleparam[0].value;
double b = singleparam[1].value;
return (x<=b? 1 : 0);
}
public double center() {
double a = singleparam[0].value;
double b = singleparam[1].value;
return (a+b)/2;
}
public double basis() {
double a = singleparam[0].value;
double b = singleparam[1].value;
return (b-a);
}
public double[] deriv_center() {
double[] deriv = new double[getNumberOfParameters()];
double a = singleparam[0].value;
double b = singleparam[1].value;
deriv[0] = 1; deriv[1] = 1;
return deriv;
}
public double[] deriv_basis() {
double[] deriv = new double[getNumberOfParameters()];
double a = singleparam[0].value;
double b = singleparam[1].value;
deriv[0] = -1; deriv[1] = 1;
return deriv;
}
public boolean test () {
double min = this.u.min();
double max = this.u.max();
double a = singleparam[0].value;
double b = singleparam[1].value;
return ( a<b && a>=min && b<=max
);
}
public void update() {
if(!isAdjustable()) return;
double[] pos = get();
double[] desp = getDesp();
boolean[] adj = getAdjustable();
double min = this.u.min();
double max = this.u.max();
double step = this.u.step();
double a = singleparam[0].value;
double b = singleparam[1].value;
a += desp[0];
b += desp[1];
if(a<min) a = min;
if(b>max) b = max;
if(a>=b) {
if(!adj[0]) b = a + step;
else if(!adj[1]) a = b - step;
else { a = (a+b-step)/2; b = a+step; }
}
pos[0] = a;
pos[1] = b;
updateValues(pos);
}
public String getEqualJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a<=x && x<=b? 1 : 0); "+eol;
return code;
}
public String getGreqJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x>=a? 1 : 0); "+eol;
return code;
}
public String getSmeqJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x<=b? 1 : 0); "+eol;
return code;
}
public String getCenterJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a+b)/2; "+eol;
return code;
}
public String getBasisJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (b-a); "+eol;
return code;
}
public String getEqualCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a<=x && x<=b? 1 : 0); "+eol;
return code;
}
public String getGreqCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x>=a? 1 : 0); "+eol;
return code;
}
public String getSmeqCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x<=b? 1 : 0); "+eol;
return code;
}
public String getCenterCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a+b)/2; "+eol;
return code;
}
public String getBasisCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (b-a); "+eol;
return code;
}
public String getEqualCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a<=x && x<=b? 1 : 0); "+eol;
return code;
}
public String getGreqCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x>=a? 1 : 0); "+eol;
return code;
}
public String getSmeqCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (x<=b? 1 : 0); "+eol;
return code;
}
public String getCenterCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (a+b)/2; "+eol;
return code;
}
public String getBasisCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " return (b-a); "+eol;
return code;
}
}