From 7382a75d68141d72562f219a839543c9c6fc83aa Mon Sep 17 00:00:00 2001
From: imushir
Date: Tue, 29 Dec 2015 12:21:00 +0530
Subject: added support for magnitude

---
 src/c/matrixOperations/includes/matrixMagnitude.h | 13 +++++++++
 src/c/matrixOperations/interfaces/int_vmagn.h     | 16 +++++++++++
 src/c/matrixOperations/magnitude/i16magna.c       | 33 +++++++++++++++++++++++
 src/c/matrixOperations/magnitude/i16magns.c       | 13 +++++++++
 src/c/matrixOperations/magnitude/i8magna.c        | 33 +++++++++++++++++++++++
 src/c/matrixOperations/magnitude/i8magns.c        | 13 +++++++++
 src/c/matrixOperations/magnitude/u16magna.c       | 33 +++++++++++++++++++++++
 src/c/matrixOperations/magnitude/u16magns.c       | 13 +++++++++
 src/c/matrixOperations/magnitude/u8magna.c        | 33 +++++++++++++++++++++++
 src/c/matrixOperations/magnitude/u8magns.c        | 13 +++++++++
 10 files changed, 213 insertions(+)
 create mode 100644 src/c/matrixOperations/magnitude/i16magna.c
 create mode 100644 src/c/matrixOperations/magnitude/i16magns.c
 create mode 100644 src/c/matrixOperations/magnitude/i8magna.c
 create mode 100644 src/c/matrixOperations/magnitude/i8magns.c
 create mode 100644 src/c/matrixOperations/magnitude/u16magna.c
 create mode 100644 src/c/matrixOperations/magnitude/u16magns.c
 create mode 100644 src/c/matrixOperations/magnitude/u8magna.c
 create mode 100644 src/c/matrixOperations/magnitude/u8magns.c

(limited to 'src/c/matrixOperations')

diff --git a/src/c/matrixOperations/includes/matrixMagnitude.h b/src/c/matrixOperations/includes/matrixMagnitude.h
index 7b65c6d..a9f4e71 100644
--- a/src/c/matrixOperations/includes/matrixMagnitude.h
+++ b/src/c/matrixOperations/includes/matrixMagnitude.h
@@ -17,6 +17,7 @@
 #include "dynlib_matrixoperations.h"
 #include "floatComplex.h"
 #include "doubleComplex.h"
+#include "types.h"
 
 #ifdef  __cplusplus
 extern "C" {
@@ -34,6 +35,18 @@ EXTERN_MATOPS float cmagna(floatComplex* in, int rows, int cols);
 EXTERN_MATOPS double zmagns(doubleComplex in);
 EXTERN_MATOPS double zmagna(doubleComplex* in, int rows, int cols);
 
+EXTERN_MATOPS uint8 u8magns(uint8 in);
+EXTERN_MATOPS uint8 u8magna(uint8* in, int rows, int cols);
+
+EXTERN_MATOPS uint16 u16magns(uint16 in);
+EXTERN_MATOPS uint16 u16magna(uint16* in, int rows, int cols);
+
+EXTERN_MATOPS int8 i8magns(int8 in);
+EXTERN_MATOPS int8 i8magna(int8* in, int rows, int cols);
+
+EXTERN_MATOPS int16 i16magns(int16 in);
+EXTERN_MATOPS int16 i16magna(int16* in, int rows, int cols);
+
 #ifdef  __cplusplus
 } /* extern "C" */
 #endif
diff --git a/src/c/matrixOperations/interfaces/int_vmagn.h b/src/c/matrixOperations/interfaces/int_vmagn.h
index 8a51755..a8647aa 100644
--- a/src/c/matrixOperations/interfaces/int_vmagn.h
+++ b/src/c/matrixOperations/interfaces/int_vmagn.h
@@ -24,6 +24,14 @@
 
 #define z0vmagnz0(in)			zmagns(in)
 
+#define u80vmagnu80(in)                 u8magns(in)
+
+#define u160vmagnu160(in)               u16magns(in)
+
+#define i80vmagni80(in)                 i8magns(in)
+
+#define i160vmagni160(in)               i16magns(in)
+
 #define s2vmagns2(in,size)		smagna(in, size[0], size[1])
 
 #define d2vmagnd2(in,size)		dmagna(in, size[0], size[1])
@@ -32,4 +40,12 @@
 
 #define z2vmagnz2(in,size)		zmagna(in, size[0], size[1])
 
+#define u82vmagnu82(in,size)            u8magna(in, size[0], size[1])
+
+#define u162vmagnu162(in,size)          u16magna(in, size[0], size[1])
+
+#define i82vmagni82(in,size)            i8magna(in, size[0], size[1])
+
+#define i162vmagni162(in,size)          i16magna(in, size[0], size[1])
+
 #endif /* !__INT_VMAGN_H__ */
diff --git a/src/c/matrixOperations/magnitude/i16magna.c b/src/c/matrixOperations/magnitude/i16magna.c
new file mode 100644
index 0000000..884a278
--- /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;
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/i16magns.c b/src/c/matrixOperations/magnitude/i16magns.c
new file mode 100644
index 0000000..d5deb28
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/i16magns.c
@@ -0,0 +1,13 @@
+
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+#include "abs.h"
+
+int16 i16magns(int16 in){
+	return i16abss(in);
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/i8magna.c b/src/c/matrixOperations/magnitude/i8magna.c
new file mode 100644
index 0000000..1a8519a
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/i8magna.c
@@ -0,0 +1,33 @@
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+
+int8 i8magna(int8* in, int rows, int cols){
+	int i=0,j=0;
+	int8  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;
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/i8magns.c b/src/c/matrixOperations/magnitude/i8magns.c
new file mode 100644
index 0000000..1703505
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/i8magns.c
@@ -0,0 +1,13 @@
+
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+#include "abs.h"
+
+int8 i8magns(int8 in){
+	return i8abss(in);
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/u16magna.c b/src/c/matrixOperations/magnitude/u16magna.c
new file mode 100644
index 0000000..10680c7
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/u16magna.c
@@ -0,0 +1,33 @@
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+
+uint16 u16magna(uint16* in, int rows, int cols){
+	int i=0,j=0;
+	uint16  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;
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/u16magns.c b/src/c/matrixOperations/magnitude/u16magns.c
new file mode 100644
index 0000000..78853ed
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/u16magns.c
@@ -0,0 +1,13 @@
+
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+#include "abs.h"
+
+uint16 u16magns(uint16 in){
+	return u16abss(in);
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/u8magna.c b/src/c/matrixOperations/magnitude/u8magna.c
new file mode 100644
index 0000000..7f5df58
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/u8magna.c
@@ -0,0 +1,33 @@
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+
+uint8 u8magna(uint8* in, int rows, int cols){
+	int i=0,j=0;
+	uint8  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;
+}
+
+
diff --git a/src/c/matrixOperations/magnitude/u8magns.c b/src/c/matrixOperations/magnitude/u8magns.c
new file mode 100644
index 0000000..e6d789c
--- /dev/null
+++ b/src/c/matrixOperations/magnitude/u8magns.c
@@ -0,0 +1,13 @@
+
+/* SCilab2C FOSSEE IIT BOMBAY */
+
+
+
+#include "matrixMagnitude.h"
+#include "abs.h"
+
+uint8 u8magns(uint8 in){
+	return u8abss(in);
+}
+
+
-- 
cgit