- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.inner()
This function returns the inner product of vectors for 1-D arrays. For higher dimensions, it returns the sum product over the last axes.
Example
import numpy as np print np.inner(np.array([1,2,3]),np.array([0,1,0])) # Equates to 1*0+2*1+3*0
It will produce the following output −
2
Example
# Multi-dimensional array example import numpy as np a = np.array([[1,2], [3,4]]) print 'Array a:' print a b = np.array([[11, 12], [13, 14]]) print 'Array b:' print b print 'Inner product:' print np.inner(a,b)
It will produce the following output −
Array a: [[1 2] [3 4]] Array b: [[11 12] [13 14]] Inner product: [[35 41] [81 95]]
In the above case, the inner product is calculated as −
1*11+2*12, 1*13+2*14 3*11+4*12, 3*13+4*14
numpy_linear_algebra.htm
Advertisements