On Mar 15, 2004, at 2:00 PM, DrBob wrote:
> I didn't expect it to be the fastest method... it may use a lot less
> memory, but that's a temporary advantage.
Sorry, I didn't mean to offend. Hopefully you ran across my previous
post comparing a variety of solutions, I merely wanted to report how
that approach compared to those tested earlier.
Since I've seen more than a few messages on this list about handling
large matrices I thought I'd compare solutions that ignored memory use
and those that tried to be efficient in space used. Since there are a
wide variety of approaches to this problem in Mathematica I thought it
would be useful to compare them on the basis of space and time
efficiency.
Incidentally, without access to the Mathematica internals, it's
impossible to know if the expression
a+Transpose[a]-DiagonalMatrix[Tr[a, List]] really takes three times as
much memory as Array[a[[Min[#1, #2], Max[#1, #2]]] &, {Length@a,
Length@a}]. It's entirely possible the interpreter is smart enough to
know the storage of the temporary values is equivalent to the storage
of the result and the result can be computed in place. So really it's
the difference between solutions that explicitly try to be space
efficient and those that don't.
> Building a matrix that large (2000x2000), when half the information is
> redundant, is probably a bad idea in the first place;
I won't argue with that.
> Instead, you should write code that uses the necessary information
> more efficiently.
>
> SparseArray also may be of help.
See my earlier post.
Ultimately the answer to the question of efficiency is, where did this
array come from and what was Marc going to do with it?
Regards,
Ssezi