summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/matrixOperations/cross/dcrossa.c
diff options
context:
space:
mode:
authorAbhinav Dronamraju2017-07-11 20:21:06 +0530
committerAbhinav Dronamraju2017-07-11 20:21:06 +0530
commit8595e91e1c157f471cc359a7dd927b1e18561b2d (patch)
tree58ad8130d10ce5d2e1741f56b833b6e6048b42a8 /2.3-1/src/c/matrixOperations/cross/dcrossa.c
parent1c92658b51e2d22e2146d1747f9bc804f079e252 (diff)
parent54646786e8d89820b4c4bd4f7606fe5fdf818687 (diff)
downloadScilab2C-8595e91e1c157f471cc359a7dd927b1e18561b2d.tar.gz
Scilab2C-8595e91e1c157f471cc359a7dd927b1e18561b2d.tar.bz2
Scilab2C-8595e91e1c157f471cc359a7dd927b1e18561b2d.zip
Ankit's changes
Diffstat (limited to '2.3-1/src/c/matrixOperations/cross/dcrossa.c')
-rw-r--r--2.3-1/src/c/matrixOperations/cross/dcrossa.c33
1 files changed, 33 insertions, 0 deletions
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)];
+
+ }
+ }
+
+ }
+}
+