summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/matrixOperations/cross/i16crossa.c
diff options
context:
space:
mode:
authorBrijeshcr2017-07-11 20:08:54 +0530
committerBrijeshcr2017-07-11 20:08:54 +0530
commit54646786e8d89820b4c4bd4f7606fe5fdf818687 (patch)
tree02b4e315f9369aee1a4cadac9375ee18b157a3a9 /2.3-1/src/c/matrixOperations/cross/i16crossa.c
parent5774ee3f40eed7ba48f427db3e4bc35fcbfac1c4 (diff)
downloadScilab2C-54646786e8d89820b4c4bd4f7606fe5fdf818687.tar.gz
Scilab2C-54646786e8d89820b4c4bd4f7606fe5fdf818687.tar.bz2
Scilab2C-54646786e8d89820b4c4bd4f7606fe5fdf818687.zip
Cross Added
Diffstat (limited to '2.3-1/src/c/matrixOperations/cross/i16crossa.c')
-rw-r--r--2.3-1/src/c/matrixOperations/cross/i16crossa.c34
1 files changed, 34 insertions, 0 deletions
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)];
+
+ }
+ }
+
+ }
+}
+