summaryrefslogtreecommitdiff
path: root/macros/NonLinear
diff options
context:
space:
mode:
Diffstat (limited to 'macros/NonLinear')
-rw-r--r--macros/NonLinear/ABSBLK_f.sci40
-rw-r--r--macros/NonLinear/ABS_VALUE.sci70
-rw-r--r--macros/NonLinear/COSBLK_f.sci41
-rw-r--r--macros/NonLinear/DLRADAPT_f.sci96
-rw-r--r--macros/NonLinear/EXPBLK_f.sci66
-rw-r--r--macros/NonLinear/EXPBLK_m.sci70
-rw-r--r--macros/NonLinear/FSV_f.sci43
-rw-r--r--macros/NonLinear/INTRP2BLK_f.sci69
-rw-r--r--macros/NonLinear/INTRPLBLK_f.sci67
-rw-r--r--macros/NonLinear/INVBLK.sci42
-rw-r--r--macros/NonLinear/INVBLK_f.sci42
-rw-r--r--macros/NonLinear/LOGBLK_f.sci68
-rw-r--r--macros/NonLinear/LOOKUP2D.sci166
-rw-r--r--macros/NonLinear/LOOKUP_c.sci1338
-rw-r--r--macros/NonLinear/LOOKUP_f.sci72
-rw-r--r--macros/NonLinear/MAXMIN.sci95
-rw-r--r--macros/NonLinear/MAX_f.sci43
-rw-r--r--macros/NonLinear/MIN_f.sci43
-rw-r--r--macros/NonLinear/POWBLK_f.sci69
-rw-r--r--macros/NonLinear/PRODUCT.sci89
-rw-r--r--macros/NonLinear/PROD_f.sci40
-rw-r--r--macros/NonLinear/QUANT_f.sci77
-rw-r--r--macros/NonLinear/SATURATION.sci74
-rw-r--r--macros/NonLinear/SAT_f.sci71
-rw-r--r--macros/NonLinear/SIGNUM.sci70
-rw-r--r--macros/NonLinear/SINBLK_f.sci41
-rw-r--r--macros/NonLinear/TANBLK_f.sci43
-rw-r--r--macros/NonLinear/TrigFun.sci63
28 files changed, 3108 insertions, 0 deletions
diff --git a/macros/NonLinear/ABSBLK_f.sci b/macros/NonLinear/ABSBLK_f.sci
new file mode 100644
index 00000000..d59ab10a
--- /dev/null
+++ b/macros/NonLinear/ABSBLK_f.sci
@@ -0,0 +1,40 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=ABSBLK_f(job,arg1,arg2)
+ //Absolute value block GUI.
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ model=scicos_model()
+ model.sim=list("absblk",1)
+ model.in=-1
+ model.out=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ gr_i=[]
+ x=standard_define([2 2],model,[],gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/ABS_VALUE.sci b/macros/NonLinear/ABS_VALUE.sci
new file mode 100644
index 00000000..bd6a5650
--- /dev/null
+++ b/macros/NonLinear/ABS_VALUE.sci
@@ -0,0 +1,70 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=ABS_VALUE(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,zcr,exprs]=..
+ scicos_getvalue("Set block parameters",..
+ ["use zero_crossing (1: yes) (0:no)"],..
+ list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ graphics.exprs=exprs
+ if ok then
+ if zcr<>0 then
+ model.nmode=-1;
+ model.nzcross=-1;
+ else
+ model.nmode=0;
+ model.nzcross=0;
+ end
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ nu=-1
+ model=scicos_model()
+ model.sim=list("absolute_value",4)
+ model.in=nu
+ model.out=nu
+ model.nzcross=nu
+ model.nmode=nu
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[string([1])]
+ gr_i=[]
+
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/COSBLK_f.sci b/macros/NonLinear/COSBLK_f.sci
new file mode 100644
index 00000000..fcdcec26
--- /dev/null
+++ b/macros/NonLinear/COSBLK_f.sci
@@ -0,0 +1,41 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=COSBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=1
+ model=scicos_model()
+ model.sim="cosblk"
+ model.in=-1
+ model.out=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ gr_i=[]
+ x=standard_define([2 2],model,[],gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/DLRADAPT_f.sci b/macros/NonLinear/DLRADAPT_f.sci
new file mode 100644
index 00000000..b26c662e
--- /dev/null
+++ b/macros/NonLinear/DLRADAPT_f.sci
@@ -0,0 +1,96 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=DLRADAPT_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,p,rn,rd,g,last_u,last_y,exprs]=scicos_getvalue("Set block parameters",..
+ ["Vector of p mesh points";
+ "Numerator roots (one line for each mesh)";
+ "Denominator roots (one line for each mesh)";
+ "Vector of gain at mesh points" ;
+ "past inputs (Num degree values)";
+ "past outputs (Den degree values)"],..
+ list("vec",-1,"mat",[-1,-1],"mat",..
+ ["size(%1,''*'')","-1"],"vec","size(%1,''*'')",..
+ "vec","size(%2,2)","vec","size(%3,2)"),exprs)
+
+
+ if ~ok then
+ break,
+ end
+ m=size(rn,2)
+ [npt,n]=size(rd)
+ if m>=n then
+ message("Transfer must be strictly proper"),
+ elseif size(rn,1)<>0&size(rn,1)<>size(p,"*") then
+ message("Numerator roots matrix row size''s is incorrect")
+ else
+ rpar=[p(:);real(rn(:));imag(rn(:));real(rd(:));imag(rd(:));g(:)]
+ ipar=[m;n;npt]
+ model.dstate=[last_u(:);last_y(:)]
+ model.rpar=rpar
+ model.ipar=ipar
+ graphics.exprs=exprs
+ x.graphics=graphics;
+ x.model=model
+ break;
+ end
+ end
+ case "define" then
+ p=[0;1]
+ rn=[]
+ rd=[0.2+0.8*%i,0.2-0.8*%i;0.3+0.7*%i,0.3-0.7*%i]
+ g=[1;1]
+ last_u=[]
+ last_y=[0;0]
+
+ model=scicos_model()
+ model.sim="dlradp"
+ model.in=[1;1]
+ model.out=1
+ model.evtin=1
+
+ model.dstate=[last_u;last_y]
+ model.rpar=[p(:);real(rn(:));imag(rn(:));real(rd(:));imag(rd(:));g(:)]
+ model.ipar=[0;2;2]
+ model.blocktype="d"
+ model.firing=[]
+ model.dep_ut=[%t %f]
+
+ exprs=[sci2exp(p);
+ sci2exp(rn);
+ sci2exp(rd,0);
+ sci2exp(g);
+ sci2exp(last_u);
+ sci2exp(last_y)]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/EXPBLK_f.sci b/macros/NonLinear/EXPBLK_f.sci
new file mode 100644
index 00000000..0c4dd55b
--- /dev/null
+++ b/macros/NonLinear/EXPBLK_f.sci
@@ -0,0 +1,66 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=EXPBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ if size(exprs,"*")==2 then
+ exprs=exprs(2),
+ end
+ while %t do
+ [ok,a,exprs]=scicos_getvalue("Set a^u block parameters",..
+ "a (>0)",list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if or(a<=0) then
+ message("a^u : a must be positive")
+ else
+ graphics.exprs=exprs
+ model.rpar=a;
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ in=1
+ a=%e
+ model=scicos_model()
+ model.sim="expblk"
+ model.in=-1
+ model.out=-1
+ model.rpar=a
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=["%e"]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/EXPBLK_m.sci b/macros/NonLinear/EXPBLK_m.sci
new file mode 100644
index 00000000..f0059b22
--- /dev/null
+++ b/macros/NonLinear/EXPBLK_m.sci
@@ -0,0 +1,70 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=EXPBLK_m(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ if size(exprs,"*")==2 then
+ exprs=exprs(2),
+ end
+ while %t do
+ [ok,a,exprs]=scicos_getvalue("Set a^u block parameters",..
+ "a (>0)",list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if or(a<=0) then
+ message("a^u : a must be positive")
+ else
+ graphics.exprs=exprs
+ model.rpar=a;
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ in=1
+ a=%e
+ model=scicos_model()
+ model.sim=list("expblk_m",4)
+ model.in=-1
+ model.in2=-2
+ model.out=-1
+ model.out2=-2
+ model.intyp=1
+ model.outtyp=1
+ model.rpar=a
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=["%e"]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/FSV_f.sci b/macros/NonLinear/FSV_f.sci
new file mode 100644
index 00000000..00db92d3
--- /dev/null
+++ b/macros/NonLinear/FSV_f.sci
@@ -0,0 +1,43 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=FSV_f(job,arg1,arg2)
+ //Absolute value block GUI.
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=1 //One input/output port with undefinite dimension
+ model=scicos_model()
+ model.sim=list("fsv",1)
+ model.in=in
+ model.out=in
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=" "
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/INTRP2BLK_f.sci b/macros/NonLinear/INTRP2BLK_f.sci
new file mode 100644
index 00000000..c64c7c03
--- /dev/null
+++ b/macros/NonLinear/INTRP2BLK_f.sci
@@ -0,0 +1,69 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=INTRP2BLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,a,b,c,exprs]=scicos_getvalue("Set Interpolation block parameters",..
+ ["X coord.";"Y coord.";"Z values"],list("vec",-1,"vec",-1,"mat",[-1,-1]),exprs)
+ if ~ok then
+ break,
+ end
+ if size(a,"*") <> size(c,"c") | size(b,"*") <> size(c,"r") then
+ message("incompatible dimension")
+ elseif min(a(2:$)-a(1:$-1)) <=0 | min(b(2:$)-b(1:$-1)) <=0 then
+ message("X and Y must be strictly increasing")
+ else
+ if ok then
+ graphics.exprs=exprs
+ model.rpar=[a(:);b(:);c(:)]
+ model.ipar=[size(a,"*");size(b,"*")]
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ end
+ case "define" then
+ a=[0;1];
+ b=[0;1];
+ c=[0 1;1 2]
+ model=scicos_model()
+ model.sim=list("intrp2",1)
+ model.in=[1;1]
+ model.out=1
+ model.rpar=[a;b;c(:)]
+ model.ipar=[2;2]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ exprs=[strcat(sci2exp(a));strcat(sci2exp(b));strcat(sci2exp(c,0))]
+ gr_i=[]
+ x=standard_define([3 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/INTRPLBLK_f.sci b/macros/NonLinear/INTRPLBLK_f.sci
new file mode 100644
index 00000000..0ab7f5b0
--- /dev/null
+++ b/macros/NonLinear/INTRPLBLK_f.sci
@@ -0,0 +1,67 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=INTRPLBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,a,b,exprs]=scicos_getvalue("Set Interpolation block parameters",..
+ ["X coord.";"Y coord."],list("vec",-1,"vec",-1),exprs)
+ if ~ok then
+ break,
+ end
+ if size(a,"*") <> size(b,"*") then
+ message("X and Y must have the same size")
+ elseif min(a(2:$)-a(1:$-1)) <=0 then
+ message("X must be strictly increasing")
+ else
+ if ok then
+ graphics.exprs=exprs
+ model.rpar=[a(:);b(:)]
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ end
+ case "define" then
+ a=[0;1];
+ b=[0;1]
+ model=scicos_model()
+ model.sim="intrpl"
+ model.in=1
+ model.out=1
+ model.rpar=[a;b]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[strcat(sci2exp(a));strcat(sci2exp(b))]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/INVBLK.sci b/macros/NonLinear/INVBLK.sci
new file mode 100644
index 00000000..4960187a
--- /dev/null
+++ b/macros/NonLinear/INVBLK.sci
@@ -0,0 +1,42 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=INVBLK(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=-1
+ model=scicos_model()
+ model.sim=list("invblk4",4)
+ model.in=in
+ model.out=in
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=" "
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/INVBLK_f.sci b/macros/NonLinear/INVBLK_f.sci
new file mode 100644
index 00000000..65391d7c
--- /dev/null
+++ b/macros/NonLinear/INVBLK_f.sci
@@ -0,0 +1,42 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=INVBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=-1
+ model=scicos_model()
+ model.sim="invblk"
+ model.in=in
+ model.out=in
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=" "
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/LOGBLK_f.sci b/macros/NonLinear/LOGBLK_f.sci
new file mode 100644
index 00000000..eb857172
--- /dev/null
+++ b/macros/NonLinear/LOGBLK_f.sci
@@ -0,0 +1,68 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=LOGBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ if size(exprs,"*")==2 then
+ exprs=exprs(2),
+ end //compatibility
+ while %t do
+ [ok,a,exprs]=scicos_getvalue("Set log block parameters",..
+ "Basis (>1)",list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if a<=1 then
+ message("Basis must be larger than 1")
+ else
+ if ok then
+ graphics.exprs=exprs
+ model.rpar=a
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ end
+ case "define" then
+ in=1
+ a=%e
+ model=scicos_model()
+ model.sim="logblk"
+ model.in=-1
+ model.out=-1
+ model.rpar=a
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs="%e"
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/LOOKUP2D.sci b/macros/NonLinear/LOOKUP2D.sci
new file mode 100644
index 00000000..62df228b
--- /dev/null
+++ b/macros/NonLinear/LOOKUP2D.sci
@@ -0,0 +1,166 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+function [x,y,typ]=LOOKUP2D(job,arg1,arg2)
+ // Copyright INRIA
+
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+
+ x=arg1
+ model=arg1.model
+ graphics=arg1.graphics
+ exprs=graphics.exprs
+ ok=%f;
+ SaveExit=%f
+ while %t do
+
+ Ask_again=%f
+ [ok,xx,yy,zz,Method,graf,exprs]=scicos_getvalue("2D Lookup table parameters",["Row index input values";"Column index input values";"Table data";"Lookup method(1..5)";"Launch graphic window(y/n)?"],list("vec",-1,"vec",-1,"mat",[-1,-1],"vec",1,"str",1),exprs)
+ // 1 : Interpolation-extrapolation (Bilinear)
+ // 2 : Interpolation_endvalues
+ // 3 : use input nearest
+ // 4 : use input below
+ // 5 : use input above
+ // 6 : Interpolation-extrapolation (linear)
+
+ if ~ok then
+ break;
+ end
+ mtd=int(Method);
+ if mtd<1 then
+ mtd=1;
+ end;
+ if mtd>6 then
+ mtd=6;
+ end;
+ if graf<>"y" & graf<>"Y" then
+ graf="n";
+ end
+ exprs(5)="n";// exprs.graf='n'
+ exprs(4)=sci2exp(mtd);// pour le cas methode>7 | method<0
+
+ METHOD=getmethod(mtd);
+ if ~Ask_again then
+ xx=xx(:);
+ yy=yy(:);
+ [nx,mx]=size(xx);
+ [ny,my]=size(yy);
+ [nz,mz]=size(zz);
+ if ((nx<=1)|(ny<=1)) then,
+ x_message("input row/column data size should be greater than one");
+ Ask_again=%t;
+ end
+ if ~((nx==nz)&(ny==mz)) then,
+ x_message("incompatible size of x and y");
+ Ask_again=%t;
+ end
+ [ok]=test_increasing(xx);
+ if (~ok) then
+ x_message("Row input values must be monotonically increasing");
+ Ask_again=%t;
+ end
+ [ok]=test_increasing(yy);
+ if (~ok) then
+ x_message("Column input values must be monotonically increasing");
+ Ask_again=%t;
+ end
+ end
+ if ~Ask_again then
+ if (graf=="Y" | graf=="y") then
+ gh=gcf();
+ curwin=gh.figure_id;
+ save_curwin=curwin;
+ gh2=scf();
+ curwin=max(winsid())+1;
+ plot3d(xx,yy,zz,35,45,"X@Y@Z",[5,2,4]) ;
+ curwin=save_curwin;
+ gh.figure_id=curwin;
+ end
+
+ model.rpar=[xx(:);yy(:);zz(:)]
+ model.ipar=[nx;ny;mtd]
+ graphics.exprs=exprs;
+ x.model=model
+ x.graphics=graphics
+ break
+ end
+ end
+ //======================================================================
+ case "define" then
+ model=scicos_model();
+ xx=[1:4]
+ yy=[1:3]
+ zz=[4,5,6;16,19,20;10,18,23;6, 3,-1];
+ Method=1;
+ Graf="n"
+
+ Nx=length(xx);
+ Ny=length(yy);
+ model.sim=list("lookup2d",4)
+ model.in=[1;1]
+ model.out=1
+
+ model.rpar=[xx(:);yy(:);zz(:)]
+ model.ipar=[Nx;Ny;Method]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ exprs=list(strcat(sci2exp(xx)),strcat(sci2exp(yy)),strcat(sci2exp(zz)),sci2exp(Method),Graf)
+ gr_i=[]
+
+ x=standard_define([2.5 2],model,exprs,gr_i)
+ end
+endfunction
+
+function [ok]=test_increasing(xx)
+ ok=%f
+ [nx,mx]=size(xx);// adjusting the x and y size
+
+ for i=1:mx
+ if (xx(i)<>xx(i)) then
+ xinfo("x contains no data in x("+string(i)+")");
+ return;
+ end
+
+ end
+
+ for i=1:mx-1
+ if (xx(i)>xx(i+1)) then
+ return;
+ end
+ end
+
+ ok=%t
+endfunction
+//============================
+function METHOD=getmethod(order)
+ select order
+ case 1 then, METHOD="Interpolation-extrapolation(biliniear)"
+ case 2 then, METHOD="Interpolation_endvalues"
+ case 3 then, METHOD="use input nearest"
+ case 4 then, METHOD="use input below"
+ case 5 then, METHOD="use input above"
+ case 6 then, METHOD="Interpolation-extrapolation"
+ end
+endfunction
+//=========================================================
diff --git a/macros/NonLinear/LOOKUP_c.sci b/macros/NonLinear/LOOKUP_c.sci
new file mode 100644
index 00000000..bef8e615
--- /dev/null
+++ b/macros/NonLinear/LOOKUP_c.sci
@@ -0,0 +1,1338 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=LOOKUP_c(job,arg1,arg2)
+ // Masoud Najafi 01/2008 --------
+ // origine: serge Steer, Habib Jreij INRIA 1993
+ // Copyright INRIA
+
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+
+ x=arg1
+ model=arg1.model
+ graphics=arg1.graphics
+ exprs=graphics.exprs
+ ok=%f;
+ SaveExit=%f
+ while %t do
+ Ask_again=%f
+ [ok,Method,xx,yy,extrapo,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)
+ // 9 : nearest
+ // 8 : above
+ // 0: below
+ // extra: 0:hold; 1: use end values
+ //
+
+ if ~ok then
+ break;
+ end
+ PeriodicOption="n";
+
+ if PeriodicOption=="y" | PeriodicOption=="Y" then,
+ PO=1;
+ else,
+ PO=0;
+ end
+ mtd=int(Method);
+ if mtd<0 then
+ mtd=0;
+ end;
+ if mtd>9 then
+ mtd=9;
+ end;
+ METHOD=getmethod(mtd);
+ extrapo=int(extrapo);
+ if extrapo<0 then
+ extrapo=0;
+ end;
+ if extrapo>1 then
+ extrapo=1;
+ end;
+
+
+ if ~Ask_again then
+ xx=xx(:);
+ yy=yy(:);
+ [nx,mx]=size(xx);
+ [ny,my]=size(yy);
+ if ~((nx==ny)&(mx==my)) then,
+ x_message("incompatible size of x and y");
+ Ask_again=%t;
+ end
+ end
+
+ if ~Ask_again then//+++++++++++++++++++++++++++++++++++++++
+ xy=[xx,yy];
+ [xy]=cleandata(xy);// just for sorting to be able to compare data before and after poke_point(.)
+ N= size(xy,"r");
+ exprs(5)="n";// exprs.graf='n'
+ if graf=="y" | graf=="Y" then //_______Graphic editor___________
+ ipar=[N;mtd;PO;extrapo];
+ rpar=[];
+ if ~exists("curwin") then
+ gh=gcf();
+ curwin=gh.figure_id
+ end
+ save_curwin=curwin;
+ curwin=max(winsid())+1;
+ [orpar,oipar,ok]=poke_point(xy,ipar,rpar);
+ curwin=save_curwin;
+ if ~ok then
+ break;
+ end;// exit without save
+
+ // verifying the data change
+ N2=oipar(1);
+ xy2=[orpar(1:N2),orpar(N2+1:2*N2)];
+ New_methhod=oipar(2);
+ DChange=%f;
+ METHOD=getmethod(New_methhod);
+ if or(xy(:,1)<>xy2(:,1)) then,
+ DChange=%t;
+ end
+ if or(xy(1:N-1,2)<>xy2(1:N2-1,2)) then,
+ DChange=%t;
+ end
+ if (xy(N,2)<>xy2(N2,2) & (METHOD<>"periodic")) then,
+ DChange=%t;
+ end
+ if DChange then
+ exprs(2)=strcat(sci2exp(xy2(:,1)))
+ exprs(3)=strcat(sci2exp(xy2(:,2)))
+ end
+ exprs(1)=sci2exp(New_methhod);
+ exprs(4)=sci2exp(oipar(4));
+ if oipar(3)==1 then,
+ perop="y";
+ else,
+ perop="n";
+ end
+ SaveExit=%t
+ else//_____________________No graphics__________________________
+ [Xdummy,Ydummy,orpar]=Do_Spline(N,mtd,xy(:,1),xy(:,2),xy($,1),xy(1,1),0);
+ if (METHOD=="periodic") then // periodic spline
+ xy(N,2)=xy(1,2);
+ end
+ if (METHOD=="order 2" | METHOD=="not_a_knot"|METHOD=="periodic" | METHOD=="monotone"| METHOD=="fast" | METHOD=="clamped") then
+ orpar=[xy(:,1);xy(:,2);orpar];
+ else
+ if (METHOD=="zero order-below"|METHOD=="linear"|METHOD=="zero order-above"|METHOD=="zero order-nearest") then
+ orpar=[xy(:,1);xy(:,2);]
+ end
+ end
+ exprs(1)=sci2exp(mtd);// pour le cas methode>7 | method<0
+ oipar=[N;mtd;PO;extrapo]
+ SaveExit=%t
+ end //___________________________________________________________
+ end //++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ if (SaveExit) then
+ xp=find(orpar(1:oipar(1))>=0);
+ if (xp<>[]) then
+ model.firing=orpar(xp(1)); //first positive event
+ else
+ model.firing=-1;
+ end
+ model.rpar=orpar
+ model.ipar=oipar
+ graphics.exprs=exprs;
+ x.model=model
+ x.graphics=graphics
+ break
+ end
+ end
+ case "define" then
+ model=scicos_model()
+
+ xx=[-1;0.5;1;1.5;2.5]
+ yy=[-6;-1;-3;3;-4]
+ N=length(xx);
+ Method=1;
+ Graf="n"
+ model.sim=list("lookup_c",4)
+ model.in=-1
+ model.in2=-2
+ model.outtyp=-1
+
+ model.out=-1
+ model.out2=-2
+ model.outtyp=-1
+
+ model.rpar=[xx(:);yy(:)]
+ model.ipar=[N;Method;0;0]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ model.evtin=[]
+ model.evtout=[]
+ model.firing=0
+ exprs=[sci2exp(Method);sci2exp(xx);sci2exp(yy);sci2exp(0);Graf]
+
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
+
+
+
+function [rpar,ipar,ok]=poke_point(ixy,iparin,rparin)
+ [lhs,rhs]=argn(0)
+ //in line definition of get_click
+ deff("[btn,xc,yc,win,Cmenu]=get_click(flag)",[
+ "if ~or(winsid() == curwin) then Cmenu = ''Quit'';return,end,";
+ "if argn(2) == 1 then";
+ " [btn, xc, yc, win, str] = xclick(flag);";
+ "else";
+ " [btn, xc, yc, win, str] = xclick();";
+ "end;";
+ "if btn == -100 then";
+ " if win == curwin then";
+ " Cmenu = ''Quit'';";
+ " else";
+ " Cmenu = ''Open/Set'';";
+ " end,";
+ " return,";
+ "end";
+ "if btn == -2 then";
+ " xc = 0;yc = 0;";
+ " try " // added to handle unwanted menu actions in french version
+ " execstr(''Cmenu='' + part(str, 9:length(str) - 1));";
+ " execstr(''Cmenu='' + Cmenu);";
+ " catch"
+ " Cmenu=[]"
+ " end "
+ " return,";
+ "end";
+ "Cmenu=[]"])
+
+ ok=%f
+ if rhs==0 then
+ ixy=[];
+ end;
+ if size(xy,"c")<2 then
+ xinfo(" No y provided");
+ return
+ end
+
+ [xy]=cleandata(ixy)
+ N=size(xy,"r");
+
+ if rhs<=1 then
+ NOrder=1;
+ PeridicOption=0;
+ extrapo=0
+ ipar=[N;NOrder;PeridicOption;extrapo]
+ rpar=[]
+ elseif rhs==2 then
+ NOrder=iparin(2);
+ PeridicOption=iparin(3);
+ extrapo=iparin(4);
+ ipar=iparin;
+ rpar=[]
+ elseif rhs==3 then
+ NOrder=iparin(2);
+ PeridicOption=iparin(3);
+ extrapo=iparin(4);
+ ipar=iparin;
+ rpar=rparin
+ end
+
+ Amp=[];
+ wp=[];
+ phase=[];
+ offset=[];
+ np1=[];
+ Sin_exprs=list(string(Amp),string(wp), string(phase),string(offset),string(np1));
+ sAmp=[];
+ sTp=[];
+ sdelay=[];
+ Sawt1_exprs=list(string(sAmp),string(sTp),string(sdelay));
+ sAmp2=[];
+ sTp2=[];
+ Sawt2_exprs=list(string(sAmp2),string(sTp2));
+
+ Amp3=[];
+ Tp3=[];
+ Pw3=[];
+ Pd3=[];
+ Bias3=[];
+ Pulse_exprs=list(string(Amp3), string(Tp3),string(Pw3),string(Pd3),string(Bias3))
+
+ mean4=[];
+ var4=[];
+ seed4=[];
+ sample4=[];
+ np4=[];
+ random_n_exprs=list(string(mean4),string(var4), string(seed4),string(sample4),string(np4))
+
+ min5=[];
+ max5=[];
+ seed5=[];
+ sample5=[];
+ np5=[];
+ random_u_exprs=list(string(min5), string(max5), string(seed5),string(sample5),string(np5))
+
+ // bornes initiales du graphique
+ xmx=max(xy(:,1));
+ xmn=min(xy(:,1)),
+ ymx=max(xy(:,2));
+ ymn=min(xy(:,2));
+ dx=xmx-xmn;
+ dy=ymx-ymn
+ if dx==0 then
+ dx=max(xmx/2,1),
+ end;
+ xmx=xmx+dx/50;
+ if dy==0 then
+ dy=max(ymx/2,1),
+ end;
+ ymn=ymn-dy/50;
+ ymx=ymx+dy/50;
+
+ rect=[xmn,ymn;xmx,ymx];
+ //===================================================================
+ f=scf();
+
+ if getos() <> "Windows" then
+ delmenu(curwin,"3D Rot.")
+ delmenu(curwin,"Edit")
+ delmenu(curwin,"File")
+ delmenu(curwin,"Insert")
+ else
+ hidetoolbar(curwin)
+ // French
+ delmenu(curwin,"&Fichier")
+ delmenu(curwin,"&Editer")
+ delmenu(curwin,"&Outils")
+ delmenu(curwin,"&Inserer")
+ // English
+ delmenu(curwin,"&File")
+ delmenu(curwin,"&Edit")
+ delmenu(curwin,"&Tools")
+ delmenu(curwin,"&Insert")
+ end
+ //menuss=menus;menuss(1)=menus(1)(2:$);menubar(curwin,menuss)
+
+ menu_r=[];
+ menu_s=[];
+ menu_o=["zero order-below","linear","order 2","not_a_knot","periodic","monotone","fast","clamped","zero order-above","zero order-nearest"]
+ menu_d=["Clear","Data Bounds","Load from text file","Save to text file","Load from Excel","Extrapolation"]
+ menu_t=["sine","sawtooth1","sawtooth2","pulse","random normal","random uniform"]
+ menu_e=["Help","Exit without save","Save/Exit"]
+ MENU=["Autoscale","Spline","Data","Standards","Exit"];
+ menus=list(MENU,menu_s,menu_o,menu_d,menu_t,menu_e);
+
+ scam="menus(1)(1)"
+ w="menus(3)(";r=")";
+ Orderm=w(ones(menu_o))+string(1:size(menu_o,"*"))+r(ones(menu_o))
+ w="menus(4)(";r=")";
+ Datam=w(ones(menu_d))+string(1:size(menu_d,"*"))+r(ones(menu_d))
+ w="menus(5)(";r=")";
+ Standm=w(ones(menu_t))+string(1:size(menu_t,"*"))+r(ones(menu_t))
+ w="menus(6)(";r=")";
+ Exitm=w(ones(menu_e))+string(1:size(menu_e,"*"))+r(ones(menu_e))
+
+ execstr("Autoscale_"+string(curwin)+"=scam")
+ execstr("Spline_"+string(curwin)+"=Orderm")
+ execstr("Data_"+string(curwin)+"=Datam")
+ execstr("Standards_"+string(curwin)+"=Standm")
+ execstr("Exit_"+string(curwin)+"=Exitm")
+
+ addmenu(curwin,MENU(1))
+ addmenu(curwin,MENU(2),menu_o)
+ addmenu(curwin,MENU(3),menu_d)
+ addmenu(curwin,MENU(4),menu_t)
+ addmenu(curwin,MENU(5),menu_e)
+ //===================================================================
+ //initial draw
+ drawlater();
+ a=gca(f);
+ a.data_bounds=rect;
+ a.axes_visible="on";
+ a.clip_state="on";
+ xtitle( "", "time", "Output" ) ;
+ a.title.font_size=2;
+ a.title.font_style=4;
+ a.title.foreground=2;
+
+ a.grid=[2 2];
+ xpolys(xy(:,1),xy(:,2),[-1]); //children(2)
+ xpolys(xy(:,1),xy(:,2),[5]); //children(1)
+ splines=a.children(1).children
+ points=a.children(2).children
+ //---------------------------------------
+
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ drawnow();
+ // -- boucle principale
+ lines(0);
+ while %t then //=================================================
+ N=size(xy,"r");
+ [btn,xc,yc,win,Cmenu]=get_click();
+ if ((win>0) & (win<>curwin)) then
+ Cmenu="Mouse click is Offside!";
+ end
+ if Cmenu==[] then Cmenu="edit",end
+ if (Cmenu=="Exit") |(Cmenu=="Quit" ) then,
+ ipar=[];
+ rpar=[];
+ ok=%f;return;
+ end
+ //-------------------------------------------------------------------
+ if ((Cmenu=="zero order-below") | (Cmenu=="linear") | (Cmenu=="order 2")| ...
+ (Cmenu=="not_a_knot")| (Cmenu=="periodic")| (Cmenu=="monotone")| ...
+ (Cmenu=="fast")| (Cmenu=="clamped") |(Cmenu=="zero order-above")|(Cmenu=="zero order-nearest")) then
+
+ select Cmenu
+ case "zero order-below" then
+ NOrder=0;
+ case "linear" then
+ NOrder=1;
+ case "order 2" then
+ NOrder=2;
+ case "not_a_knot" then
+ NOrder=3;
+ case "periodic" then
+ NOrder=4;
+ case "monotone" then
+ NOrder=5;
+ case "fast" then
+ NOrder=6;
+ case "clamped" then
+ NOrder=7;
+ case "zero order-above" then
+ NOrder=8;
+ case "zero order-nearest" then
+ NOrder=9;
+ end
+ ipar(2)=NOrder;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ end
+ //-------------------------------------------------------------------
+ select Cmenu
+ case "Data Bounds" then
+ rectx=findrect(a);
+ [mok,xmn1,xmx1,ymn1,ymx1]=scicos_getvalue("Enter new bounds",["xmin";"xmax"; ...
+ "ymin";"ymax"],list("vec",1,"vec",1,"vec",1,"vec",1), ...
+ string(rectx))
+ //drawlater();
+ if mok then
+ if (xmn1>xmx1|ymn1>ymx1) then
+ xinfo("Incorrect bounds")
+ mok=%f;
+ end
+ if mok then
+ a.data_bounds=[xmn1,ymn1;xmx1,ymx1];
+ end
+ end
+ //drawnow();
+ //-------------------------------------------------------------------
+ case "Autoscale" then
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ //-------------------------------------------------------------------
+ case "Extrapolation" then
+ //extrapo
+ if extrapo==1 then,
+ ans0="1",
+ else,
+ ans0="0",
+ end;
+ [mok,myans]=scicos_getvalue("Extrapolation method (just for Method 1)",["0: hold end values, 1: extrapolation"],list("vec",1),list(ans0));
+ if (mok==%t) then
+ extrapo=int(myans);
+ if extrapo<0 then
+ extrapo=0;
+ end;
+ if extrapo>1 then
+ extrapo=1;
+ end;
+ ipar(4)=extrapo;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ end
+ //-------------------------------------------------------------------
+ case "sine" then
+ [mok,Amp,wp,phase,offset,np1,Sin_exprs2]=scicos_getvalue(" Sine parameters", ...
+ ["Amplitude";"Frequency(rad/sec)"; ...
+ "Phase(rad)";"Bias";"number of points"],list("vec",1,"vec",1,"vec",1, ...
+ "vec",1,"vec",1),Sin_exprs)
+ if np1< 2 then
+ np1=2;
+ end
+ if mok & wp>0 then
+ NOrder=3;
+ ipar(2)=NOrder;
+ phase=atan(tan(phase));
+ xt=linspace(0,%pi*2/wp,np1)';
+ yt=Amp*sin(wp*xt+phase)+offset;
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ Sin_exprs=Sin_exprs2
+ end
+ //-------------------------------------------------------------------
+ case "sawtooth1" then
+ [mok,sAmp,sTp,sdelay,Sawt1_exprs2]=scicos_getvalue("Sawtooth signal parameters", ...
+ ["Amplitude";"Period";"delay"], ...
+ list("vec",1,"vec",1,"vec",1),Sawt1_exprs)
+ if mok & sTp>0 then
+ NOrder=1;
+ ipar(2)=NOrder;
+ if sdelay<sTp then
+ xt=[0;sdelay;sTp];
+ yt=[0;0;sAmp];
+ else
+ xt=[0];
+ yt=[0];
+ end
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
+ Sawt1_exprs=Sawt1_exprs2
+ end
+ //-------------------------------------------------------------------
+ case "sawtooth2" then
+ [mok,sAmp2,sTp2,Sawt2_exprs2]=scicos_getvalue("Sawtooth signal parameters", ...
+ ["Amplitude";"Period"],list("vec",1,"vec",1),Sawt2_exprs)
+ if mok & sTp2>0 then
+ NOrder=1;
+ ipar(2)=NOrder;
+ xt=[0;sTp2];
+ yt=[sAmp2;-sAmp2];
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
+ Sawt2_exprs=Sawt2_exprs2
+ end
+ //-------------------------------------------------------------------
+ case "pulse" then
+ [mok,Amp3,Tp3,Pw3,Pd3,Bias3,Pulse_exprs2]=scicos_getvalue("Square wave pulse signal", ...
+ ["Amplitude";"Period (sec)";"Pulse width(% of period)";"Phase delay (sec)";"Bias"],list("vec",1, ...
+ "vec",1,"vec",1,"vec",1,"vec", ...
+ 1),Pulse_exprs)
+ if mok & Tp3>0 then
+ NOrder=0;
+ ipar(2)=NOrder;
+ if (Pd3>0) then
+ xt=0;
+ yt=Bias3;
+ else
+ xt=[];
+ yt=[];
+ end
+ //otherwise there would be double points at 0
+ if Pd3<Tp3 then
+ if Pw3>0 then
+ xt=[xt;Pd3; Pw3*Tp3/100+Pd3;Tp3];
+ yt=[yt;Amp3+Bias3;Bias3;Bias3];
+ else
+ xt=[0;Tp3];
+ yt=[Bias3;Bias3];
+ end
+ else
+ xt=[0;Tp3];
+ yt=[Bias3;Bias3];
+ end
+
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
+ Pulse_exprs=Pulse_exprs2;
+ end
+ //-------------------------------------------------------------------
+ case "random normal" then
+ [mok,mean4,var4,seed4,sample4,np4,random_n_exprs2]=scicos_getvalue("Normal (Gaussian) random signal", ...
+ ["Mean";"Variance";"Initial seed";"Sample time";"Number of points"],list("vec",1, ...
+ "vec",1,"vec",1,"vec", ...
+ 1,"vec",1),random_n_exprs)
+ if mok & sample4>0 then
+ NOrder=0;
+ ipar(2)=NOrder;
+ rand("normal");
+ rand("seed",seed4);
+ xt=0:sample4:sample4*(np4-1);
+ xt=xt(:);
+ yt=mean4+sqrt(var4)*rand(np4,1);
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
+ random_n_exprs2=random_n_exprs;
+ end
+ //-------------------------------------------------------------------
+ case "random uniform" then
+ [mok,min5,max5,seed5,sample5,np5,random_u_exprs2]=scicos_getvalue("Uniform random signal", ...
+ ["Minimum";"Maximum";"Initial seed";"Sample time";"Number of points"],list("vec",1, ...
+ "vec",1,"vec",1,"vec", ...
+ 1,"vec",1),random_u_exprs)
+ if mok & sample5>0 then
+ NOrder=0;
+ ipar(2)=NOrder;
+ rand("uniform");
+ rand("seed",seed5);
+ xt=0:sample5:sample5*(np5-1);
+ xt=xt(:);
+ yt=min5+(max5-min5)*rand(np5,1);
+ xy=[xt,yt];
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar);
+ random_u_exprs2=random_u_exprs;
+
+ end
+ //-------------------------------------------------------------------
+ case "Save/Exit" then
+ NOrder=ipar(2);
+ PeridicOption=ipar(3);
+
+ METHOD=getmethod(NOrder);
+ if (METHOD=="periodic") then // periodic spline
+ xy(N,2)=xy(1,2);
+ end
+
+ if (METHOD=="order 2" | METHOD=="not_a_knot"|METHOD=="periodic" | METHOD=="monotone"| METHOD=="fast" | METHOD=="clamped") then
+ rpar=[xy(:,1);xy(:,2);rpar];
+ else
+ if (METHOD=="zero order-below"|METHOD=="linear"|METHOD=="zero order-above"|METHOD=="zero order-nearest")
+ rpar=[xy(:,1);xy(:,2);]
+ end
+ end
+
+ ok=%t
+ delete(f);
+ return
+ //-------------------------------------------------------------------
+ case "Exit without save" then
+ ipar=[];
+ rpar=[];
+ ok=%f
+ delete(f);
+ return
+ //-------------------------------------------------------------------
+ case "Clear" then
+ xy=[0,0];
+ NOrder=0;
+ ipar(2)=NOrder;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ //----------------------------------------------------------------
+ case "Edit text data NOT IN USE" then
+ // editvar xy;
+ [mok,xt,yt]=scicos_getvalue("Enter x and y data",["x";"y"],list("vec",-1,"vec",-1),list(strcat(sci2exp(xy(:,1))),strcat(sci2exp(xy(:,2)))));
+ if mok then,
+ xy=[xt,yt];
+ [xy]=cleandata(xy),
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ end
+ //---------------------------------------------------------------
+ case "Help" then
+ t1="Mouse-left click: adding a new point"
+ t2="Mouse-right click: remove a point"
+ t3="Mouse-left double click: edit a point''s coordinates"
+ t4="Mouse-left button press/drag/release: move a point"
+ t5="Change the window size: ''Data'' menu -> ''Databounds''"
+ x_message([t1;t2;t3;t4;t5]);
+ //---------------------------------------------------------------
+ case "Load from Excel" then
+ [tok,xytt]=ReadExcel()
+ if tok then
+ xy=xytt;
+ NOrder=1
+ ipar(2)=NOrder;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ end
+ //---------------------------------------------------------------
+ case "Load from text file" then
+ [tok,xytt]=ReadFromFile()
+ if tok then
+ xy=xytt;
+ NOrder=1
+ ipar(2)=NOrder;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ end
+ //---------------------------------------------------------------
+ case "Save to text file" then
+ [sok]=SaveToFile(xy)
+ //---------------------------------------------------------------
+ case "Replot" then
+ if xy<>[] then
+ drawlater();
+ points.data=xy;
+ [rpar,ipar]=drawSplin(a,xy,ipar,rpar);
+ drawnow()
+ end
+ //----------------------------------------------------------
+ case "edit" then
+ HIT=%f
+ if N<>0 then
+ xt=xy(:,1);
+ yt=xy(:,2);
+ dist=((xt-ones(N,1)*xc))^2+((yt-ones(N,1)*yc))^2
+ [dca,k]=min(dist);
+ rectx=a.data_bounds;
+ ex=abs(rectx(2,1)-rectx(1,1))/80;
+ ey=abs(rectx(2,2)-rectx(1,2))/80;
+ if (abs(xc-xt(k))<ex & abs(yc-yt(k))<ey) then
+ HIT=%t
+ end
+ end
+
+ //_________________________
+ // if ~((NOrder==-1|NOrder==-2|NOrder==-3|NOrder==-4)) then
+ if (~HIT)&(btn==0 | btn==3) then // add point
+ xy=[xy;xc,yc];
+ [xtt,k2]=gsort(xy(:,1),"r","i");xy=xy(k2,:)
+ drawlater();
+ points.data=xy;
+ [rpar,ipar]=drawSplin(a,xy,ipar,rpar);
+ drawnow()
+ end
+
+ if (HIT)&(btn==2 | btn==5) then // remove point
+ xy(k,:)=[];
+ drawlater();
+ points.data=xy;
+ [rpar,ipar]=drawSplin(a,xy,ipar,rpar);
+ drawnow()
+ end
+
+ if (HIT)&(btn==0) then // move point
+ [xy,rpar,ipar]=movept(a,xy,ipar,rpar,k)
+ end
+
+ if (HIT)&(btn==10) then // change data:: double click
+ [mok,xt,yt]=scicos_getvalue("Enter new x and y",["x";"y"],list("vec", ...
+ 1,"vec",1),list(sci2exp(xy(k,1)),sci2exp(xy(k,2))));
+ if mok then
+ xy(k,:)=[xt,yt];
+ [xy]=cleandata(xy)
+ drawlater();
+ points.data=xy;
+ [rpar,ipar]=AutoScale(a,xy,ipar,rpar)
+ drawnow()
+ end
+ end
+
+ // end
+ //_________________________________
+
+ end
+ //----------------------------------------------------------
+ end
+endfunction
+//========================================================================
+function [orpar,oipar]=drawSplin(a,xy,iipar,irpar)
+ N=size(xy,"r");// new size of xy
+ x=xy(:,1);
+ y=xy(:,2);
+ points=a.children(2).children
+ splines=a.children(1).children
+ order=iipar(2);
+ periodicoption=iipar(3);
+ extrapo=iipar(4);
+ orpar=irpar;
+
+ METHOD=getmethod(order);
+
+ if periodicoption==1 then
+ PERIODIC="periodic, T="+string(x(N)-x(1));
+ else
+ PERIODIC="aperiodic";
+ end
+ a.title.text=[string(N)+" points, "+"Method: "+METHOD+", "+PERIODIC];
+
+ if (N==0) then,
+ return;
+ end
+ if (N==1) then,
+ order=0;
+ end
+ // NP=50;// number of intermediate points between two data points
+
+ xmx=max(points.data(:,1));
+ xmn=min(points.data(:,1));
+ xmx1=max(a.x_ticks.locations);
+ xmn1=min(a.x_ticks.locations)
+ xmx=max(xmx,xmx1);
+ xmn=min(xmn,xmn1);
+ [X,Y,orpar]=Do_Spline(N,order,x,y,xmx,xmn,extrapo);
+
+ if (periodicoption==1) then
+ X=[X;X($)];
+ Y=[Y;Y(1)];
+ else
+ //X=[X;XMX];
+ //Y=[Y;Y($)];
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ splines.data=[X,Y];
+ oipar=[N;iipar(2);periodicoption;extrapo]
+endfunction
+//=============================================================
+function [xyt,orpar,oipar]=movept(a,xy,iipar,irpar,k)
+ //on bouge un point existant
+ points=a.children(2).children
+ splines=a.children(1).children
+ oipar=iipar
+ orpar=irpar
+ order=iipar(2);
+ x=xy(:,1);
+ y=xy(:,2);
+
+ x(k)=[];
+ y(k)=[];
+
+ btn=-1
+
+ while ~(btn==3 | btn==0| btn==10| btn==-5)
+ rep=xgetmouse([%t %t]);
+ xc=rep(1);
+ yc=rep(2);
+ btn=rep(3);
+
+ xt=[x;xc];
+ yt=[y;yc];
+ [xt,k2]=gsort(xt,"r","i");yt=yt(k2)
+ xyt=[xt,yt];
+
+ drawlater();
+ points.data=xyt;
+ [orpar,oipar]=drawSplin(a,xyt,oipar,orpar);
+ drawnow()
+ end
+
+endfunction
+
+//==========================================================
+function rectx=findrect(a)
+ splines=a.children(1).children
+ points=a.children(2).children
+
+ if (points.data==[]) then
+ rectx=a.data_bounds;
+ return;
+ end
+
+
+ ymx1=max(splines.data(:,2));
+ ymn1=min(splines.data(:,2))
+
+ xmx=max(points.data(:,1));
+ xmn=min(points.data(:,1));
+ ymx=max(points.data(:,2));
+ ymn=min(points.data(:,2));
+
+
+ XMX=max(xmx);
+ XMN=max(xmn);
+ YMX=max(ymx,ymx1);
+ YMN=min(ymn,ymn1);
+
+ dx=XMX-XMN;
+ dy=YMX-YMN
+ if dx==0 then
+ dx=max(XMX/2,1),
+ end;
+ XMX=XMX+dx/50
+ if dy==0 then
+ dy=max(YMX/2,1),
+ end;
+ YMN=YMN-dy/50;
+ YMX=YMX+dy/50;
+ rectx=[XMN,YMN;XMX,YMX];
+endfunction
+
+//============================================================
+function [tok,xyo]=ReadExcel()
+ TA=["A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P"; ...
+ "Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"a";"b";"c";"d";"e";"f"; ...
+ "g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v"; ...
+ "w";"x";"y";"z"];
+ TN=["0","1","2","3","4","5","6","7","8","9"];
+ xyo=[];
+ tok=%f;
+ while %t
+ [zok,filen,sheetN,xa,ya]=scicos_getvalue("Excel data file ",["Filename";"Sheet # ";"X[start:Stop]";"Y[start:stop]"],list("str",1, ...
+ "vec",1,"str",1, ...
+ "str",1), ...
+ list(["Classeur1.xls"],["1"],["C5:C25"],["D5:D25"]));
+ if ~zok then
+ break,
+ end
+
+ try
+ [fd,SST,Sheetnames,Sheetpos] = xls_open(filen);
+ catch
+ xinfo("Scicos cannot find the excel file:"+filen);
+ break;
+ end
+ try
+ N=size(Sheetnames,"*");
+ if ((sheetN<=N) &(sheetN>0)) then
+ [Value,TextInd] = xls_read(fd,Sheetpos(sheetN))
+ mclose(fd)
+ end
+ xa=strsubst(xa," ","");
+ px=strindex(xa,":");
+ ya=strsubst(ya," ","");
+ py=strindex(ya,":");
+ x1=part(xa,1:px-1);
+ x2=part(xa,px+1:length(xa));
+ y1=part(ya,1:py-1);
+ y2=part(ya,py+1:length(ya));
+
+ x1p=min(strindex(x1,TN));
+ if x1p==[] then,
+ xinfo("Bad address in X:"+x1);
+ break,
+ end
+ x11=part(x1,1:x1p-1);
+ x12=part(x1,x1p:length(x1));
+
+ x2p=min(strindex(x2,TN));
+ if x2p==[] then,
+ xinfo("Bad address in X:"+x2);
+ break,
+ end
+ x21=part(x2,1:x2p-1);
+ x22=part(x2,x2p:length(x2));
+
+ y1p=min(strindex(y1,TN));
+ if y1p==[] then,
+ xinfo("Bad address in Y:"+y1);
+ break,
+ end
+ y11=part(y1,1:y1p-1);
+ y12=part(y1,y1p:length(y1));
+
+ y2p=min(strindex(y2,TN));
+ if y2p==[] then,
+ xinfo("Bad address in Y:"+y2);
+ break,
+ end
+ y21=part(y2,1:y2p-1);
+ y22=part(y2,y2p:length(y2));
+
+ // x11 x12: x21 x22
+
+ lx11=length(x11);
+ lx21=length(x21);
+ ly11=length(y11);
+ ly21=length(y21)
+ xstC=0;
+ for i=1:lx11,
+ xstC=xstC+modulo(find(TA==part(x11,lx11-i+1)),26)*26^(i-1);
+ end
+ xenC=0;
+ for i=1:lx21,
+ xenC=xenC+modulo(find(TA==part(x21,lx21-i+1)),26)*26^(i-1);
+ end
+ ystC=0;
+ for i=1:ly11,
+ ystC=ystC+modulo(find(TA==part(y11,ly11-i+1)),26)*26^(i-1);
+ end
+ yenC=0;
+ for i=1:ly11,
+ yenC=yenC+modulo(find(TA==part(y21,ly21-i+1)),26)*26^(i-1);
+ end
+
+ xstR=evstr(x12);
+ xenR=evstr(x22);
+ ystR=evstr(y12);
+ yenR=evstr(y22);
+
+ [mv,nv]=size(Value)
+
+ if ~(xstR<=mv & xstR>0 & xenR<=mv & xenR>0&ystR<=mv & ystR>0&yenR<=mv&yenR>0 ) then
+ xinfo("error in Row data addresses");
+ break
+ end
+ if ~(xstC<=nv & xstC>0 & xenC<=nv & xenC>0&ystC<=nv & ystC>0&yenC<=nv&yenC>0 ) then
+ xinfo("error in Column data addresses");
+ break
+ end
+
+ xo=Value(min(xstR,xenR):max(xstR,xenR),min(xstC,xenC):max(xstC,xenC));
+ yo=Value(min(ystR,yenR):max(ystR,yenR),min(ystC,yenC):max(ystC,yenC));
+ [nx,mx]=size(xo);// adjusting the x and y size
+ [ny,my]=size(yo);
+ N=min(nx,ny);
+ xo=xo(1:N,:);
+ yo=yo(1:N,:);
+
+ xyo=[xo,yo];
+ [xyo]=cleandata(xyo)
+
+ tok=%t;
+ break,
+ catch
+ xinfo(" Scicos cannot read your Excel file, please verify the parameters ");
+ break
+ end
+ end
+
+endfunction
+//---------------------------------------------------------------
+function [xyo]=cleandata(xye)
+ xe=xye(:,1)
+ ye=xye(:,2)
+
+ [nx,mx]=size(xe);// adjusting the x and y size
+ [ny,my]=size(ye);
+ N=min(nx,ny);
+ xe=xe(1:N,:);
+ ye=ye(1:N,:);
+
+ // checking for NULL data
+ for i=1:N
+ if (xe(i)<>xe(i)) then
+ xinfo("x contains no data:x("+string(i)+")");
+ return;
+ end
+ if (ye(i)<>ye(i)) then
+ xinfo("Y contains no data:y("+string(i)+")");
+ return;
+ end
+ end
+
+ [xo,k2]=gsort(xe,"r","i");
+ yo=ye(k2)
+
+ xyo=[xo,yo];
+endfunction
+//---------------------------------------------------------------
+function [orpar,oipar]=AutoScale(a,xy,inipar,inrpar)
+ drawlater();
+ oipar=inipar
+ orpar=inrpar
+ points=a.children(2).children
+ splines=a.children(1).children
+ points.data=xy;
+ splines.data=xy;
+ [orpar,oipar]=drawSplin(a,xy,oipar,orpar);
+ rectx=findrect(a);
+ a.data_bounds=rectx;
+ drawnow()
+endfunction
+//============================
+function METHOD=getmethod(order)
+ select order
+ case 0 then,
+ METHOD="zero order-below"
+ case 1 then,
+ METHOD="linear"
+ case 2 then,
+ METHOD="order 2"
+ case 3 then,
+ METHOD="not_a_knot"
+ case 4 then,
+ METHOD="periodic"
+ case 5 then,
+ METHOD="monotone"
+ case 6 then,
+ METHOD="fast"
+ case 7 then,
+ METHOD="clamped"
+ case 8 then,
+ METHOD="zero order-above"
+ case 9 then,
+ METHOD="zero order-nearest"
+ end
+endfunction
+//=======================================
+function [sok,xye]=ReadFromFile()
+ xye=[];
+ sok=%f;
+ while %t
+ [sok,filen,Cformat,Cx,Cy]=scicos_getvalue("Text data file ",["Filename";"Reading [C] format";"Abscissa column";"Output column"],list("str",1,"str",1,"vec",1,"vec",1), ...
+ list(["mydatafile.dat"],["%g %g"],["1"],["2"]));
+ if ~sok then
+ break,
+ end
+ px=strindex(Cformat,"%");
+ NC=size(px,"*");
+ if NC==[] then,
+ xinfo("Bad format in reading data file");
+ sok=%f;
+ break;
+ end
+ Lx=[];
+ try
+ fd=mopen(filen,"r");
+ Lx=mfscanf(-1,fd,Cformat);
+ mclose(fd);
+ catch
+ xinfo("Scicos cannot open the data file:"+filen);
+ break;
+ end
+
+ [nD,mD]=size(Lx);
+ if ((mD==0) | (nD==0)) then,
+ xinfo("No data read");
+ sok=%f;
+ break;
+ end
+ if (mD<>NC) then,
+ xinfo("Bad format");
+ sok=%f;
+ break;
+ end
+
+ xe=Lx(:,Cx);ye=Lx(:,Cy);
+ xye=[xe,ye];
+ [xye]=cleandata(xye)
+ sok=%t;
+ break,
+ end
+endfunction
+//=======================================
+function [sok]=SaveToFile(xye)
+ xe=xye(:,1)
+ ye=xye(:,2)
+ sok=%f;
+ while %t
+ [sok,filen,Cformat]=scicos_getvalue("Text data file ",["Filename";"Writing [C] format"],list("str",1,"str",1), ...
+ list(["mydatafile.dat"],["%g %g"]));
+ if ~sok then
+ break,
+ end
+ px=strindex(Cformat,"%");
+ NC=size(px,"*");
+ if NC<>2 then,
+ xinfo("Bad format in writing data file");
+ sok=%f;
+ break;
+ end
+
+ Cformat=Cformat+"\n";
+
+ try
+ fd=mopen(filen,"w");
+ mfprintf(fd,Cformat,xe,ye);
+ mclose(fd);
+ catch
+ xinfo("Scicos cannot open the data file:"+filen);
+ break;
+ end
+
+ sok=%t;
+ break,
+ end
+endfunction
+//=========================================================
+function [X,Y,orpar]=Do_Spline(N,order,x,y,xmx,xmn,extrapo)
+ X=[];
+ Y=[];
+ orpar=[];
+
+ METHOD=getmethod(order);
+
+ if (METHOD=="zero order-below") then
+ X=[xmn;x(1)];
+ Y=[y(1);y(1)];
+ for i=1:N-1
+ X=[X;x(i+1);x(i+1)];
+ Y=[Y;y(i);y(i+1)];
+ end
+ X=[X;xmx];
+ Y=[Y;y(N)];
+ return
+ end
+ if (METHOD=="zero order-above") then
+ X=[xmn;x(1)];
+ Y=[y(1);y(1)];
+ for i=1:N-1
+ X=[X;x(i);x(i+1)];
+ Y=[Y;y(i+1);y(i+1)];
+ end
+ X=[X;xmx];
+ Y=[Y;y(N)];
+ return
+ end
+ if (METHOD=="zero order-nearest") then
+ X=[xmn;x(1)];
+ Y=[y(1);y(1)];
+ for i=1:N-1
+ X=[X;(x(i)+x(i+1))/2;(x(i)+x(i+1))/2];
+ Y=[Y;y(i);y(i+1)];
+ end
+ X=[X;xmx];
+ Y=[Y;y(N)];
+ return
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="linear") then
+
+ if N<=1 then
+ return;
+ end
+ if extrapo==0 then
+ X=[xmn];
+ Y=[y(1)];
+ end
+ if extrapo==1 then
+ X=[xmn];
+ Y=y(1)+(xmn-x(1))*(y(1)-y(2))/(x(1)-x(2));
+ end
+ for i=1:N
+ X=[X;x(i)];
+ Y=[Y;y(i)];
+ end
+ if extrapo==0 then
+ X=[X;xmx];
+ Y=[Y;y(N)];
+ end
+ if extrapo==1 then
+ X=[X;xmx];
+ Y=[Y;y(N)+(xmx-x(N))*(y(N)-y(N-1))/(x(N)-x(N-1))];
+ end
+ return
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (N<25) then
+ NP=10;
+ elseif (N<50) then
+ NP=5;
+ elseif (N<100) then
+ NP=2;
+ elseif (N<200) then
+ NP=1;
+ else
+ NP=0;
+ end
+ for i=1:N-1
+ X=[X;linspace(x(i),x(i+1),NP+2)']; // pour tous sauf "linear" et "zero order"
+ end
+ if extrapo==1 then
+ X=[linspace(xmn,x(1),NP+2)';X;linspace(x(N),xmx,NP+2)'];
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (N>2) & (METHOD=="order 2") then
+ Z=ORDER2(x,y);
+ A=Z(1:N-1);
+ B=Z(N:2*N-2);
+ C=Z(2*N-1:3*N-3);
+ for j=1:size(X,"*")
+ for i=N-1:-1:1
+ if X(j)>=x(i) then,
+ break;
+ end
+ end
+ Y(j)=A(i)*(X(j)-x(i))^2+B(i)*(X(j)-x(i))+C(i);
+ end
+ orpar=matrix(Z,-1,1)
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="not_a_knot") then
+ try
+ d = splin(x, y, METHOD);
+ Y = interp(X, x, y, d);
+ orpar=d(:);
+ catch
+ xinfo("ERROR in SPLINE: "+METHOD)
+ end
+
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="periodic") then
+ if y(1)<>y(N) then
+ y(N)=y(1)
+ end
+ try
+ d = splin(x, y,METHOD);
+ Y = interp(X, x, y, d);
+ orpar=d(:);
+ catch
+ xinfo("ERROR in SPLINE: "+METHOD)
+ end
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="monotone" ) then
+ try
+ d = splin(x, y, METHOD);
+ Y = interp(X, x, y, d);
+ orpar=d(:);
+ catch
+ xinfo("ERROR in SPLINE: "+METHOD)
+ end
+
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="fast") then
+ try
+ d = splin(x, y, METHOD);
+ Y = interp(X, x, y, d);
+ orpar=d(:);
+ catch
+ xinfo("ERROR in SPLINE: "+METHOD)
+ end
+ end
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if (METHOD=="clamped") then
+ try
+ d = splin(x, y, METHOD,[0;0]);
+ Y = interp(X, x, y, d);
+ orpar=d(:);
+ catch
+ xinfo("ERROR in SPLINE: "+METHOD)
+ end
+ end
+ if extrapo==0 then
+ X=[X;xmx];
+ Y=[Y;y(N)];
+ end
+
+endfunction
+//=================================================
+function [Z]=ORDER2(x,y)
+ N=size(x,"*")-1;
+ A=zeros(3*N-1,N*3);
+ B=zeros(3*N-1,1);
+ for i=1:N
+ j=3*(i-1)+1;
+ A(j,i+2*N)=1;
+ B(j)=y(i);
+ A(j+1,i)=(x(i+1)-x(i))^2;
+ A(j+1,i+N)=x(i+1)-x(i);
+ A(j+1,i+2*N)=1;
+ B(j+1)=y(i+1);
+ end
+
+ for i=1:N-1
+ j=3*(i-1)+1;
+ A(j+2,i)=2*(x(i+1)-x(i));
+ A(j+2,i+N)=1;
+ A(j+2,i+N+1)=-1;
+ end
+
+ Q=zeros(3*N,3*N);
+ for i=1:N
+ Q(i,i)=4*(x(i+1)-x(i))^2
+ Q(i,i+N)=2*(x(i+1)-x(i))
+ Q(i+N,i)=2*(x(i+1)-x(i))
+ Q(i+N,i+N)=1;
+ end
+
+ At=[Q,A';A,zeros(3*N-1,3*N-1)]
+ Bt=[zeros(3*N,1);B]
+ Zt=At\Bt;
+ Z=Zt(1:3*N,1)
+endfunction
+//===================================================
+
+
+
diff --git a/macros/NonLinear/LOOKUP_f.sci b/macros/NonLinear/LOOKUP_f.sci
new file mode 100644
index 00000000..51f1fc88
--- /dev/null
+++ b/macros/NonLinear/LOOKUP_f.sci
@@ -0,0 +1,72 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=LOOKUP_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ rpar=model.rpar;
+ n=size(rpar,"*")/2
+ xx=rpar(1:n);
+ yy=rpar(n+1:2*n)
+ while %t do
+ [ln,fun]=where();
+
+ if ~or(fun == "do_eval") then // cas standard
+ [xx,yy,ok,gc] = edit_curv(xx,yy,"axy");
+ else
+ ok=%t
+ end // no need anymore to overload edit_curv in do_eval
+
+ if ~ok then
+ break,
+ end
+ n=size(xx,"*")
+ if or(xx(2:n)-xx(1:n-1)<=0) then
+ message("You have not defined a function")
+ ok=%f
+ end
+ if ok then
+ model.rpar=[xx(:);yy(:)]
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ model=scicos_model()
+ model.sim="lookup"
+ model.in=1
+ model.out=1
+ model.rpar=[-2;-1;1;2;-1;1;-1;1]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ gr_i=[]
+ x=standard_define([2 2],model,[],gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/MAXMIN.sci b/macros/NonLinear/MAXMIN.sci
new file mode 100644
index 00000000..fb6db898
--- /dev/null
+++ b/macros/NonLinear/MAXMIN.sci
@@ -0,0 +1,95 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=MAXMIN(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,mm,nin,zcr,exprs]=..
+ scicos_getvalue("Set Max/Min block parameters",..
+ ["Min (1) or Max (2) ";"Number of input vectors (1 or 2)";"zero-crossing (1: yes, 0;no)"],..
+ list("vec",1,"vec",1,"vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if zcr<>0 then
+ zcr=-1,
+ end
+ if mm<>1 then
+ mm=2,
+ end
+ if nin<>1 & nin<>2 then
+ message("Wrong number of inputs, only 1 and 2 allowed")
+ ok=%f
+ end
+ if ok then
+ if nin==1 then
+ [model,graphics,ok]=check_io(model,graphics,-1,1,[],[])
+ else
+ [model,graphics,ok]=check_io(model,graphics,[-1,-1],-1,[],[])
+ end
+ end
+ if ok then
+ model.nzcross=zcr;
+ if nin==1 then
+ model.nmode=abs(zcr);
+ else
+ model.nmode=zcr
+ end
+ model.ipar=mm;
+
+ // Update the label of the block
+ if mm == 1 then
+ label="MIN";
+ else
+ label="MAX";
+ end
+ graphics.style="MAXMIN;displayedLabel=" + label;
+
+ graphics.exprs=exprs;
+ x.graphics=graphics;
+ x.model=model;
+ break
+ end
+ end
+ case "define" then
+ model=scicos_model()
+ model.sim=list("minmax",4)
+ model.out=1
+ model.in=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ model.ipar=0;
+ exprs=[string([2,1,1]')]
+ gr_i=[]
+
+ x=standard_define([2 2],model,exprs,gr_i)
+ x.graphics.style="MAXMIN;displayedLabel=MAX"
+ end
+endfunction
+
diff --git a/macros/NonLinear/MAX_f.sci b/macros/NonLinear/MAX_f.sci
new file mode 100644
index 00000000..809ac54b
--- /dev/null
+++ b/macros/NonLinear/MAX_f.sci
@@ -0,0 +1,43 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=MAX_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=-1
+ model=scicos_model()
+ model.sim="maxblk"
+ model.in=in
+ model.out=1
+ model.dstate=[0;0]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=" "
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/MIN_f.sci b/macros/NonLinear/MIN_f.sci
new file mode 100644
index 00000000..580b5a7f
--- /dev/null
+++ b/macros/NonLinear/MIN_f.sci
@@ -0,0 +1,43 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=MIN_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ in=-1
+ model=scicos_model()
+ model.sim="minblk"
+ model.in=in
+ model.out=1
+ model.dstate=[0;0]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=sci2exp(in)
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/POWBLK_f.sci b/macros/NonLinear/POWBLK_f.sci
new file mode 100644
index 00000000..02d8e0d6
--- /dev/null
+++ b/macros/NonLinear/POWBLK_f.sci
@@ -0,0 +1,69 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=POWBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ if size(exprs,"*")==2 then
+ exprs=exprs(2),
+ end //compatibility
+ while %t do
+ [ok,a,exprs]=scicos_getvalue("Set u^a block parameters",..
+ "to the power of",list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ graphics.exprs=exprs
+ if a==int(a) then
+ model.ipar=a;
+ model.rpar=[]
+ else
+ model.rpar=a;
+ model.ipar=[]
+ end
+ model.firing=[] //compatibility
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ case "define" then
+ in=1
+ a=1.5
+ model=scicos_model()
+ model.sim="powblk"
+ model.in=-1
+ model.out=-1
+ model.rpar=a
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=string(a)
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/PRODUCT.sci b/macros/NonLinear/PRODUCT.sci
new file mode 100644
index 00000000..ed4ff195
--- /dev/null
+++ b/macros/NonLinear/PRODUCT.sci
@@ -0,0 +1,89 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ] = PRODUCT(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics
+ model=arg1.model
+ exprs=graphics.exprs
+ while %t do
+ [ok,sgn,exprs]=scicos_getvalue([" Set multiplication block parameters";
+ "(multiplication is set with + 1, division with -1)";""],...
+ "Number of inputs or sign vector",...
+ list("vec",-1),exprs)
+ if ~ok then
+ break,
+ end
+ sgn=sgn(:);
+ if size(sgn,1)==1 then
+ if sgn<1 then
+ message("Number of inputs must be > 0")
+ ok=%f
+ elseif sgn==1 then
+ in=-1
+ sgn=[]
+ nout=1
+ else
+ in=-ones(sgn,1)
+ sgn=ones(sgn,1)
+ nout=-1
+ end
+ else
+ if ~and(abs(sgn)==1) then
+ message("Signs can only be +1 or -1")
+ ok=%f
+ else
+ in=-ones(size(sgn,1),1)
+ nout=-1
+ end
+ end
+ if ok then
+ [model,graphics,ok]=check_io(model,graphics,in,nout,[],[])
+ end
+ if ok then
+ model.ipar=sgn
+ graphics.exprs=exprs
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ sgn=[1;-1]
+ model=scicos_model()
+ model.sim=list("product",4)
+ model.in=[-1;-1]
+ model.out=-1
+ model.ipar=sgn
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+
+ exprs=sci2exp(sgn)
+ gr_i=[]
+ x=standard_define([2 3],model, exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/PROD_f.sci b/macros/NonLinear/PROD_f.sci
new file mode 100644
index 00000000..4c392e44
--- /dev/null
+++ b/macros/NonLinear/PROD_f.sci
@@ -0,0 +1,40 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=PROD_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ p=1 //pixel sizes ratio
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ model=scicos_model()
+ model.sim=list("prod",2)
+ model.in=[-1;-1]
+ model.out=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ x=standard_define([1 1],model,[],[])
+ end
+endfunction
diff --git a/macros/NonLinear/QUANT_f.sci b/macros/NonLinear/QUANT_f.sci
new file mode 100644
index 00000000..3ec21a94
--- /dev/null
+++ b/macros/NonLinear/QUANT_f.sci
@@ -0,0 +1,77 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=QUANT_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t then
+ [ok,pas,meth,exprs]=scicos_getvalue("Set parameters",..
+ ["Step";"Quantization Type (1-4)"],..
+ list("vec",1,"vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if meth<1|meth>4 then
+ message("Quantization Type must be from 1 to 4")
+ else
+ rpar=pas
+ model.rpar=rpar
+ model.ipar=meth
+ select meth
+ case 1 then
+ model.sim="qzrnd"
+ case 2 then
+ model.sim="qztrn"
+ case 3 then
+ model.sim="qzflr"
+ case 4 then
+ model.sim="qzcel"
+ end
+ graphics.exprs=exprs
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ pas=0.1;
+ meth=1
+ model=scicos_model()
+ model.sim="qzrnd"
+ model.in=-1
+ model.out=-1
+ model.rpar=pas
+ model.ipar=meth
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[string(pas);string(meth)]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/SATURATION.sci b/macros/NonLinear/SATURATION.sci
new file mode 100644
index 00000000..cb2098b3
--- /dev/null
+++ b/macros/NonLinear/SATURATION.sci
@@ -0,0 +1,74 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=SATURATION(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,maxp,minp,zeroc,exprs]=scicos_getvalue("Set Saturation parameters",..
+ ["Upper limit";"Lower limit";"zero crossing (0:no, 1:yes)"],list("vec",1,"vec",1,"vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if maxp<=minp then
+ message("Upper limit must be > Lower limit")
+ else
+ rpar=[maxp;minp]
+ model.rpar=rpar
+ if zeroc<>0 then
+ model.nzcross=2
+ model.nmode=1
+ else
+ model.nzcross=0
+ model.nmode=0
+ end
+ graphics.exprs=exprs
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ minp=-1;
+ maxp=1;
+ rpar=[maxp;minp]
+ model=scicos_model()
+ model.sim=list("satur",4)
+ model.in=1
+ model.nzcross=2
+ model.nmode=1
+ model.out=1
+ model.rpar=rpar
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[string(maxp);string(minp);string(model.nmode)]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/SAT_f.sci b/macros/NonLinear/SAT_f.sci
new file mode 100644
index 00000000..53f572e0
--- /dev/null
+++ b/macros/NonLinear/SAT_f.sci
@@ -0,0 +1,71 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=SAT_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,minp,maxp,pente,exprs]=scicos_getvalue("Set Saturation parameters",..
+ ["Min";"Max";"Slope"],list("vec",1,"vec",1,"vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ if maxp<=0 then
+ message("Max must be strictly positive")
+ elseif pente<=0 then
+ message("Slope must be strictly positive")
+ else
+ rpar=[minp/pente;maxp/pente;pente]
+ model.rpar=rpar
+ model.firing=[] //compatibility
+ graphics.exprs=exprs
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ minp=-1;
+ maxp=1;
+ slope=1;
+ rpar=[minp;maxp;slope]
+
+ model=scicos_model()
+ model.sim=list("lusat",1)
+ model.in=1
+ model.nzcross=2
+ model.out=1
+ model.rpar=[minp;maxp;slope]
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[string(minp);string(maxp);string(slope)]
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/SIGNUM.sci b/macros/NonLinear/SIGNUM.sci
new file mode 100644
index 00000000..0b2c376d
--- /dev/null
+++ b/macros/NonLinear/SIGNUM.sci
@@ -0,0 +1,70 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=SIGNUM(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ while %t do
+ [ok,zcr,exprs]=..
+ scicos_getvalue("Set block parameters",..
+ ["use zero_crossing (1: yes) (0:no)"],..
+ list("vec",1),exprs)
+ if ~ok then
+ break,
+ end
+ graphics.exprs=exprs
+ if ok then
+ if zcr<>0 then
+ model.nmode=-1;
+ model.nzcross=-1;
+ else
+ model.nmode=0;
+ model.nzcross=0;
+ end
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ nu=-1
+ model=scicos_model()
+ model.sim=list("signum",4)
+ model.in=nu
+ model.out=nu
+ model.nzcross=nu
+ model.nmode=nu
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=[string([1])]
+ gr_i=[]
+
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/SINBLK_f.sci b/macros/NonLinear/SINBLK_f.sci
new file mode 100644
index 00000000..e6f86d4a
--- /dev/null
+++ b/macros/NonLinear/SINBLK_f.sci
@@ -0,0 +1,41 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=SINBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ case "define" then
+ model=scicos_model()
+ model.sim="sinblk"
+ model.in=-1
+ model.out=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=" "
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/TANBLK_f.sci b/macros/NonLinear/TANBLK_f.sci
new file mode 100644
index 00000000..ffea89ea
--- /dev/null
+++ b/macros/NonLinear/TANBLK_f.sci
@@ -0,0 +1,43 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=TANBLK_f(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ x.model.firing=[]
+ case "define" then
+ in=-1
+ model=scicos_model()
+ model.sim="tanblk"
+ model.in=in
+ model.out=in
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+
+ exprs=sci2exp(in)
+ gr_i=[]
+ x=standard_define([2 2],model,exprs,gr_i)
+ end
+endfunction
diff --git a/macros/NonLinear/TrigFun.sci b/macros/NonLinear/TrigFun.sci
new file mode 100644
index 00000000..a9c1600c
--- /dev/null
+++ b/macros/NonLinear/TrigFun.sci
@@ -0,0 +1,63 @@
+// Scicos
+//
+// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=TrigFun(job,arg1,arg2)
+ x=[];
+ y=[];
+ typ=[];
+ select job
+ case "set" then
+ x=arg1;
+ graphics=arg1.graphics;
+ exprs=graphics.exprs
+ model=arg1.model;
+ %FF=["sin";"cos";"tan";
+ "asin";"acos";"atan";
+ "sinh";"cosh";"tanh";
+ "asinh";"acosh";"atanh"];
+ %GG=["Choose among "+strcat(%FF(1:4),", ");strcat(%FF(5:$),", ")]
+ while %t do
+ [ok,fun,exprs]=scicos_getvalue(%GG,"Function",list("str",1),exprs)
+ if ~ok then
+ break,
+ end
+ if find(%FF==fun)==[] then
+ message("Sorry but "+fun +" is not in the list!")
+ else
+ graphics.exprs=exprs
+ execstr("model.sim=list(''"+fun+"_blk'',4)")
+ x.graphics=graphics;
+ x.model=model
+ break
+ end
+ end
+ case "define" then
+ model=scicos_model()
+ model.sim=list("sin_blk",4)
+ model.in=-1
+ model.out=-1
+ model.blocktype="c"
+ model.dep_ut=[%t %f]
+ exprs="sin"
+ gr_i=[]
+ x=standard_define([4 2],model,exprs,gr_i)
+ end
+endfunction