5e58bf1259c82c70725fd4e11bfe43865b37fd52
[scilab.git] / scilab / modules / integer / macros / %i_p_i.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA -
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13
14 function r=%i_p_i(a,n)
15     if or(n<0) then
16         r=double(a)^n
17     else
18         if size(a,"*")==1 then
19             r=iconvert(double(a)^double(n),inttype(a))
20         else
21             if size(n,"*")<>1 then
22                 error(43)
23             else
24                 n=double(n)
25                 r=a
26                 if size(a,1)==size(a,2) then
27                     for i=2:n,r=r*a,end
28                 else
29                     mprintf(gettext("Warning: Syntax ""vector ^ scalar"" is obsolete. It will be removed in Scilab 6.0.\n  Use ""vector .^ scalar"" instead.\n"));
30                     for i=2:n,r=r.*a,end
31                 end
32             end
33         end
34     end
35 endfunction