Friday, September 5, 2025
HomeLanguagesAlgebraOnMatrix Module in Python

AlgebraOnMatrix Module in Python

AlgebraOnMatrix module is that library of python which helps you to perform basic matrix algebra such as addition of two matrices, subtraction of two matrices, multiplication of two matrices, transpose of matrix .

Installing Library

This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.

pip install AlgebraOnMatrix

Function of AlgebraOnMatrix

Matrix : It will transform our Two dimensional array into matrix .

Example :




# Importing Matrix function  
# From AlgebraOnMatrix Library  
from AlgebraOnMatrix import Matrix
  
arr =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
  
# Now we will transform our 2d array
# into the matrix and make an object
# of it 
a = Matrix(arr)


Operations on Matrix

  • Addition of Matrices : Here we will add the matrix b with the matrix a where matrix b is given in 2d array .It will be done by function Matrix.addition(a, b) where a is a object which we have created and b is 2d array .
    Example :




    # Importing Matrix function  
    # From AlgebraOnMatrix Library  
    from AlgebraOnMatrix import Matrix
      
    arr =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    # Now we will transform our 2d array 
    # into matrix and make an object of it 
    a = Matrix(arr)
      
    b =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    ans = Matrix.addition(a, b)
    print(ans)

    
    

    Output :

    [[2, 4, 6], [8, 10, 12], [14, 16, 18]]
    
  • Subtraction of Matrices :Here we will subtract the matrix b from the matrix a where matrix b is given in 2d array .It will be done by function Matrix.subtraction(a, b) where a is a object which we have created and b is 2d array .
    Example :




    # Importing Matrix function  
    # From AlgebraOnMatrix Library  
    from AlgebraOnMatrix import Matrix
      
    arr =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    # Now we will transform our 2d array 
    # into matrix and make an object of it 
    a = Matrix(arr)
      
    b =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    ans = Matrix.subtraction(a, b)
    print(ans)

    
    

    Output :

    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    
  • Multiplication of Matrices : Here we will multiply the matrix b with the matrix a where matrix b is given in 2d array .It will be done by function Matrix.multiplication(a, b) where a is a object which we have created and b is 2d array .
    Example :




    # Importing Matrix function  
    # From AlgebraOnMatrix Library  
    from AlgebraOnMatrix import Matrix
      
    arr =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    # Now we will transform our 2d array 
    # into matrix and make an object of it 
    a = Matrix(arr)
      
    b =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    ans = Matrix.multiplication(a, b)
    print(ans)

    
    

    Output :

    [[30, 36, 42], [66, 81, 96], [102, 126, 150]]
    
  • Transpose of Matrix :Here we will transpose the matrix a.It will be done by function Matrix.transpose(a) where a is a object which we have created
    Example :




    # Importing Matrix function  
    # From AlgebraOnMatrix Library  
    from AlgebraOnMatrix import Matrix
      
    arr =[[1, 2, 3], [4, 5, 6, ], [7, 8, 9]]
      
    # Now we will transform our 2d array 
    # into matrix and make an object of it 
      
    a = Matrix(arr)
      
    ans = Matrix.transpose(a)
    print(ans)

    
    

    Output :

    [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
    
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6699 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS