numpy.dot() in Python Last Updated : 18 Nov, 2022 Comments Improve Suggest changes Like Article Like Report numpy.dot(vector_a, vector_b, out = None) returns the dot product of vectors a and b. It can handle 2D arrays but considers them as matrix and will perform matrix multiplication. For N dimensions it is a sum-product over the last axis of a and the second-to-last of b : dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m]) Parameters vector_a : [array_like] if a is complex its complex conjugate is used for the calculation of the dot product. vector_b : [array_like] if b is complex its complex conjugate is used for the calculation of the dot product. out : [array, optional] output argument must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b). Dot Product of vectors a and b. if vector_a and vector_b are 1D, then scalar is returned Code 1: Python # Python Program illustrating # numpy.dot() method import numpy as geek # Scalars product = geek.dot(5, 4) print("Dot Product of scalar values : ", product) # 1D array vector_a = 2 + 3j vector_b = 4 + 5j product = geek.dot(vector_a, vector_b) print("Dot Product : ", product) Output: Dot Product of scalar values : 20 Dot Product : (-7+22j)How Code1 works ? vector_a = 2 + 3j vector_b = 4 + 5j now dot product = 2(4 + 5j) + 3j(4 +5j) = 8 + 10j + 12j - 15 = -7 + 22j Code 2: Python # Python Program illustrating # numpy.dot() method import numpy as geek # 1D array vector_a = geek.array([[1, 4], [5, 6]]) vector_b = geek.array([[2, 4], [5, 2]]) product = geek.dot(vector_a, vector_b) print("Dot Product : \n", product) product = geek.dot(vector_b, vector_a) print("\nDot Product : \n", product) """ Code 2 : as normal matrix multiplication """ Output: Dot Product : [[22 12] [40 32]] Dot Product : [[22 32] [15 32]] Comment More infoAdvertise with us Next Article numpy.dot() in Python M Mohit Gupta_OMG Improve Article Tags : Python Practice Tags : python Similar Reads numpy.exp2() in Python numpy.exp2(array, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : This mathematical function helps user to calculate 2**x for all x being the array elements. Parameters : array : [array_like]Input array or object whose elements, we need to test. out : [ndarray, optional 2 min read NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read numpy.vdot() in Python Prerequisite - numpy.dot() in Python numpy.vdot(vector_a, vector_b) returns the dot product of vectors a and b. If first argument is complex the complex conjugate of the first argument(this is where vdot() differs working of dot() method) is used for the calculation of the dot product. It can handle 2 min read numpy.round_() in Python The round_() function in NumPy rounds the elements of an array to a specified number of decimal places. This function is extremely useful when working with floating-point numbers and when precision is important in scientific computing or data analysis.Syntax: numpy.round_(arr, decimals=0, out=None)P 3 min read numpy.fromiter() function â Python NumPy's fromiter() function is a handy tool for creating a NumPy array from an iterable object. This iterable can be any Python object that provides elements one at a time. The function is especially useful when you need to convert data from a custom data source, like a file or generator, into a Num 2 min read Python | Numpy ndarray.__imod__() With the help of Numpy ndarray.__imod__(), every element in an array is operated on binary operator i.e mod(%). Remember we can use any type of values in an array and value for mod is applied as the parameter in ndarray.__imod__(). Syntax: ndarray.__imod__($self, value, /) Return: self%=value Exampl 1 min read numpy.fromstring() function â Python numpy.fromstring() function create a new one-dimensional array initialized from text data in a string. Syntax : numpy.fromstring(string, dtype = float, count = -1, sep = ' ') Parameters : string : [str] A string that contained the data. dtype : [data-type, optional] Data-type of the array. Default d 1 min read float() in Python Python float() function is used to return a floating-point number from a number or a string representation of a numeric value. Example: Here is a simple example of the Python float() function which takes an integer as the parameter and returns its float value. Python3 # convert integer value to floa 3 min read numpy.loadtxt() in Python numpy.loadtxt() function is used to load data from a text file and return it as a NumPy array. It is ideal for reading large data sets that are stored in simple text formats, such as CSV files or space-separated files.Example: Basic Usage of numpy.loadtxt() for Reading a Simple Space-Separated FileT 4 min read numpy.array_repr() in Python numpy.array_repr()function is used to convert an array to a string. Syntax : numpy.array_repr(arr, max_line_width=None, precision=None, suppress_small=None) Parameters : arr : [array_like] Input array. max_line_width : [int, optional] The maximum number of columns the string should span. Newline cha 2 min read Like