Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:56:03+00:00 2026-06-05T15:56:03+00:00

What is the difference between import numpy as np np.dot(a,b) and import numpy as

  • 0

What is the difference between

import numpy as np
np.dot(a,b)

and

import numpy as np
np.inner(a,b)

all examples I tried returned the same result. Wikipedia has the same article for both?! In the description of inner() it says, that its behavior is different in higher dimensions, but I couldn’t produce any different output. Which one should I use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:56:05+00:00Added an answer on June 5, 2026 at 3:56 pm

    numpy.dot:

    For 2-D arrays it is equivalent to matrix multiplication, and for 1-D arrays to inner product of vectors (without complex conjugation). For N dimensions it is a sum product over the last axis of a and the second-to-last of b:

    numpy.inner:

    Ordinary inner product of vectors for 1-D arrays (without complex conjugation), in higher dimensions a sum product over the last axes.

    (Emphasis mine.)

    As an example, consider this example with 2D arrays:

    >>> a=np.array([[1,2],[3,4]])
    >>> b=np.array([[11,12],[13,14]])
    >>> np.dot(a,b)
    array([[37, 40],
           [85, 92]])
    >>> np.inner(a,b)
    array([[35, 41],
           [81, 95]])
    

    Thus, the one you should use is the one that gives the correct behaviour for your application.


    Performance testing

    (Note that I am testing only the 1D case, since that is the only situation where .dot and .inner give the same result.)

    >>> import timeit
    >>> setup = 'import numpy as np; a=np.random.random(1000); b = np.random.random(1000)'
    
    >>> [timeit.timeit('np.dot(a,b)',setup,number=1000000) for _ in range(3)]
    [2.6920320987701416, 2.676928997039795, 2.633111000061035]
    
    >>> [timeit.timeit('np.inner(a,b)',setup,number=1000000) for _ in range(3)]
    [2.588860034942627, 2.5845699310302734, 2.6556360721588135]
    

    So maybe .inner is faster, but my machine is fairly loaded at the moment, so the timings are not consistent nor are they necessarily very accurate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is difference Difference Between Import All Products/import Product Stock when your importing a
Is there a difference between importing something (e.g. #import JSON.h ) into the header
I'm wondering if there's any difference between the code fragment from urllib import request
What is the difference between: #import foo.h and: #import <foo.h>
somehow I'm doing hard to figure out the difference between #import <Cocoa/Cocoa.h> and #import
What is the difference between using @class & #import ? I had a situation
When used like this: import static com.showboy.Myclass; public class Anotherclass{} what's the difference between
What is the difference between #include and #import in C++?
What's the difference between xsd:include and xsd:import ? When would you use one instead
What is the difference between the following import java.util.Scanner; //Creating the scanner Scanner input=new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.