This is a basic implementation of matrix and vectors library to make it understandable in the context of computational matrices
1. Gabry is the required library the one that should be used to use others (so it is the imported one)
- to download the gabry library just clone this repository (Inshaa Allah in the future I will make a pip install of this)
git clone https://github.com/serrysibaee/gabry.git
Then you can use the gabry library by importing it in the code
from gabry import *
Then now let's make some matrix to do basic operations on it (Small note: I named the functions using Arabizi typing and I regret it now but too lazy to change it so sorry -smily face- )
from gabry import *
list1 = [[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]]
# يصنع مصفوفة
masf = i9n3_masfofatan(list1)
print(masf,masf.shape)
Here we can do add, sub and dot product operation for two matrices (note that in this implementation I did not add the row wise multiply maybe in the future)
from gabry import *
list1 = [[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]]
list2 = [[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]]
# # يصنع مصفوفة
masf1 = i9n3_masfofatan(list1)
masf2 = i9n3_masfofatan(list2)
print(masf1 + masf2)
print(masf1 - masf2)
print(masf1 * masf2.man8ool()) # this is dot product
NOTE: that sum() is similar to numpy way to do the axis summation on
from gabry import *
list1 = [[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]]
masf1 = i9n3_masfofatan(list1)
# print the shape
print(masf1.shape)
# transpose
print(masf1.man8ool())
# summation (0 is for rows and 1 is for columns) but it will always return them as a vector
print(masf1.sum(axis=0))
print(masf1.sum(axis=1))
the library khap6_3shwaa is a random number generator that has been added to gabry
rand_mat_int = random_matrix_int(3,3)
print(rand_mat)
rand_mat = random_matrix(3,3)
print(rand_mat)
- inverse function
- element wise product (done see in gabry elementwise_product() function)
- Building pip library for gabry (It's more fancy way but you can use the library by just clone the repository)
- vectors cross product and norm (NOTE: you can do them by your self as a practice for reminding you see this link link)
- complete the random library khap6_3shwaa (for refrence see the book numerical recipes chapter 7 (page 340)) {DONE}