       Re: exporting a list of functions for use in a C function

• To: mathgroup at smc.vnet.net
• Subject: [mg44377] Re: exporting a list of functions for use in a C function
• From: "Hans Michel" <hansjm at bellsouth.net>
• Date: Fri, 7 Nov 2003 05:16:20 -0500 (EST)
• References: <bob7qo\$qu1\$1@smc.vnet.net>
• Reply-to: "Hans Michel" <hansjm at bellsouth.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Try Using CForm

In:= CForm[x^15]
Out//CForm=
Power(x,15)

Hans
"Nathan Moore" <nmoore at physics.umn.edu> wrote in message
news:bob7qo\$qu1\$1 at smc.vnet.net...
> I've composed a large list of functions in Mathematica that I'd like to
> have a c function evaluate.  To my knowledge c and C++ reject the
> convention x^2 and prefer either x*x or pow(x,2).  The functions are
> integer powers of a single variable.  I'm using the command,
>
> Export["function_list.txt", Table[gflist[p], {p, 2, 5}], "CSV"]
>
> where "gflist[n]" generates the said set of functions for the case "n".
>   The output file then looks like:
>
> [winesap:~] nmoore% cat function_list.txt
> 1/(8*d*l^3*Pi)
> 1/(8*l^3*Pi),-(-3 + d)/(16*d*l^3*Pi)
> (8 - 3*d)/(64*l^3*Pi),(-4 + d)^2/(64*d*l^3*Pi)
> -(-5 + d^2)/(64*l^3*Pi),(-5 + 30*d - 15*d^2 +
> 2*d^3)/(192*d*l^3*Pi),-(-5 + d)^3/(384*d*l^3*Pi)
>
> I don't mind pasting in the "case" statement required by c, but I don't
> have the free two days required to re-express all the carats (^).  How
> can I have Mathematica express x^15 as x*x*x*x*x*x*x*x*x*x*x*x*x*x*x
> (the highest power of the polynomial is "n", I'd like to export the set
> of functions n=2 to n=30 or so - far too much typing for me)
>
> NT Moore
> University of Minnesota Physics
>

```

• Prev by Date: Re: Trying to use Mathematica as "word processor" for my math homework
• Next by Date: Re: exporting a list of functions for use in a C function
• Previous by thread: exporting a list of functions for use in a C function
• Next by thread: Re: exporting a list of functions for use in a C function