MathGroup Archive 1994

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

Search the Archive

Re: Compile

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Compile
  • From: Jerry Keiper <keiper>
  • Date: Tue, 28 Jun 1994 07:46:12 -0500

	> f = Compile[ {{x, _Real}}, x/10^8 ]
	> 
	> Evaluating it:
	> 
	> f[1.0]    ->    "CompiledFunction::cfn: Numerical error
	> encountered at instruction 6; proceeding with uncompiled
	> evaluation."

	> I assume it's a bug, or have I missed something ?


The latter, although this has been improved for the next version.
Compile has the Attribute HoldAll.  As such there are two operations
in the expression x/10^8: integer exponentiation and floating-point
division.  You are getting integer overflow with 10^8.  The best
fix (in terma of speed) would be to use

	f = Compile[ {{x, _Real}}, 0.00000001 x]
or
	f = Compile[ {{x, _Real}}, Evaluate[x/N[10^8]]]

Jerry B. Keiper
keiper at wri.com
Wolfram Research, Inc.






  • Prev by Date: Re: Question
  • Next by Date: Are these good books?
  • Previous by thread: Compile
  • Next by thread: Compile