MathGroup Archive 2002

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

Search the Archive

Arbitrary Crash with Compile

Dear Group,

I have a  program to take the local polynomial non parametric regression
of two variables.  It uses Compile, unfortunately, and regularly, but
inconsistently, causes Mathematica to crash (in Win2K, with I forget
what error, and in Win98/Mathematica4.0 with an invalid memory access from
MathDLL.dll).  I am running Mathematica 4.1, and have this problem consistently
on 4 different machines.

Here is the code, if it doesn't crash the first time, it will the second
or third:

w = Compile[{{xj, _Real, 0}, {XX, _Real, 1}, {YY, _Real, 1}, {h, _Real,
     {nn, _Integer, 0}, {ord, _Integer, 0}},
First[Inverse[Sum[Outer[Times, Table[If[Positive[q], (XX[[i]] - xj)^q,
1], {q, 0, ord}],
Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0,
ord}]*E^(-0.5*((XX[[i]] - xj)/h)^2)], {i, nn}]] .
Sum[(Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0, ord}]*YY[[i]])*
E^(-0.5*((XX[[i]] - xj)/h)^2), {i, nn}]]];

\!\(tt = MemoryInUse[];
  ListPlot[Table[{\((i + 1)\)\^2, \(Timing[
              nn = \((i + 1)\)\^2; \[Epsilon] = Table[Random[]*3, {i,
              testX = Table[i* .3 - Random[]*2, {i, nn}];
              testY = Table[Sin[i/3] - 2, {i, nn}] + \[Epsilon];
              Map[w[#, testX, testY,  .1 + Random[], nn, 0] &,
                testX];]\)[\([1]\)]/Second}, {i, 15}], PlotJoined ->
    PlotLabel -> "\<Calculation Times as a function of n\>"];
  MemoryInUse[] - tt\)

I have followed Ted Ersek's tips and tricks
( about Compile,
and have tried changing all variable names (works sometimes), removing
any hidden spaces, restructuring the formulas, changing all 0's to 0. 's
and all 1's to 1. 's, etcetera etcetera, but I still can't comprehend
what the problem might be.  Doing "w[[-2]]" shows a list of op-code
numbers, and one function name, Inverse[#1]&, so it seems to me that
there are no problems with the use of Compile here. Would anyone have
any thoughts???


Bernard Gress
burnthebiscuit at

  • Prev by Date: Profiler for Mathematica
  • Next by Date: RE: RE: Generating Two Unit Orthogonal Vectors
  • Previous by thread: Re: Profiler for Mathematica
  • Next by thread: Re: Arbitrary Crash with Compile