File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import SparseMatrix as sm
3
3
4
+ # Create main function
4
5
def main ():
5
6
print ("Hello World" )
6
7
print ("The current working directory is {0}" .format (os .getcwd ()))
7
8
8
- # Sparse Matrix
9
+ # Define a sparse matrix
9
10
m1 = sm .SparseMatrix (3 , 3 )
10
11
m1 [0 , 0 ] = 1
11
12
m1 [0 , 1 ] = 2
@@ -14,6 +15,7 @@ def main():
14
15
print ("M1 Sparse Matrix:" )
15
16
print (m1 )
16
17
18
+ # Define another sparse matrix
17
19
m2 = sm .SparseMatrix (3 , 3 )
18
20
m2 [0 , 1 ] = 5
19
21
m2 [1 , 0 ] = 6
@@ -22,13 +24,16 @@ def main():
22
24
print ("M2 Sparse Matrix:" )
23
25
print (m2 )
24
26
27
+ # Add the two sparse matrices
25
28
m3 = m1 + m2
26
29
print ("Addition of M1 and M2:" )
27
30
print (m3 )
28
31
32
+ # Multiply the two sparse matrices
29
33
m4 = m1 * m2
30
34
print ("Multiplication of M1 and M2:" )
31
35
print (m4 )
32
36
37
+ # This is the standard boilerplate that calls the main() function.
33
38
if __name__ == "__main__" :
34
39
main ()
You can’t perform that action at this time.
0 commit comments