diff options
author | jofret | 2010-06-21 07:19:27 +0000 |
---|---|---|
committer | jofret | 2010-06-21 07:19:27 +0000 |
commit | 6d7c1d87455053bb11082198f747eb9445f59675 (patch) | |
tree | 78dd24dbab90140633ee33850990d6abf6d9e9ea /macros/CCodeGeneration/GetSymbolDimension.sci | |
parent | 7a35f83fa20927d71dd1b1f792dea35c7e9d5f47 (diff) | |
download | scilab2c-6d7c1d87455053bb11082198f747eb9445f59675.tar.gz scilab2c-6d7c1d87455053bb11082198f747eb9445f59675.tar.bz2 scilab2c-6d7c1d87455053bb11082198f747eb9445f59675.zip |
Hypermatrix management : detect variables with more than 2 dimensions
Diffstat (limited to 'macros/CCodeGeneration/GetSymbolDimension.sci')
-rw-r--r-- | macros/CCodeGeneration/GetSymbolDimension.sci | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/macros/CCodeGeneration/GetSymbolDimension.sci b/macros/CCodeGeneration/GetSymbolDimension.sci index 4fe3cc8d..bb6045a2 100644 --- a/macros/CCodeGeneration/GetSymbolDimension.sci +++ b/macros/CCodeGeneration/GetSymbolDimension.sci @@ -11,7 +11,7 @@ function symboldimension = GetSymbolDimension(Field_Size) // // Output data: // symboldimension: number specifying the dimension of the symbol. -// 0 = scalar; 1 = column or row; 2 = matrix. +// 0 = scalar; 1 = column or row; 2 = matrix; 3 = hypermatrix. // // #RNU_RES_E // Status: @@ -25,46 +25,44 @@ function symboldimension = GetSymbolDimension(Field_Size) // ------------------------------ // --- Check input arguments. --- // ------------------------------ -SCI2CNInArgCheck(argn(2),1,1); - + SCI2CNInArgCheck(argn(2),1,1); + // Size is expressed as an array of two strings. -Nelem = max(size(Field_Size)); -if (Nelem < 2) - SCI2Cerror('The size of a symbol cannot be expressed with one or zero numbers.'); -end -for countersize = 1:Nelem - // #RNU_RES_B - // Field_Type = 1; if Size is Symbol or a number > 1 - // Field_Type = 0; if Size is a number == 1 - // error if Size is 0. - // A symbol is scalar if the sum of the Field_Type elements is zero. - // A symbol is column or row if the sum of the Field_Type elements is one. - // A symbol is a matrix if the sum of the Field_Type elements is > 1. - // #RNU_RES_E - if (isnum(Field_Size(countersize))) + Nelem = max(size(Field_Size)); + if (Nelem < 2) + SCI2Cerror('The size of a symbol cannot be expressed with one or zero numbers.'); + end + + for countersize = 1:Nelem +// #RNU_RES_B +// Field_Type = 1; if Size is Symbol or a number > 1 +// Field_Type = 0; if Size is a number == 1 +// error if Size is 0. +// A symbol is scalar if the sum of the Field_Type elements is zero. +// A symbol is column or row if the sum of the Field_Type elements is one. +// A symbol is a matrix if the sum of the Field_Type elements is > 1. +// #RNU_RES_E + if (isnum(Field_Size(countersize))) tmpnum = eval(Field_Size(countersize)); if (tmpnum == 0) - SCI2Cerror('Found a symbol that has zeros elements. 0xN or Nx0 matrices are not allowed.'); + SCI2Cerror('Found a symbol that has zeros elements. 0xN or Nx0 matrices are not allowed.'); elseif (tmpnum == 1) - Field_Type(countersize) = 0; + Field_Type(countersize) = 0; else - Field_Type(countersize) = 1; + Field_Type(countersize) = 1; end - else - Field_Type(countersize) = 1; - end -end - -Sum_Field_Type = sum(Field_Type); -if (Sum_Field_Type == 0) - symboldimension = 0; -elseif (Sum_Field_Type == 1) - // #RNU_RES_B - // symboldimension = 1; //NUT for this release there will not be difference between vectors and matrices. - // #RNU_RES_E - symboldimension = 2; -else - symboldimension = 2; -end + else + Field_Type(countersize) = 1; + end + end + // The symbol global dimension is the count of all >1 dimension. + symboldimension = sum(Field_Type); + + if (symboldimension == 1) +// #RNU_RES_B +// symboldimension = 1; //NUT for this release there will not be difference between vectors and matrices. +// #RNU_RES_E + symboldimension = 2; + end endfunction |