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

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.