diff options
author | yash1112 | 2017-07-07 21:20:49 +0530 |
---|---|---|
committer | yash1112 | 2017-07-07 21:20:49 +0530 |
commit | 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 (patch) | |
tree | f50d6e06d8fe6bc1a9053ef10d4b4d857800ab51 /2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci | |
download | Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.gz Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.bz2 Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.zip |
sci2c arduino updated
Diffstat (limited to '2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci')
-rw-r--r-- | 2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci b/2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci new file mode 100644 index 00000000..f439e23e --- /dev/null +++ b/2.3-1/macros/FunctionAnnotation/FA_SZ_OPPLUS.sci @@ -0,0 +1,93 @@ +function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type)
+// function opoutsize = FA_SZ_OPPLUS(in1size,in2size,in1type,in2type)
+// -----------------------------------------------------------------
+// Returns the size of the output computed by OPPLUS operator,
+// including the string operations.
+//
+// Assuming:
+// size(in1) = [in1r,in1c]
+// size(in2) = [in2r,in2c]
+// size(out) = [outr,outc]
+//
+// we have the following combinations:
+// in1 in2 outr outc
+// -----------------------
+// S S in2r in2c
+// S M in2r in2c
+// M S in1r in1c
+// M M in1r in1c
+//
+// Where S means that the input is a scalar
+// and M means that the input is a matrix.
+// There is also the case related to the string catenation!
+// This is the main difference between - and + operators.
+//
+// Input data:
+// in1size: size of input number 1. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// in2size: size of input number 2. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Output data:
+// opoutsize: size of output. It is an array of 2 strings.
+// The first string specifies the number of rows.
+// The second string specifies the number of columns.
+//
+// Status:
+// 08-Dec-2007 -- Raffaele Nutricato: Author.
+// 08-Dec-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),4,4);
+
+// ------------------------
+// --- Generate Output. ---
+// ------------------------
+// --- Get dimensions of input arguments. ---
+in1size = string(in1size);
+in2size = string(in2size);
+in1type = string(in1type);
+in2type = string(in2type);
+in1dim = GetSymbolDimension(in1size);
+
+if ((in1type ~= 'g') & (in2type ~= 'g'))
+ opoutsize = FA_SZ_OPPLUSA(in1size,in2size);
+elseif ((in1type == 'g') & (in2type == 'g'))
+ opoutsize(1) = '1';
+ if (isnum(in1size(1)) & isnum(in2size(1)))
+ in1num = eval(in1size(1));
+ in2num = eval(in2size(1));
+ if (in1num > 1 | in2num > 1)
+ error(9999, 'String catenation can be performed only on strings of 1 x N size not N x 1 size');
+ //NUT: mi pare che non possano proprio esistere stringe di dimensione Nx1 perche' in
+ //NUT: scilab esiste il tipo string che e' di size 1x1 e sono io a trasformarlo in
+ //NUT: 1xN per cui se uso sempre questa convenzione non sbaglio mai.
+ //NUT: ho provato in scilab a fare la trasposta di una stringa e ottengo sempre 1x1.
+ end
+ end
+ if (isnum(in1size(2)) & isnum(in2size(2)))
+ in1num = eval(in1size(2));
+ in2num = eval(in2size(2));
+ opoutsize(2) = string(in1num+in2num-1);
+ if isnan(opoutsize(2))
+ opoutsize(2) = '__SCI2CNANSIZE';
+ else
+ opoutsize(2) = string(opoutsize(2));
+ end
+ else
+ opoutsize(2) = '('+string(in1size(2))+'+'+string(in2size(2))+'-1)';
+ end
+else
+ error(9999, 'Unexpected type combination for ""+"" operator (type1,type2): ('+in1type+in2type+').');
+end
+
+endfunction
|