diff options
author | imushir | 2015-12-29 12:21:00 +0530 |
---|---|---|
committer | imushir | 2015-12-29 12:21:00 +0530 |
commit | 7382a75d68141d72562f219a839543c9c6fc83aa (patch) | |
tree | 3fee7fd1f9a4557a23c3e11f0e80be9872edc68a /src/c/matrixOperations/magnitude/i16magna.c | |
parent | adee9863483df64816970dc3a4b6ea6e85f40610 (diff) | |
download | scilab2c-7382a75d68141d72562f219a839543c9c6fc83aa.tar.gz scilab2c-7382a75d68141d72562f219a839543c9c6fc83aa.tar.bz2 scilab2c-7382a75d68141d72562f219a839543c9c6fc83aa.zip |
added support for magnitude
Diffstat (limited to 'src/c/matrixOperations/magnitude/i16magna.c')
-rw-r--r-- | src/c/matrixOperations/magnitude/i16magna.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/c/matrixOperations/magnitude/i16magna.c b/src/c/matrixOperations/magnitude/i16magna.c new file mode 100644 index 00000000..884a278e --- /dev/null +++ b/src/c/matrixOperations/magnitude/i16magna.c @@ -0,0 +1,33 @@ +/* SCilab2C FOSSEE IIT BOMBAY */ + + + +#include "matrixMagnitude.h" + +int16 i16magna(int16* in, int rows, int cols){ + int i=0,j=0; + int16 out=0, colSum=0; + + /* Other method : + drowsuma(in,rows,cols,temp); + out=max(temp,cols); + but we have to malloc a array */ + + if ((rows==1)||(cols==1)){ + for(i=0;i<cols*rows;i++){ + out += dmagns(in[i]); + } + } + else{ + for(i=0;i<cols;i++){ + colSum = 0; + for(j=0;j<rows;j++){ + colSum += dmagns(in[i*rows+j]); + } + if (colSum>out) out=colSum; + } + } + return out; +} + + |