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 7079755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:42:39+00:00 2026-05-28T06:42:39+00:00

As stated in the docs for numpy.all() : numpy.all() tests whether all array elements

  • 0

As stated in the docs for numpy.all():

numpy.all() tests whether all array elements along a given axis evaluate to True.

Is there a function, that does the opposite: Check whether all array elements along a given axis (I need the diagonal) evaluates to False.

What I need in particular is to check if the diagonal of a 2-dimensional matrix is zero every where.

  • 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-05-28T06:42:40+00:00Added an answer on May 28, 2026 at 6:42 am

    First, to extract the diagonal, you can use mymatrix.diagonal().

    There are quite a few ways to do what you want.

    To test whether it is zero everywhere you can do numpy.all(mymatrix.diagonal() == 0).

    Alternatively, “everything is equal to zero (False)” is the same as “nothing equal to True”, so you could also use not numpy.any(mymatrix.diagonal()).

    Since it’s a numeric matrix though, you can just add up the absolute value of the elements on the diagonal and if they’re all 0, each element must be zero: numpy.sum(numpy.abs(mymatrix.diagonal()))==0.

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

Sidebar

Related Questions

jQuery.unique lets you get unique elements of an array, but the docs say the
I am trying to install Googles' eclipse plugin - http://code.google.com/eclipse/docs/getting_started.html Even on following all
as it is stated at http://static.springsource.org/spring/docs/2.0.8/reference/orm.html The Spring Framework provides integration with Hibernate, JDO,
The python 2.6 docs state that x % y is defined as the remainder
The Adobe docs (I can't find which) state that Flash can read Shared Objects
As stated in the title, i'm looking for an XML schema (XSD-file) for the
As stated in the title, I need double shortcut keys for my application (ie.
As stated in the title, how can I modify - in the simplest manner
as stated in the title.
Question as stated in the title.

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.