Python | Numpy matrix.copy() (original) (raw)
Last Updated : 12 Apr, 2019
With the help of **Numpy matrix.copy()**
method, we can make a copy of all the data elements that is present in matrix. If we change any data element in the copy, it will not affect the original matrix.
Syntax :
matrix.copy()
Return : Return copy of matrix
Example #1 :
In this example we can see that with the help of matrix.copy()
method we are making the copy of an elements in different matrix.
import
numpy as np
gfg
=
np.matrix(
'[1, 2, 3]'
)
geeks
=
gfg.copy()
print
(geeks)
Example #2 :
import
numpy as np
gfg
=
np.matrix(
'[1, 2, 3; 4, 5, 6]'
)
geeks
=
gfg.copy()
print
(geeks)
Output:
[[1 2 3] [4 5 6]]
Similar Reads
- 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
- Python | Numpy ndarray.__copy__() With the help of Numpy ndarray.__copy__() method, we can make a copy of all the data elements that is present in numpy array. If you change any data element in the copy, it will not affect the original numpy array. Syntax : numpy.__copy__() Return : Copy of all the data elements Example #1 : In this 1 min read
- Numpy matrix.I function | Python With the help ofnumpy.matrix.I() function we can get the multiplicative inverse of the same size as of our given matrix. Syntax : numpy.matrix.I() Return : [matrix object] If self is non-singular, ret is such that ret * self == self * ret == np.matrix(np.eye(self[0, :].size) all return True. Return 1 min read
- numpy.matrix.A() function - Python numpy.matrix.A() function return self as an ndarray object. Syntax : numpy.matrix.A() Parameters : None Return : [ndarray] Return self as an ndarray. Code #1 : # Python program explaining # numpy.matrix.A() function # importing numpy as geek import numpy as geek mat = geek.matrix(geek.arange(9).resh 1 min read
- numpy.copysign() in Python numpy.copysign(arr1, arr2, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None) : This mathematical function helps user to change the sign of arr1 and arr2. Both arr1 or arr2 can be either list/sequence or a scalar value. If sequence, both must have same dimension; otherwise a 2 min read
- Python | Numpy matrix.take() With the help of Numpy matrix.take() method, we can select the elements from a given matrix by passing the parameter as index value of that element. It will return a matrix having one dimension. Remember it will work for one axis at a time. Syntax : matrix.take(index, axis) Return : Return matrix of 1 min read
- numpy.asmatrix() in Python 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 # Python Programming illustrating # numpy.asmatrix import numpy as geek # array-like inp 1 min read
- Python | Numpy matrix.view() With the help of Numpy matrix.view() method, we can find the new view of a the matrix by using the matrix.view() method. Syntax : matrix.view() Return : Return new view for same matrix Example #1 : In this example we can see that by using matrix.view() method we are able to find the new view of the 1 min read
- 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