-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex_ops.c
65 lines (56 loc) · 1.28 KB
/
ex_ops.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**************************************************
tmalib usage example
this program shows rank of matrix,
scalar multiplication
**************************************************/
#include "../tmatlib.h"
int main(int argc, char *argv[])
{
matrix *m, *m1, *m2;
m=create_matrix(3,3);
/*1 2 -1
3 4 0
-1 0 -2
*/
set_cell(m,0,0,1);
set_cell(m,0,1,2);
set_cell(m,0,2,-1);
set_cell(m,1,0,3);
set_cell(m,1,1,4);
set_cell(m,1,2,0);
set_cell(m,2,0,-1);
set_cell(m,2,1,0);
set_cell(m,2,2,0);
//---------------------
m1 = create_matrix(3,3);
set_cell(m1,0,0,-1);
set_cell(m1,0,1,2);
set_cell(m1,0,2,1);
set_cell(m1,1,0,-3);
set_cell(m1,1,1,4);
set_cell(m1,1,2,0);
set_cell(m1,2,0,-1);
set_cell(m1,2,1,0);
set_cell(m1,2,2,-1);
printf("addition of matrices\n");
display_matrix(m);
printf("===============\n");
display_matrix(m1);
printf("===============\n");
m2= add_matrix(m,m1);
display_matrix(m2);
printf("===============\n");
printf("subtraction of matrices\n");
display_matrix(m);
printf("===============\n");
display_matrix(m1);
printf("===============\n");
m2= subtract_matrix(m,m1);
display_matrix(m2);
printf("===============\n");
delete_matrix(m);
delete_matrix(m1);
delete_matrix(m2);
printf("===============\n");
return(0);
}