Row numbers in a Matrix | Linear Algebra using Python

Linear Algebra using Python | Row numbers in a Matrix: Here, we are going to learn how to get row numbers in a 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. For many operations with a Matrix, we need to know about the number of rows in a matrix.

In python, we can find it using two methods. One of the simplest methods we are going to see is just using the len(M) function. Python considers the length of a Matrix as the number of rows in it.

Rows also have a different interpretation as row space. So whenever we are asked to find the number of dimensions in the row space of a matrix, we can just put the inbuilt function len(M) in our code to answer such questions.

The following code shows how to call a whole row of a matrix.

Python code for Row numbers in a Matrix

# Linear Algebra Learning Sequence
# Row numbers in 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],[323,623,823]])
print("--The Matrix-- \n",V)

#number of rows
num = len(V)

print("Number of rows in the Given Matrix : ", num)

Output:

--The Matrix-- 
 [[  1   2   3]
 [  2   3   5]
 [  3   6   8]
 [323 623 823]]
Number of rows in the Given Matrix :  4






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.