Open In App

numpy.inner() in python

Last Updated : 28 Nov, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
numpy.inner(arr1, arr2): Computes the inner product of two arrays.
Parameters : 
arr1, arr2 : array to be evaluated.

Return:  Inner product of the two arrays.
Code #1 : Python3 1==
# Python Program illustrating 
# numpy.inner() method 

import numpy as geek 

# Scalars 
product = geek.inner(5, 4) 
print("inner Product of scalar values : ", product) 

# 1D array 
vector_a = 2 + 3j
vector_b = 4 + 5j

product = geek.inner(vector_a, vector_b) 
print("inner Product : ", product) 
Output:
inner Product of scalar values :  20
inner Product :  (-7+22j)
  Code #2 : As normal matrix multiplication Python3 1==
# Python Program illustrating 
# numpy.inner() 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.inner(vector_a, vector_b) 
print("inner Product : \n", product) 

product = geek.inner(vector_b, vector_a) 
print("\ninner Product : \n", product) 
Output:
inner Product : 
 [[18 13]
 [34 37]]

inner Product : 
 [[18 34]
 [13 37]]

Next Article
Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy