//+++++++++++++++++++++++++++++++++++++++++++++++++++++
// File automatically generated by Xfuzzy - DO NOT EDIT
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
package pkg.xfl.family;
import xfuzzy.lang.*;
public class rectangular extends Family {
public rectangular() {
super("xfl","rectangular");
Parameter single[] = new Parameter[0];
setSingleParameters(single);
setParamListName("p");
setParamList(new Parameter[0]);
}
public int members() {
double[] p = getParamListValues();
return p.length+1;
}
public double compute(int i, double x) {
double min = this.min();
double max = this.max();
double[] p = getParamListValues();
double a = (i==0? min : p[i-1]);
double b = (i==p.length? max : p[i]);
return (a<=x && x<=b? 1.0 : 0.0);
}
public double greatereq(int i, double x) {
double min = this.min();
double[] p = getParamListValues();
double a = (i==0? min : p[i-1]);
return (a<=x? 1.0 : 0.0);
}
public double smallereq(int i, double x) {
double max = this.max();
double[] p = getParamListValues();
double b = (i==p.length? max : p[i]);
return (x<=b? 1.0 : 0.0);
}
public double center(int i) {
double min = this.min();
double max = this.max();
double[] p = getParamListValues();
double a = (i==0? min : p[i-1]);
double b = (i==p.length? max : p[i]);
return (a+b)/2;
}
public double basis(int i) {
double min = this.min();
double max = this.max();
double[] p = getParamListValues();
double a = (i==0? min : p[i-1]);
double b = (i==p.length? max : p[i]);
return (b-a);
}
public boolean test () {
double min = this.min();
double max = this.max();
double[] p = getParamListValues();
return ( p.length>0 && p[0]>min && p[p.length-1]<max && sorted(p) );
}
public void update() {
if(!isAdjustable()) return;
double[] pos = get();
double[] desp = getDesp();
boolean[] adj = getAdjustable();
double min = this.min();
double max = this.max();
double step = this.step();
double[] p = getParamListValues();
pos = sortedUpdate(pos,desp,adj);
if(pos[0]<=min) {
pos[0]=min+step;
for(int i=1;i<p.length; i++) {
if(pos[i]<=pos[i-1]) pos[i] = pos[i-1]+step;
else break;
}
}
if(pos[p.length-1]>=max) {
pos[p.length-1]=max-step;
for(int i=p.length-2; i>=0; i--) {
if(pos[i]>=pos[i+1]) pos[i] = pos[i+1]-step;
else break;
}
}
updateValues(pos);
}
public String getEqualJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==p.length? max : p[i]);"+eol;
code += " return (a<=x && x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getGreqJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " return (a<=x? 1.0 : 0.0);"+eol;
return code;
}
public String getSmeqJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double b = (i==p.length? max : p[i]);"+eol;
code += " return (x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getCenterJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==p.length? max : p[i]);"+eol;
code += " return (a+b)/2;"+eol;
return code;
}
public String getBasisJavaCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==p.length? max : p[i]);"+eol;
code += " return (b-a);"+eol;
return code;
}
public String getEqualCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (a<=x && x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getGreqCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " return (a<=x? 1.0 : 0.0);"+eol;
return code;
}
public String getSmeqCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getCenterCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (a+b)/2;"+eol;
return code;
}
public String getBasisCCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (b-a);"+eol;
return code;
}
public String getEqualCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (a<=x && x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getGreqCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " return (a<=x? 1.0 : 0.0);"+eol;
return code;
}
public String getSmeqCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (x<=b? 1.0 : 0.0);"+eol;
return code;
}
public String getCenterCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (a+b)/2;"+eol;
return code;
}
public String getBasisCppCode() {
String eol = System.getProperty("line.separator", "\n");
String code = "";
code += " double a = (i==0? min : p[i-1]);"+eol;
code += " double b = (i==length? max : p[i]);"+eol;
code += " return (b-a);"+eol;
return code;
}
}