Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 583 of 2501
447 Views
To get the Trigonometric sines of an array of angles given in degrees, use the numpy.sin() method in Python Numpy. The method returns the sine of each element of the 1st parameter x. This is a scalar if is a scalar. The 1st parameter, x, is an Angle, in radians (2pi means 360 degrees). Here, it is an array of angles. The 2nd and 3rd parameters are optional.The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated ... Read More
183 Views
To return the scalar type of highest precision of the same kind as the input, use the maximum_sctype() method in Python Numpy. The parameter is the input data type. This can be a dtype object or an object that is convertible to a dtype.StepsAt first, import the required library −import numpy as npUsing the maximum_sctype() method in Numpy. Get the scalar type of highest precision −print("Result...", np.maximum_sctype(int)) print("Result...", np.maximum_sctype(np.uint8)) print("Result...", np.maximum_sctype(complex)) print("Result...", np.maximum_sctype(str)) print("Result...", np.maximum_sctype('f4')) print("Result...", np.maximum_sctype('i2')) print("Result...", np.maximum_sctype('i4')) print("Result...", np.maximum_sctype('i8'))Exampleimport numpy as np # To return the scalar type of highest precision of the same kind as the ... Read More
339 Views
To return the string representation of a scalar dtype, use the sctype2char() method in Python Numpy. The 1st argument, if a scalar dtype, the corresponding string character is returned. If an object, sctype2char tries to infer its scalar type and then return the corresponding string character.StepsAt first, import the required library −import numpy as npThe string representation of a scalar type −for i in [np.int32, np.double, np.complex_, np.string_, np.ndarray]: print(np.sctype2char(i))Return the string representation of int types −print("The string representation of int types...") for j in [np.int16, np.int32, np.int64]: print(np.sctype2char(j))Return the string representation of float types −print("The string representation ... Read More
262 Views
To return a description for the given data type code, use the typename() method in Python Numpy. NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.StepsAt first, import the required library −import numpy as npOur array −arr = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', 'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']To return a description for the given data type code, use the typename() method in ... Read More
5K+ Views
To compute the cross product of two vectors, use the numpy.cross() method in Python Numpy. The method returns c, the Vector cross product(s). The 1st parameter is a, the components of the first vector(s). The 2nd parameter is b, the components of the second vector(s). The 3rd parameter is axisa, the axis of a that defines the vector(s). By default, the last axis. The 4th parameter is axisb, the axis of b that defines the vector(s). By default, the last axis. The 5th parameter is axisc, the axis of c containing the cross product vector(s). Ignored if both input vectors have ... Read More
171 Views
To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The parameter, x, y, z are arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter, deg is the list of maximum degrees of the form [x_deg, y_deg, z_deg].StepsAt first, import the required library −numpy as np from numpy.polynomial import hermite as HCreate arrays of point ... Read More
351 Views
To return the Norm of the matrix or vector in Linear Algebra, use the LA.norm() method in Python Numpy. The 1st parameter, x is an input array. If axis is None, x must be 1-D or 2-D, unless ord is None. If both axis and ord are None, the 2-norm of x.ravel will be returned. The 2nd parameter, ord is the order of the norm. The inf means numpy’s inf object. The default is None.The 3rd parameter axis, if an integer, specifies the axis of x along which to compute the vector norms. If axis is a 2-tuple, it specifies ... Read More
1K+ Views
To compute the eigenvalues of a complex Hermitian or real symmetric matrix, use the numpy.eigvalsh() method. The method returns the eigenvalues in ascending order, each repeated according to its multiplicity.The 1st parameter, a is a complex- or real-valued matrix whose eigenvalues are to be computed. The 2nd parameter, UPLO specifies whether the calculation is done with the lower triangular part of a (‘L’, default) or the upper triangular part (‘U’). Irrespective of this value only the real parts of the diagonal will be considered in the computation to preserve the notion of a Hermitian matrix. It therefore follows that the ... Read More
133 Views
To check whether similar data types of different sizes are not subdtypes of each other, use the numpy.issubdtype() method in Python Numpy. The parameters are the dtype or object coercible to one.StepsAt first, import the required library −import numpy as npUsing the issubdtype() method in Nump to check for similar datatypes with different sizes. Checking for float datatype with different sizes −print("Result...", np.issubdtype(np.float32, np.float64)) print("Result...", np.issubdtype(np.float64, np.float32))Checking for int datatype with different sizes −print("Result...", np.issubdtype(np.int16, np.int32)) print("Result...", np.issubdtype(np.int32, np.int16)) print("Result...", np.issubdtype(np.int64, np.int32)) print("Result...", np.issubdtype(np.int32, np.int64))Exampleimport numpy as np # To check whether similar data types of different sizes are ... Read More
1K+ Views
To determine whether the given object represents a scalar data-type, use the numpy.issctype() method. The method returns Boolean result of check whether rep is a scalar dtype. The first parameter is the rep. If rep is an instance of a scalar dtype, True is returned.If not, False is returned.StepsAt first, import the required library −import numpy as npUsing the issctype() method in Numpy −print("Result...", np.issctype(np.int32)) print("Result...", np.issctype(np.int64)) print("Result...", np.issctype(np.dtype('str'))) print("Result...", np.issctype(100)) print("Result...", np.issctype(25.9)) print("Result...", np.issctype(np.float32(22.3)))Exampleimport numpy as np # To determine whether the given object represents a scalar datatype, use the numpy.issctype() method # The method returns Boolean result ... Read More