* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / MatrixOp / MATRESH.sci
1 //  Scicos
2 //
3 //  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // See the file ../license.txt
20 //
21
22 function [x,y,typ]=MATRESH(job,arg1,arg2)
23     //
24     x=[];
25     y=[];
26     typ=[];
27     select job
28     case "set" then
29         x=arg1
30         model=arg1.model;
31         graphics=arg1.graphics;
32         label=graphics.exprs
33         if size(label,"*")==14 then
34             label(9)=[],
35         end //compatiblity
36         while %t do
37             [ok,typ,l1,out,lab]=..
38             scicos_getvalue(msprintf(_("Set %s block parameters"), "MATRESH"),..
39                 _(["Datatype (1=real double  2=Complex)";
40                    "Input size";
41                    "Output size desired"]), ..
42             list("vec",-1,"vec",-1,"vec",-1),label)
43             if ~ok then
44                 break,
45             end
46             nout=size(out)
47             nin=size(l1)
48             if nout==0 then
49                 message(_("Output size > 0 expected"));
50                 ok=%f;
51             end
52             if nin==0 then
53                 message(_("Input size > 0 expected"));
54                 ok=%f;
55             end
56             if ok then
57                 if ((out(1)>(l1(1)*l1(2)))) then
58                     message(_("The first dimension of the output is too big"));
59                     ok=%f;
60                 end
61                 if ((out(2)>(l1(1)*l1(2)))) then
62                     message(_("The second dimension of the output is too big"));
63                     ok=%f;
64                 end
65                 if (((out(2)*out(1))>(l1(1)*l1(2)))) then
66                     message(_("The dimensions of the output are too big"));
67                     ok=%f;
68                 end
69             end
70             if (typ==1) then
71                 function_name="mat_reshape";
72                 ot=1;
73                 it=1;
74             elseif (typ==2) then
75                 function_name="matz_reshape";
76                 ot=2;
77                 it=2;
78             else
79                 message(_("Unknown datatype"));
80                 ok=%f;
81             end
82             if ok then
83                 label=lab
84                 [model,graphics,ok]=set_io(model,graphics,list(l1,it),list(out,ot),[],[])
85             end
86             if ok then
87                 funtyp=4;
88                 model.sim=list(function_name,funtyp)
89                 graphics.exprs=label
90                 arg1.graphics=graphics
91                 arg1.model=model
92                 x=arg1
93                 break
94             end
95         end
96         needcompile=resume(needcompile)
97     case "define" then
98         model=scicos_model()
99         function_name="mat_reshape";
100         funtyp=4;
101         model.sim=list(function_name,funtyp)
102         model.in=-1
103         model.in2=-2
104         model.intyp=1
105         model.out=-1
106         model.out2=-2
107         model.outtyp=1
108         model.evtin=[]
109         model.evtout=[]
110         model.state=[]
111         model.dstate=[]
112         model.rpar=[]
113         model.ipar=[]
114         model.blocktype="c"
115         model.firing=[]
116         model.dep_ut=[%t %f]
117         label=[sci2exp(1);sci2exp([1,1]);sci2exp([1,1])];
118         gr_i=[]
119         x=standard_define([3 2],model,label,gr_i)
120     end
121 endfunction
122