1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA - Farid BELAHCENE
3 // Copyright (C) 2011 - DIGITEO - Michael Baudin
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 // Copyright (C) 2020 - Samuel GOUGEON
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
14 function y = complex(varargin)
17 // Given the real part and the imaginary part this function constructs the complex form :
18 // y = complex(a,b) returns y = a + b*i
20 // a, b : real scalars/vectors/matrices
25 if ( rhs<1 | rhs>2 ) then
26 error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"complex",1,2));
29 // Get input arguments
41 // Check type of input arguments
42 if and(type(a)<>[1 4 5 6 8]) then
43 error(msprintf(gettext("%s: Argument #%d: Decimal numbers expected.\n"),"complex",1));
44 elseif or(type(a)==[4 6])
49 if and(type(b)<>[1 4 5 6 8]) then
50 error(msprintf(gettext("%s: Argument #%d: Decimal numbers expected.\n"),"complex",2));
51 elseif or(type(b)==[4 6])
58 if ( size(a,"*") <> 1 & size(b,"*") <> 1 & size(a)<>size(b) ) then
59 error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"complex",1,2));
62 // Check content of input arguments
64 error(msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"),"complex",1));
69 error(msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"),"complex",2));