Python | Constant Matrix

Python | Constant Matrix: In this tutorial, we are going to learn about the constant matrix and its Python implementation.
Submitted by Anuj Singh, on July 09, 2020

In this article, we are going to create a constant matrix, where all the elements of the matrix have the same constant value. This can be done by online inbuilt function numpy.full(). This NumPy library function returns a constant matrix.

Python code to create constant matrix

# Linear Algebra Learning Sequence
# Constant Matrix

import numpy as np

M = np.full((5,6), 44)

print('A constant matrix with all entries as 44 :\n', M)

Output:

A constant matrix with all entries as 44 :
 [[44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]
 [44 44 44 44 44 44]]
 


Comments and Discussions!

Load comments ↻





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