-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvecmain.c
51 lines (42 loc) · 1.17 KB
/
vecmain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Library Imports */
#include "veclib.h"
/* Function for taking input. */
void inputVec(vector vecA) {
printf("Enter four space seprated values for the vector in R^4:\n");
for (int i = 0; i < 4; i++)
scanf("%f", &vecA[i]);
}
/* Print vector */
void printVec(vector vecA) {
printf("[ ");
for (int i = 0; i < 4; i++)
printf("%f ", vecA[i]);
printf("]");
printf("\n");
}
/* Main Function */
int main() {
/* Vector Declaration */
vector vecA, vecB, vecC;
/* Input Vector 1 */
inputVec(vecA);
/* Input Vector 2 */
inputVec(vecB);
/* Element product of two vectors */
eleProd(vecA, vecB, vecC);
printf("Element product of two vectors:\n");
printVec(vecC);
/* Addition of two vectors */
add(vecA, vecB, vecC);
printf("Addition of two vectors:\n");
printVec(vecC);
/* Dot product of two vectors */
float dotp = dotprod(vecA, vecB);
printf("Dot product of two vectors: %f\n", dotp);
/* Norm of two vectors*/
float normv = norm(vecA, vecB);
printf("norm of two vectors: %f\n", normv);
/*Angle between two vectors*/
float angle_v = angle(vecA, vecB);
printf("Angle between two vectors: %f\n", angle_v);
}