Scalar Multiplication of Matrix | Linear Algebra using Python

Linear Algebra using Python | Scalar Multiplication of Matrix: Here, we are going to learn how to find scalar multiplication of matrix in Python?
Submitted by Anuj Singh, on May 20, 2020

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. Matrix is the key to linear algebra. All the linear algebra revolves around matrices. One of the major needed steps in linear algebra is scalar multiplication. When a matrix is defined using NumPy, it's easy to code scalar multiplication.

Python code for Scalar Multiplication of Matrix

# Linear Algebra Learning Sequence
# Scalar Multiplication of a Matrix

import numpy as np

# Use of np.array() to define a matrix
V = np.array([[1,2,3],[2,3,5],[3,6,8]])

# Scalar Multiplication of matrix with c =2
print("The Matrix A =\n",V)
print("The MAtrix 2xA =\n",2*V)

Output:

The Matrix A =
 [[1 2 3]
 [2 3 5]
 [3 6 8]]
The MAtrix 2xA =
 [[ 2  4  6]
 [ 4  6 10]
 [ 6 12 16]]


Comments and Discussions!

Load comments ↻





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