Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: C code generation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119948] Re: C code generation
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Thu, 30 Jun 2011 20:41:39 -0400 (EDT)
  • References: <iug5os$9g0$1@smc.vnet.net>

On 6/29/2011 2:34 PM, Shane Di Dona wrote:
> Is there a way to make Mathematica generate C code for functions such as Position[] and MemberQ[]?

  I am writing a program for CUDAlink and would like not to have to 
reinvent the wheel (in C)

on these somewhat basic functions.
>

1. Code for a similar program for position and member can be found in 
other languages, though really, it should be easy to write yourself.
2. A full implementation of Position and MemberQ requires that you allow 
for the possibility of searching for a pattern, and so you would have to 
(re) implement Mathematica's matching.  I doubt you want to do that.
3. While I am not familiar with CUDAlink, it seems to me unlikely that 
copying a (long?) list into a graphics processor to test for membership 
is a really bad idea. A worse idea would be, I suppose, NOT copying the 
list into the graphics processor.  My suggestion: Read up on hash 
tables. Suggestion 2: If you are in a hurry, don't use Mathematica.

RJF


  • Prev by Date: Running notebook from command line
  • Next by Date: Re: Remote presentation clicker for mathematica slideshows.
  • Previous by thread: Re: C code generation
  • Next by thread: How to find the difference between two lists (opposite of union[]?)