-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex1.py
More file actions
68 lines (55 loc) · 1.71 KB
/
ex1.py
File metadata and controls
68 lines (55 loc) · 1.71 KB
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
66
67
68
import numpy as np
def dot_product(A, B):
# TODO: Compute the dot product of matrices A and B
result = ...
return result
def matrix_transpose(A):
# TODO: Compute the transpose of matrix A
result = ...
return result
def matrix_determinant(A):
# TODO: Compute the determinant of matrix A
result = ...
return result
def matrix_inverse(A):
# TODO: Compute the inverse of matrix A
result = ...
return result
def matrix_rank(B):
# TODO: Calculate the rank of matrix B
result = ...
return result
def vector_norm(B):
# TODO: Calculate the vector norm of B
result = ...
return result
def multiply_matrix_vector(A, vector):
# TODO: Multiply matrix A by a vector
result = ...
return result
def main():
# TODO: Define matrices A and B with appropriate values
A = ... # Populate with appropriate values
B = ... # Populate with appropriate values
# Perform operations
A_dot_B = dot_product(A, B)
A_transpose = matrix_transpose(A)
A_det = matrix_determinant(A)
A_inv = matrix_inverse(A)
B_rank = matrix_rank(B)
B_norm = vector_norm(B)
# TODO: Define a vector with appropriate values
vector = ... # Populate with appropriate values
A_vector = multiply_matrix_vector(A, vector)
vector_norm_result = vector_norm(A_vector)
# Print results
print("Dot product of A and B:", A_dot_B)
print("Transpose of A:", A_transpose)
print("Determinant of A:", A_det)
print("Inverse of A:", A_inv)
print("Rank of B:", B_rank)
print("Norm of B:", B_norm)
print("A multiplied by vector:", A_vector)
print("Norm of A*vector:", vector_norm_result)
if __name__ == "__main__":
main()