MathGroup Archive 2000

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

Search the Archive

bug with Compile ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26374] bug with Compile ?
  • From: Jean-Marie THOMAS <jmt at agat.net>
  • Date: Sat, 16 Dec 2000 02:40:07 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

$Version : "4.0 for Linux (April 21, 1999)"

Implementing some basic functions, I get the following discrepancy :

EuclidianDistance1[p_List, q_List] := 
  Check[With[{m = p - q}, N at Sqrt[m.m]], $Failed]

EuclidianDistance3 := 
  Check[Compile[{{p, _Real, 1}, {q, _Real, 1}}, 
      With[{m = p - q}, Sqrt[m.m]]], $Failed]

These two functions are ok, and the compiled form about four times faster. 
The Check prevents obviously inconsistent results to propagate, like in the 
following situation (two points in different dimensions) :

EuclidianDistance1[{1., 2., 3.}, {1., 2., 3., 4.}]
Thread::"tdlen": "Objects of unequal length in \!\(\(\({1.`, 2.`, 3.`}\)\) + \
\(\({\(\(-1.`\)\), \(\(-2.`\)\), \(\(-3.`\)\), \(\(-4.`\)\)}\)\)\) cannot be \
combined."
Out[96]=
$Failed

Which is what expected : the return value is $Failed

Now :
EuclidianDistance3[{1., 2., 3.}, {1., 2., 3., 4.}]

CompiledFunction::"cflist": "Non-tensor object generated; proceeding with \
uncompiled evaluation."
Thread::"tdlen": "Objects of unequal length in \!\(\(\({1.`, 2.`, 3.`}\)\) + \
\(\({\(\(-1.`\)\), \(\(-2.`\)\), \(\(-3.`\)\), \(\(-4.`\)\)}\)\)\) cannot be \
combined."

\!\(\ at \(\(({1.`, 2.`, 3.`} + {\(-1.`\), \(-2.`\), \(-3.`\), \(-4.`\)})\) . \
\(({1.`, 2.`, 3.`} + {\(-1.`\), \(-2.`\), \(-3.`\), \(-4.`\)})\)\)\)

The return value is in this case an unevaluated expression, while $Failed is 
expected.

Bug ?


  • Prev by Date: Re: Q: Postscript problem with braces "()" (now complete)
  • Next by Date: Re: Re: want to modify NDSolve--molecular dynamics with mathematica
  • Previous by thread: Re: Q: Postscript problem with braces "()" (now complete)
  • Next by thread: RE: bug with Compile ?