summaryrefslogtreecommitdiff
path: root/matrixv.c
diff options
context:
space:
mode:
Diffstat (limited to 'matrixv.c')
-rw-r--r--matrixv.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/matrixv.c b/matrixv.c
new file mode 100644
index 0000000..0b1ea3a
--- /dev/null
+++ b/matrixv.c
@@ -0,0 +1,30 @@
+/* File: matrixv.c
+ Calculate matrix equation b = Ax */
+
+#include <stdio.h>
+
+#define M 3
+#define N 3
+
+int main()
+{
+ double a[M][N] = {{ 3,5,6},
+ { 4,2,1},
+ { 0,7,1}};
+ double v[N] = {2,1,-2};
+ double b[M];
+
+ int i,j;
+
+ for(i = 0;i<N;i++)
+ {
+ b[i] = 0;
+ for(j=0;j<N;j++)
+ {
+ b[i] += a[i][j] * v[j];
+ }
+ }
+ printf("b=%g,%g,%g\n",b[0],b[1],b[2]);
+ return 0;
+
+}