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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:29+00:00 2026-05-31T13:11:29+00:00

I am trying to do a function iteratively to an array, and make a

  • 0

I am trying to do a function iteratively to an array, and make a matrix composed of what it returns. If this was native python, what I would do is:

[func(x, y) for y in xrange(Y)]

but if I do that, I need to wrap it with numpy.matrix() to vectorize it. What is the numpy way of doing this? Right now I am initializing a zeros matrix and then populating it with elements I get from a for loop, but that seems inefficient.

  • 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-31T13:11:30+00:00Added an answer on May 31, 2026 at 1:11 pm

    Take a look at the numpy tutorial, especially the part about Universal Functions or ufuncs. A ufunc is:

    Functions that operate element by element on whole arrays.

    which sounds like what you’re asking for. Keep in mind that you probably don’t need to write your own ufunc, but just write func in terms of existing ufuncs. For example:

    def hypot(a, b):
        return np.sqrt(a**2 + b**2)
    
    >>> a = np.array([3., 5., 10.])
    >>> b = np.array([4., 12., 24.,])
    >>> hypot(a, b)
    array([  5.,  13.,  26.])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying write a function that generates simulated data but if the simulated
I'm working on a password reset function and trying to check to make sure
I have a function trying to run this: if ( action=='fadeIn' ) { if
I'm trying this: function send_sms() { $liveQuery = $this->db->get('liveList'); $counter = 0; foreach($liveQuery->result() as
Trying to write function that numerize items of list and returns list of tuples
Hi I am trying to sum two function handles, but it doesn't work. for
I am trying this: function initMenu() { $(#menu ul).hide(); $(#menu li a).click(function() { $(this).addClass('selected');
Here is my piece of code am trying: initData:function(period) { this.getLoadObject('0',url, this.callbackFunction); }, I
I am trying this: function add_things() { var first = '2'; var second =
I'm trying to write a function in Python that finds the first number in

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.