DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th August 2008
kasse kasse is offline
Fdisk Soldier
 
Join Date: Jun 2008
Posts: 67
Default How to vectorize a function for numpy arrays in Python

In python say that I have a numpy array
Code:
 myarray =array([item1,item2,...itemN])
all items are of the same type and I have a function
Code:
 myfun(item)
and I want to use myfun on myarray. I dont want to write a function that uses a for loop applying myfun on the elements in myarray since the for loops are so slow in python on big array 10^N elements. The predefined types and basic operations on these seem to work in vectorized format, so how do I write my own.
I know there is something called ufunc with numpy but I cannot access scipy.org since the site appears to be down now. Vectorize and frompyfunc works but it is much slower that if you can make your own ufunc like.

Last edited by kasse; 26th August 2008 at 02:38 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ncurses & function keys JimC OpenBSD General 1 24th October 2011 02:36 PM
Undefined function in OpenBSD WeakSauceIII OpenBSD General 4 20th May 2009 12:58 PM
Basic Perl arrays question stukov Programming 12 18th November 2008 08:44 PM
C 2D arrays jgroch Programming 16 2nd August 2008 01:54 AM
ksh arrays mtx Programming 11 7th May 2008 10:00 AM


All times are GMT. The time now is 03:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick