Identity Matrix Transpose Property | Linear Algebra using Python

Linear Algebra using Python | Identity Matrix Transpose Property: Here, we are going to learn about the identity matrix transpose property and its implementation in Python.
Submitted by Anuj Singh, on May 26, 2020

Prerequisites:

In linear algebra, the identity matrix, of size n is the n × n square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by I. Also known as the unit matrix because its determinant value is 1 irrespective of size. This is the key feature of an Identity matrix and it plays an important role in Linear Algebra.

The identity matrix has the property that, transpose of identity matrix gives identity matrix (IT = I).

Method 1:

Syntax:
    M = numpy.eye(n)
    transpose_M = M.T 
Parameter: 
    dimension of the matrix n
Return: 
    MT

Method 2:

Syntax:
    M = numpy.eye(n)
    transpose_M = numpy.transpose(M)
Input Parameter: 
    dimension of the matrix n
Return: 
    MT

Python code for identity matrix transpose property

# Linear Algebra Learning Sequence
# Transpose using different Method

import numpy as np

I = np.eye(4)
print("---Matrix I---\n", I)

# Transposing the Matrix g
print('\n\nTranspose as I.T----\n', I.T)
print('\n\nTranspose as np.tanspose(I)----\n', np.transpose(I))

if I.T.all() == I.all():
    print("Transpose is eqaul to I")

Output:

---Matrix I---
 [[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]


Transpose as I.T----
 [[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]


Transpose as np.tanspose(I)----
 [[1. 0. 0. 0.]
 [0. 1. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 1.]]
Transpose is eqaul to I


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.