numpy.asmatrix() in Python (original) (raw)
Last Updated : 29 Nov, 2018
numpy.asmatrix(data, dtype = None) Returns a matrix by interpreting the input as a matrix.
Parameters :
data : array-like input data dtype : Data type of returned array
Returns :
Interprets the input as a matrix
import
numpy as geek
b
=
geek.matrix([[
5
,
6
,
7
], [
4
,
6
]])
print
(
"Via array-like input : \n"
, b,
"\n"
)
c
=
geek.asmatrix(b)
b[
0
,
1
]
=
10
print
(
"c matrix : \n"
, c)
Output :
Via array-like input : [[[5, 6, 7] [4, 6]]]
c matrix : [[[5, 6, 7] 10]]
Note : These NumPy-Python programs won’t run on onlineID, so run them on your systems to explore them
.
Similar Reads
- Python | Numpy numpy.matrix.A() With the help of Numpy numpy.matrix.A() method, we can get the same matrix as self. It means through this method we can get the identical matrix. Syntax : numpy.matrix.A() Return : Return self matrix Example #1 : In this example we can see that with the help of matrix.A() method, we are able to get 1 min read
- numpy.bmat() in Python numpy.bmat(obj, l_dict = None, g_dict = None) : Return specialised 2-D matrix from nested objects that can be string-like or array-like. Parameters : object : array-like or string l_dict : (dict, optional) replaces local operands, A dictionary that replaces local operands in current frame g_dict : ( 2 min read
- numpy.asarray() in Python numpy.asarray()function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples of lists and arrays. Syntax : numpy.asarray(arr, dtype=None, order=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a 2 min read
- numpy.matrix() in Python This class returns a matrix from a string of data or array-like object. Matrix obtained is a specialised 2D array. Syntax : numpy.matrix(data, dtype = None) : Parameters : data : data needs to be array-like or string dtype : Data type of returned array. Returns : data interpreted as a matrix # Pytho 1 min read
- numpy.asfarray() in Python numpy.asfarray()function is used when we want to convert input to a float type array. Input includes scalar, lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Syntax : numpy.asfarray(arr, dtype=type 'numpy.float64') Parameters : arr : [array_like] Input data, in any for 2 min read
- Python | Numpy numpy.matrix.all() With the help of Numpy numpy.matrix.all() method, we are able to compare each and every element of one matrix with another or we can provide the axis on the we want to apply comparison. Syntax : numpy.matrix.all() Return : Return true if found match else false Example #1 : In this example we can see 1 min read
- Python | Numpy numpy.matrix.any() With the help of Numpy numpy.matrix.any() method, we are able to compare each and every element of one matrix with another or we can provide the axis on the we want to apply comparison if any of the element matches it return true. Syntax : numpy.matrix.any() Return : Return true if any match found e 1 min read
- Python | Numpy numpy.matrix.T() With the help of Numpy numpy.matrix.T() method, we can make a Transpose of any matrix either having dimension one or more than more. Syntax : numpy.matrix.T() Return : Return transpose of every matrix Example #1 : In this example we can see that with the help of matrix.T() method, we are able to tra 1 min read
- Python | Numpy numpy.matrix.H() With the help of Numpy numpy.matrix.H() method, we can make a conjugate Transpose of any complex matrix either having dimension one or more than more. Syntax : numpy.matrix.H() Return : Return conjugate transpose of every complex matrix Example #1 : In this example we can see that with the help of m 1 min read
- Python | Numpy matrix.sum() With the help of matrix.sum() method, we are able to find the sum of values in a matrix by using the same method. Syntax : matrix.sum() Return : Return sum of values in a matrix Example #1 : In this example we are able to find the sum of values in a matrix by using matrix.sum() method. # import the 1 min read