Bug #6009 fixed - conv2, convol2d and conv function added
[scilab.git] / scilab / modules / signal_processing / macros / conv.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2012 - INRIA - Serge STEER
3 // 
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution.  The terms
7 // are also available at    
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9 function h=conv(u,v,shape)
10   if and(size(u)>1) then
11     error( msprintf(_("%s: Wrong size for argument #%d: Vector expected.\n"),"conv",1))
12   end
13   if and(size(v)>1) then
14         error( msprintf(_("%s: Wrong size for argument #%d: Vector expected.\n"),"conv",2))
15   end
16   if argn(2)==2 then 
17     shape='full',
18   elseif and(shape<>["full","same","valid"]) then
19     error(msprintf(_("%s: Wrong value for input argument #%d: ""%s"" or ""%s"" expected.\n"),"conv",3, """full"", ""same""","""valid"""));
20   end
21  
22   h=conv2(u(:),v(:),shape);
23   //set result orientation
24   if shape=="full" then
25     if size(u,'*')>size(v,'*') then
26       if size(u,1)==1 then h=matrix(h,1,-1);end
27     else
28       if size(v,1)==1 then h=matrix(h,1,-1);end
29     end
30   else
31     if size(u,1)==1 then h=matrix(h,1,-1);end
32   end
33 endfunction
34