summaryrefslogtreecommitdiff
path: root/js/NonLinear/LOOKUP_c.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/NonLinear/LOOKUP_c.js')
-rw-r--r--js/NonLinear/LOOKUP_c.js97
1 files changed, 54 insertions, 43 deletions
diff --git a/js/NonLinear/LOOKUP_c.js b/js/NonLinear/LOOKUP_c.js
index 51ce5f2c..29655d2e 100644
--- a/js/NonLinear/LOOKUP_c.js
+++ b/js/NonLinear/LOOKUP_c.js
@@ -4,9 +4,9 @@ function LOOKUP_c() {
this.model = scicos_model();
this.xx = [[-1],[0.5],[1],[1.5],[2.5]];
this.yy = [[-6],[-1],[-3],[3],[-4]];
- N = length(this.xx);
+ var N = length(this.xx);
this.Method = 1;
- Graf = "n";
+ var Graf = "n";
this.model.sim = list(new ScilabString(["lookup_c"]), new ScilabDouble([4]));
this.model.in1 = new ScilabDouble([-1]);
this.model.in2 = new ScilabDouble([-2]);
@@ -21,8 +21,8 @@ function LOOKUP_c() {
this.model.evtin = [];
this.model.evtout = [];
this.model.firing = new ScilabDouble([0]);
- exprs = [[sci2exp(this.Method)],[sci2exp(this.xx)],[sci2exp(this.yy)],[sci2exp(0)],[Graf]];
- gr_i = [];
+ var exprs = [[sci2exp(this.Method)],[sci2exp(this.xx)],[sci2exp(this.yy)],[sci2exp(0)],[Graf]];
+ var gr_i = [];
this.x = standard_define([2,2],this.model,exprs,gr_i);
return new BasicBlock(this.x);
}
@@ -47,30 +47,30 @@ function LOOKUP_c() {
this.graf = arguments[0]["graf"]
this.x = arg1;
this.model = arg1.model;
- graphics = arg1.graphics;
- exprs = graphics.exprs;
- ok = false;
- SaveExit = false;
+ var graphics = arg1.graphics;
+ var exprs = graphics.exprs;
+ var ok = false;
+ var SaveExit = false;
while (true) {
- Ask_again = false;
+ var Ask_again = false;
[ok,this.Method,this.xx,this.yy,this.extrapo,this.graf,exprs] = scicos_getvalue("Lookup table parameters",["Spline Interpolation method (0..9)","x","y","Extrapolate method (0,1)","Launch graphic window(y/n)?"],list("vec",1,"vec",-1,"vec",-1,"vec",1,"str",1),exprs);
if (!ok) {
break;
}
- PeriodicOption = "n";
+ var PeriodicOption = "n";
if (PeriodicOption=="y"||PeriodicOption=="Y") {
- PO = 1;
+ var PO = 1;
} else {
- PO = 0;
+ var PO = 0;
}
- mtd = int(this.Method);
+ var mtd = int(this.Method);
if (mtd<0) {
- mtd = 0;
+ var mtd = 0;
}
if (mtd>9) {
- mtd = 9;
+ var mtd = 9;
}
- METHOD = getmethod(mtd);
+ var METHOD = getmethod(mtd);
this.extrapo = int(this.extrapo);
if (this.extrapo<0) {
this.extrapo = 0;
@@ -81,45 +81,53 @@ function LOOKUP_c() {
if (!Ask_again) {
this.xx = this.xx.slice();
this.yy = this.yy.slice();
- [nx,mx] = size(this.xx);
- [ny,my] = size(this.yy);
+ var tmpvar0 = size(this.xx)
+ var nx = tmpvar0[0]
+ var mx = tmpvar0[1];
+ var tmpvar1 = size(this.yy)
+ var ny = tmpvar1[0]
+ var my = tmpvar1[1];
if (!((nx==ny)&&(mx==my))) {
x_message("incompatible size of x and y");
- Ask_again = true;
+ var Ask_again = true;
}
}
if (!Ask_again) {
this.xy = [this.xx,this.yy];
- [this.xy] = cleandata(this.xy);
- N = size(this.xy,"r");
+ var tmpvar2 = cleandata(this.xy)
+ this.xy = tmpvar2[0];
+ var N = size(this.xy,"r");
exprs[5-1] = "n";
if (this.graf=="y"||this.graf=="Y") {
- ipar = [[N],[mtd],[PO],[this.extrapo]];
- rpar = [];
+ var ipar = [[N],[mtd],[PO],[this.extrapo]];
+ var rpar = [];
if (!exists("curwin")) {
- gh = gcf();
+ var gh = gcf();
this.curwin = gh.figure_id;
}
- save_curwin = this.curwin;
+ var save_curwin = this.curwin;
this.curwin = max(winsid())+1;
- [orpar,oipar,ok] = poke_point(this.xy,ipar,rpar);
+ var tmpvar3 = poke_point(this.xy,ipar,rpar)
+ var orpar = tmpvar3[0]
+ var oipar = tmpvar3[1]
+ var ok = tmpvar3[2];
this.curwin = save_curwin;
if (!ok) {
break;
}
- N2 = oipar[1-1];
- xy2 = [orpar.slice(1-1,N2),orpar.slice(N2+1-1,2*N2)];
- New_methhod = oipar[2-1];
- DChange = false;
- METHOD = getmethod(New_methhod);
+ var N2 = oipar[1-1];
+ var xy2 = [orpar.slice(1-1,N2),orpar.slice(N2+1-1,2*N2)];
+ var New_methhod = oipar[2-1];
+ var DChange = false;
+ var METHOD = getmethod(New_methhod);
if (or(this.xy.slice()[1-1]!=xy2.slice()[1-1])) {
- DChange = true;
+ var DChange = true;
}
if (or(this.xy.slice(1-1,N-1)[2-1]!=xy2.slice(1-1,N2-1)[2-1])) {
- DChange = true;
+ var DChange = true;
}
if ((this.xy[N-1][2-1]!=xy2[N2-1][2-1]&&(METHOD!="periodic"))) {
- DChange = true;
+ var DChange = true;
}
if (DChange) {
exprs[2-1] = strcat(sci2exp(xy2.slice()[1-1]));
@@ -128,30 +136,33 @@ function LOOKUP_c() {
exprs[1-1] = sci2exp(New_methhod);
exprs[4-1] = sci2exp(oipar[4-1]);
if (oipar[3-1]==1) {
- perop = "y";
+ var perop = "y";
} else {
- perop = "n";
+ var perop = "n";
}
- SaveExit = true;
+ var SaveExit = true;
} else {
- [Xdummy,Ydummy,orpar] = Do_Spline(N,mtd,this.xy.slice()[1-1],this.xy.slice()[2-1],this.xy[$-1][1-1],this.xy[1-1][1-1],0);
+ var tmpvar4 = Do_Spline(N,mtd,this.xy.slice()[1-1],this.xy.slice()[2-1],this.xy[$-1][1-1],this.xy[1-1][1-1],0)
+ var Xdummy = tmpvar4[0]
+ var Ydummy = tmpvar4[1]
+ var orpar = tmpvar4[2];
if ((METHOD=="periodic")) {
this.xy[N-1][2-1] = this.xy[1-1][2-1];
}
if ((METHOD=="order 2"||METHOD=="not_a_knot"||METHOD=="periodic"||METHOD=="monotone"||METHOD=="fast"||METHOD=="clamped")) {
- orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]],[orpar]];
+ var orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]],[orpar]];
} else {
if ((METHOD=="zero order-below"||METHOD=="linear"||METHOD=="zero order-above"||METHOD=="zero order-nearest")) {
- orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]]];
+ var orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]]];
}
}
exprs[1-1] = sci2exp(mtd);
- oipar = [[N],[mtd],[PO],[this.extrapo]];
- SaveExit = true;
+ var oipar = [[N],[mtd],[PO],[this.extrapo]];
+ var SaveExit = true;
}
}
if ((SaveExit)) {
- xp = find(orpar.slice(1-1,oipar[1-1])>=0);
+ var xp = find(orpar.slice(1-1,oipar[1-1])>=0);
if ((xp!=[])) {
this.model.firing = new ScilabDouble([orpar[xp[1-1]-1]]);
} else {