Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

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: <a2r4hj$9p1$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

here is an example

In[]:=
expr=x^2 + 2*(x^2 - 1) - 1/x^2;
oexp = Experimental`OptimizeExpression[expr, 
    OptimizationLevel -> 2];

Out[]=
Experimental`OptimizedExpression[Block[{$67, $68}, 
  $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.

Regards
  Jens


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: Re: NestWhile
  • Previous by thread: Break up very long expression for C implementation
  • Next by thread: File Import