Skip to content

Commit 95b1991

Browse files
committed
update
1 parent d1593a3 commit 95b1991

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

example.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import os
22
import SparseMatrix as sm
33

4+
# Create main function
45
def main():
56
print("Hello World")
67
print("The current working directory is {0}".format(os.getcwd()))
78

8-
# Sparse Matrix
9+
# Define a sparse matrix
910
m1 = sm.SparseMatrix(3, 3)
1011
m1[0, 0] = 1
1112
m1[0, 1] = 2
@@ -14,6 +15,7 @@ def main():
1415
print("M1 Sparse Matrix:")
1516
print(m1)
1617

18+
# Define another sparse matrix
1719
m2 = sm.SparseMatrix(3, 3)
1820
m2[0, 1] = 5
1921
m2[1, 0] = 6
@@ -22,13 +24,16 @@ def main():
2224
print("M2 Sparse Matrix:")
2325
print(m2)
2426

27+
# Add the two sparse matrices
2528
m3 = m1 + m2
2629
print("Addition of M1 and M2:")
2730
print(m3)
2831

32+
# Multiply the two sparse matrices
2933
m4 = m1 * m2
3034
print("Multiplication of M1 and M2:")
3135
print(m4)
3236

37+
# This is the standard boilerplate that calls the main() function.
3338
if __name__ == "__main__":
3439
main()

0 commit comments

Comments
 (0)