summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/matrixOperations/cross
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/matrixOperations/cross')
-rw-r--r--2.3-1/src/c/matrixOperations/cross/ccrossa.c37
-rw-r--r--2.3-1/src/c/matrixOperations/cross/dcrossa.c33
-rw-r--r--2.3-1/src/c/matrixOperations/cross/i16crossa.c34
-rw-r--r--2.3-1/src/c/matrixOperations/cross/i8crossa.c34
-rw-r--r--2.3-1/src/c/matrixOperations/cross/scrossa.c33
-rw-r--r--2.3-1/src/c/matrixOperations/cross/u16crossa.c34
-rw-r--r--2.3-1/src/c/matrixOperations/cross/u8crossa.c34
-rw-r--r--2.3-1/src/c/matrixOperations/cross/zcrossa.c37
8 files changed, 276 insertions, 0 deletions
diff --git a/2.3-1/src/c/matrixOperations/cross/ccrossa.c b/2.3-1/src/c/matrixOperations/cross/ccrossa.c
new file mode 100644
index 00000000..5f74bb36
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/ccrossa.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "floatComplex.h"
+#include "stdlib.h"
+#include "string.h"
+#include "cat.h"
+
+void ccrossa (floatComplex* inp1, int size1_r, int size1_c, floatComplex* inp2, int size2_r, int size2_c ,floatComplex* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/dcrossa.c b/2.3-1/src/c/matrixOperations/cross/dcrossa.c
new file mode 100644
index 00000000..203ec24b
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/dcrossa.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+
+void dcrossa (double* inp1, int size1_r, int size1_c, double* inp2, int size2_r, int size2_c ,double* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/i16crossa.c b/2.3-1/src/c/matrixOperations/cross/i16crossa.c
new file mode 100644
index 00000000..91cdb7f0
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/i16crossa.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "int16.h"
+
+void i16crossa (int16* inp1, int size1_r, int size1_c, int16* inp2, int size2_r, int size2_c ,int16* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/i8crossa.c b/2.3-1/src/c/matrixOperations/cross/i8crossa.c
new file mode 100644
index 00000000..adfbd534
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/i8crossa.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "int8.h"
+
+void i8crossa (int8* inp1, int size1_r, int size1_c, int8* inp2, int size2_r, int size2_c ,int8* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/scrossa.c b/2.3-1/src/c/matrixOperations/cross/scrossa.c
new file mode 100644
index 00000000..414b85a4
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/scrossa.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+
+void scrossa (float* inp1, int size1_r, int size1_c, float* inp2, int size2_r, int size2_c ,float* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/u16crossa.c b/2.3-1/src/c/matrixOperations/cross/u16crossa.c
new file mode 100644
index 00000000..e0a32bcc
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/u16crossa.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "uint16.h"
+
+void u16crossa (uint16* inp1, int size1_r, int size1_c, uint16* inp2, int size2_r, int size2_c ,uint16* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/u8crossa.c b/2.3-1/src/c/matrixOperations/cross/u8crossa.c
new file mode 100644
index 00000000..7a8b857f
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/u8crossa.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "uint8.h"
+
+void u8crossa (uint8* inp1, int size1_r, int size1_c, uint8* inp2, int size2_r, int size2_c ,uint8* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+
diff --git a/2.3-1/src/c/matrixOperations/cross/zcrossa.c b/2.3-1/src/c/matrixOperations/cross/zcrossa.c
new file mode 100644
index 00000000..85a19607
--- /dev/null
+++ b/2.3-1/src/c/matrixOperations/cross/zcrossa.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cross.h>
+#include "doubleComplex.h"
+#include "stdlib.h"
+#include "string.h"
+#include "cat.h"
+
+void zcrossa (doubleComplex* inp1, int size1_r, int size1_c, doubleComplex* inp2, int size2_r, int size2_c ,doubleComplex* oup)
+{
+ int i,j;
+
+ if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix
+ {
+ oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1];
+ oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2];
+ oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0];
+ printf("%lf ", oup[0]);
+ printf("%lf ", oup[1]);
+ printf("%lf \n", oup[2]);
+ }
+ else // Calculating the cross product for a 3XN Matrix
+ {
+ for(i = 0; i < size1_r; i++)
+ {
+ for(j = 0; j < size1_c; j = j+3)
+ {
+ oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)];
+ oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)];
+ oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)];
+
+ }
+ }
+
+ }
+}
+