summaryrefslogtreecommitdiff
path: root/2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci
diff options
context:
space:
mode:
authoryash11122017-07-07 21:20:49 +0530
committeryash11122017-07-07 21:20:49 +0530
commit9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 (patch)
treef50d6e06d8fe6bc1a9053ef10d4b4d857800ab51 /2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci
downloadScilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.gz
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.bz2
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.zip
sci2c arduino updated
Diffstat (limited to '2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci')
-rw-r--r--2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci103
1 files changed, 103 insertions, 0 deletions
diff --git a/2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci b/2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci
new file mode 100644
index 00000000..1dddfb77
--- /dev/null
+++ b/2.3-1/macros/FunctionAnnotation/FA_SZ_ROW_DIAG_INS_EXT.sci
@@ -0,0 +1,103 @@
+function outsize = FA_SZ_ROW_DIAG_INS_EXT(insize,val)
+//function outsize = FA_SZ_ROW_DIAG_INS_EXT(insize,val)
+// -----------------------------------------------------------------
+// Get row size of output for diag(insert) function
+//
+// Input data:
+// insize: string specifying the size of first input argument.
+// val: string specifying the value of second input argument.
+//
+// Output data:
+// outsize: string containing the size for output argument.
+//
+// Copyright (C) 2017 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Mushir
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+ // val ==> Position value ...,-2,-1,0,1,2....
+ //insize ==> insize(1) will give ROW size and insize(2) will give COLUMN size.
+ insize = string(insize);
+ row_num = eval(insize(1));
+ col_num = eval(insize(2));
+ val_num = eval(val);
+ ///////////////////// FOR INSERT CONDITION //////////////////////////////
+
+
+
+ if(row_num == 1)
+ if(val_num == 0) then // For 0th position
+ outsize = string(col_num);// ROW size is equal to COLUMN size
+
+ else // For ....-2,-1,1,2... positions
+ outsize = string(col_num+abs(val_num));
+ //ROW is equal to COLUMN SIZE + position value (i.e for 1*4 matrix and insert position 1 then ROW size is 4+1 = 5 )
+
+ end
+ elseif(col_num == 1) // if Column size is one
+ if(val_num == 0) then // For Oth position
+ outsize = string(row_num); // ROW size is equal to ROW size
+
+ else // ....-2,-1,1,2... positions.
+ outsize = string(row_num + abs(val_num));
+ //ROW is equal to ROW SIZE + position value (i.e for 4*1 matrix and insert position 1 then ROW size is 4+1 = 5 )
+
+ end
+
+ /////////////////////////////////////////////////////////////////////////////
+
+
+ //////////////////////////// FOR EXTRACT CONDITION /////////////////////////
+
+ elseif(row_num == col_num) // For no. of rows equal to no. of column (R == C)
+ if(val_num == 0) then //For 0th position
+ outsize = string(col_num); // No. of row is equal to column size
+ else //For ....-2,-1,1,2... Positions
+ outsize = string(col_num-abs(val_num)); //row value is equal to subtraction of column size and absolute value of position (i.e +ve and -ve both position values)
+ end
+ elseif(row_num > col_num) // for no. of rows greater than no. of column (R > C)
+ if(val_num == 0) then // if 0th position
+ outsize = string(col_num); // No. of row is equal to column size
+ elseif(val_num > 0) then // For +ve positions i.e 1,2,3.....
+ outsize = string(col_num-abs(val_num)); // No. of row is equal to subtraction of column size and absolute value of +ve postion
+
+ elseif(val_num < 0 ) then // For -ve positions i.e -1,-2,-3
+ temp_outsize1 = row_num-abs(val_num); //In this row values are varying for 4*3 matrix there is no repetition of same row values,for 5*3 matrix there is (5-3 = 2) two same row size(i.e 3 and 3) for -1,-2 position and for 6*3 matrix there is (6-3 = 3) three same row size(i.e 3 ,3,3) for -1,-2,-3 position
+ if(temp_outsize1 >= col_num) // if temp_outsize1 is greater than equal to column size then
+ outsize = string(col_num); // row size is equal to column
+ else
+ outsize = string(row_num-abs(val_num)); // else row size is substractio of row and abosulte value of position(i.e -1,-2,-3)
+ end
+ end
+ elseif(row_num < col_num) // for no. of rows less than no. of column size
+ if(val_num == 0) then // if 0th position
+ outsize = string(row_num); // No. of row is equal to row size
+ elseif(val_num > 0) then // for +ve positions i.e 1,2 3.....
+ temp_outsize2 = col_num-abs(val_num);// In this column values are varying for 3*4 matrix there is no repetition of same row values,for 3*5 matrix there is (5-3 =2) two same row size (i.e 3, 3 ) for 1 ,2 position and for 3*6 matrix there is (6-3 = 3) three row size (i.e 3 ,3 ,3) for 1,2 3 position
+ if(temp_outsize2 >= row_num) // if temp_outsize2 is greater than equal to row size then
+ outsize = string(row_num); // row size is equal to row size
+ else
+ outsize = string(col_num-abs(val_num)); // else row size substractio of column and absolute value
+ end
+ elseif(val_num < 0) then // for -ve positions i.e -1,-2,-3 .. positions
+ outsize = string(row_num-abs(val_num)); // row size is substraction of row size and absolute value of position values(-1,-2,-3)
+ end
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ end
+
+endfunction