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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:24:27+00:00 2026-05-25T21:24:27+00:00

I had like to know the best fatest/optimized way of getting the maximum values

  • 0

I had like to know the best fatest/optimized way of getting the maximum values element-wised of "n" matrices in Python/Numpy.

For example:

import numpy as np
matrices=[np.random.random((5,5)) for i in range(10)]
# the function np.maximum from numpy only works for two matrices.
max_matrix=np.maximum(matrices[0],matrices[1])
max_matrix=np.maximum(*matrices) # <- error

How would you overcome this problem?

  • 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-25T21:24:28+00:00Added an answer on May 25, 2026 at 9:24 pm

    Use reduce:

    reduce(np.maximum, matrices)
    

    From the docs:

    reduce(function, iterable[, initializer])

    Apply function of two arguments cumulatively to the items of iterable,
    from left to right, so as to reduce the iterable to a single value.
    For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
    ((((1+2)+3)+4)+5). The left argument, x, is the accumulated value and
    the right argument, y, is the update value from the iterable. If the
    optional initializer is present, it is placed before the items of the
    iterable in the calculation, and serves as a default when the iterable
    is empty. If initializer is not given and iterable contains only one
    item, the first item is returned.

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

Sidebar

Related Questions

I had a doubt on comparision operator in python. I would like to know
I'd like to know what the best way to handle form validation is where
i would like to know what is the standard/best way of doing the following:
I'd like to know what is the best practice to track and/or persist changes
I need to know the best way to manage team web-development on a shared
I would like to know what are best practices for database queries. I am
I want to know the best way to implement this (approach). I will bee
I want to know the best way to accomplish the following. I have a
Does any one know the best way to create an autocomplete combobox with Knockout
I am creating a social networking site and need to know the best way

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.