2025-11-04 17:02:58 +01:00
2025-11-04 17:02:58 +01:00
2025-11-04 17:02:58 +01:00
2025-11-04 17:02:58 +01:00
2025-11-04 17:02:58 +01:00
2025-11-01 18:02:35 +01:00

MatrixMania

This Package contains a few fundamental function which can be used for matrices.

Functions:

  • matmul function
  • transpose function
  • rot_2D function

matmul function:

This function calculates the matrix multiplication with 2 matrices. It also checks if the matrices are compatible for multiplication.

Example:

matrix_a =  [[3, 4, -1, 4],
             [-2, 2, 5, 1]]
             
matrix_b =  [[1, 3, -2],
             [2, 5, 1],
             [-1, 4, -4],
             [2, 3, 6]]
             
matrix_c = matmul(matrix_a, matrix_b)
print("matrix c:")
print(tabulate(matrix_c))

Result:

matrix c:
--  --  --
20  37  26
-1  27  -8
--  --  --

transpose function:

This function transposes a matrix.

Example:

matrix = [[1, 2, 3],
          [4, 5, 6]]
          
new_matrix = transpose(matrix)
print("transposed matrix:")
print(tabulate(new_matrix))

Result:

transposed matrix:
-  -
1  4
2  5
3  6
-  -

rot_2D function:

This function returns the rotation matrix for a given angle.

Example:

theta = math.pi / 2
R = rot_2D(theta)

print("rotation matrix for 90°:")
print(tabulate(R))

Result

rotation matrix for 90°:
-----------  ------------
6.12323e-17  -1
1             6.12323e-17
-----------  ------------
Description
Prog3A Matrizenlibrary in Python
Readme 41 KiB
Languages
Python 100%