Re: More on Delete Problems
- To: mathgroup at smc.vnet.net
- Subject: [mg51732] Re: More on Delete Problems
- From: p-valko at tamu.edu (Peter Valko)
- Date: Sun, 31 Oct 2004 01:16:14 -0500 (EST)
- References: <cl9t75$7nl$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Once again, Andzej was right (and mature in his judgement). He convinced me that the problem is caused by the "Packed Array Technology". It seems, that the Dot[] function (or in short-hand the "." itself) brings in the packed array. Then the Delete may (or may not) cause a memory violation. Therefore I suggest a temporary workaround: Unprotect[Dot]; Dot[x_, y_] := Inner[Times, x, y, Plus]; Protect[Dot]; a = {{1, 2}, {3, 4}}; b = {{1, 0}, {0, 1}}; c = a.b Delete[c, {1, 1}] Without the first line, the above code (run from scratch) crashes Mathematica (Version 5, Windows XP) With the first line added, packed arrays will not be used at all and there will be no crash. Of course, when packed arrays will not be used, Mathematica will be slower and more memory hungry on typical number crunching applications. "Dot" seems to be not the only function invoking packed array technology, but far the most dangerous, because it applies the technology even to a four - element matrix. "Table" also brings in packed arrays, but only at heavier usage. In fact the shortest "program" I could crash my Mathematica with is the following "oneliner" (run from scratch): Delete[Table[{1, 1}, {250}], {1, 1}] Evaluating it first works OK, but the second evaluation of the same line causes crash (Version 5, Windows XP, starting from scratch). Also, it does not matter if you put a semicolon after it or not. Using the ByteCount I can see what is the difference between a 249- and a 250- row Table: ByteCount[Table[{1,1},{249}]] is 16952 and ByteCount[Table[{1,1},{250}]] is 2060, that is in the second case approximately 500*4 byte is used, the same as would be used by a Fortran (C, VB)-like integer matrix of 500 elements. I think before a next version comes out a temporary solution might be a way to switch off PackedArray usage for the Session. I wonder if anybody knows how to do this (something like Off[PackedArrays] ? ...) Regards and Thanks Peter Gove Effinger <effinger at skidmore.edu> wrote in message news:<cl9t75$7nl$1 at smc.vnet.net>... > Here's simple code which bombs for me: > > a={{1.,2.,3.},{4.,5.,6.}} > > b = {{1,0,1},{0,-2,3}, {0,1,0}} > > c = a . b > > Delete[c,{1,1}] > > Why? > > G. Effinger