1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/* autogenerated from "macros/Sources/CURVE_c.sci" */
function CURVE_c() {
CURVE_c.prototype.define = function CURVE_c() {
this.model = scicos_model();
this.xx = [0,1,2];
this.yy = [10,20,-30];
var N = 3;
this.Method = 3;
this.PeriodicOption = "y";
var Graf = "n";
this.model.sim = list(new ScilabString(["curve_c"]), new ScilabDouble([4]));
this.model.in1 = new ScilabDouble([]);
this.model.out = new ScilabDouble([1]);
this.model.rpar = new ScilabDouble([this.xx.slice()],[this.yy.slice()]);
this.model.ipar = new ScilabDouble([N],[this.Method],[1]);
this.model.blocktype = new ScilabString(["c"]);
this.model.dep_ut = new ScilabDouble([false,true]);
this.model.evtin = new ScilabDouble([1]);
this.model.evtout = new ScilabDouble([1]);
this.model.firing = new ScilabDouble([0]);
var exprs = [[sci2exp(this.Method)],[sci2exp(this.xx)],[sci2exp(this.yy)],[this.PeriodicOption],[Graf]];
var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CURVE_c\",sz(1),sz(2));"]);
this.x = standard_define([2,2],this.model,exprs,gr_i);
return new BasicBlock(this.x);
}
CURVE_c.prototype.details = function CURVE_c() {
return this.x;
}
CURVE_c.prototype.get = function CURVE_c() {
var options = {
Method:["Spline Method (0..7)",this.Method],
xx:["x",this.xx],
yy:["y",this.yy],
PeriodicOption:["Periodic signal(y/n)?",this.PeriodicOption],
graf:["Launch graphic window(y/n)?",this.graf],
}
return options;
}
CURVE_c.prototype.set = function CURVE_c() {
this.Method = parseFloat(arguments[0]["Method"])
this.xx = inverse(arguments[0]["xx"])
this.yy = inverse(arguments[0]["yy"])
this.PeriodicOption = arguments[0]["PeriodicOption"]
this.graf = arguments[0]["graf"]
this.x = arg1;
this.model = arg1.model;
this.graphics = arg1.graphics;
var exprs = this.graphics.exprs;
var ok = false;
var SaveExit = false;
while (true) {
var Ask_again = false;
[ok,this.Method,this.xx,this.yy,this.PeriodicOption,this.graf,exprs] = scicos_getvalue("Spline data",["Spline Method (0..7)","x","y","Periodic signal(y/n)?","Launch graphic window(y/n)?"],list("vec",1,"vec",-1,"vec",-1,"str",1,"str",1),exprs);
if (!ok) {
break;
}
if (this.PeriodicOption=="y"||this.PeriodicOption=="Y") {
var PO = 1;
} else {
exprs[4-1] = "n";
var PO = 0;
}
var mtd = int(this.Method);
if (mtd<0) {
var mtd = 0;
}
if (mtd>7) {
var mtd = 7;
}
var METHOD = getmethod(mtd);
if (!Ask_again) {
this.xx = this.xx.slice();
this.yy = this.yy.slice();
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))) {
messagebox("Incompatible size of [x] and [y]","modal","error");
var Ask_again = true;
}
}
if (!Ask_again) {
this.xy = [this.xx,this.yy];
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") {
var ipar = [[N],[mtd],[PO]];
var rpar = [];
if ((winsid()==[])) {
this.curwin = 0;
} else {
this.curwin = max(winsid())+1;
}
var tmpvar3 = poke_point(this.xy,ipar,rpar);
var orpar = tmpvar3[0];
var oipar = tmpvar3[1];
var ok = tmpvar3[2];
if (!ok) {
break;
}
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])) {
var DChange = true;
}
if (or(this.xy.slice(1-1,N-1)[2-1]!=xy2.slice(1-1,N2-1)[2-1])) {
var DChange = true;
}
if ((this.xy[N-1][2-1]!=xy2[N2-1][2-1]&&(METHOD!="periodic"))) {
var DChange = true;
}
if (DChange) {
exprs[2-1] = strcat(sci2exp(xy2.slice()[1-1]));
exprs[3-1] = strcat(sci2exp(xy2.slice()[2-1]));
}
exprs[1-1] = sci2exp(New_methhod);
if (oipar[3-1]==1) {
var perop = "y";
} else {
var perop = "n";
}
exprs[4-1] = perop;
var SaveExit = true;
} else {
var tmpvar4 = Do_Spline(N,mtd,this.xy.slice()[1-1],this.xy.slice()[2-1]);
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")) {
var orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]],[orpar]];
} else {
if ((METHOD=="zero order"||METHOD=="linear")) {
var orpar = [[this.xy.slice()[1-1]],[this.xy.slice()[2-1]]];
}
}
exprs[1-1] = sci2exp(mtd);
var oipar = [[N],[mtd],[PO]];
var SaveExit = true;
}
}
if ((SaveExit)) {
var xp = find(orpar.slice(1-1,oipar[1-1])>=0);
if ((xp!=[])) {
this.model.firing = new ScilabDouble([orpar[xp[1-1]-1]]);
} else {
this.model.firing = new ScilabDouble([-1]);
}
this.model.rpar = new ScilabDouble(orpar);
this.model.ipar = new ScilabDouble(oipar);
this.graphics.exprs = new ScilabDouble([exprs]);
this.x.model = this.model;
this.x.graphics = this.graphics;
break;
}
}
return new BasicBlock(this.x);
}
}
|