[Date Index]
[Thread Index]
[Author Index]
Arbitrary Crash with Compile
*To*: mathgroup at smc.vnet.net
*Subject*: [mg36478] Arbitrary Crash with Compile
*From*: Wizard Lab <cschmitt at wizard.ucr.edu>
*Date*: Sun, 8 Sep 2002 03:31:06 -0400 (EDT)
*Organization*: University of California, Riverside
*Sender*: owner-wri-mathgroup at wolfram.com
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,
0},
{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,
nn}];
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 ->
True,
PlotLabel -> "\<Calculation Times as a function of n\>"];
MemoryInUse[] - tt\)
*)
I have followed Ted Ersek's tips and tricks
(http://www.verbeia.com/mathematica/tips/tip_index.html) 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???
Regards,
Bernard Gress
burnthebiscuit at netscape.net
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**
| |