Re: Break up very long expression for C implementation
- To: mathgroup at smc.vnet.net
- Subject: [mg32538] Re: Break up very long expression for C implementation
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 26 Jan 2002 04:07:56 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <firstname.lastname@example.org>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
here is an example
expr=x^2 + 2*(x^2 - 1) - 1/x^2;
oexp = Experimental`OptimizeExpression[expr,
OptimizationLevel -> 2];
$67 = x^2; $68 = $67^(-1); -$68 + $67 + 2*(-1 + $67)]]
Now you need a Hold instead of Experimental`OptimizedExpression
because, otherwise Mathematica will revert the optimization, when
the block is evaluated.
Hold @@ oexp
But it needs a sufficient part of additional work
to make C code from it.
Hold @@ oexp
jose flanigan wrote:
> After a lot of work, I've computed a very long expression that I need
> to export as a C program. The expression is over 300,000 characters
> long. What I would like to do is automatically break it up into sub
> expressions that I can compute step-by-step in a C program. It would
> be particularly convenient effect of breaking up into parts that
> repeat multiple times in the expression. This would save me the
> computational cost of having to repeatedly compute the same thing over
> and over again.
> I was wondering if somebody can help me get started with this.
> Thanks in advance.
Prev by Date:
Re: button to evaluate notebook
Next by Date:
Previous by thread:
Break up very long expression for C implementation
Next by thread: