[Date Index]
[Thread Index]
[Author Index]
Re: Matrix multiplication speed up
*To*: mathgroup at smc.vnet.net
*Subject*: [mg83088] Re: Matrix multiplication speed up
*From*: Yaroslav Bulatov <yaroslavvb at gmail.com>
*Date*: Sat, 10 Nov 2007 03:41:44 -0500 (EST)
*References*: <fgs87d$3uh$1@smc.vnet.net><fh1co5$cus$1@smc.vnet.net>
One issue is that Mathematica automatically simplifies/rearranges
certain expressions (like Times), so defining a custom multiplication
operation (like dh's response) is one solution.
If you just want index sets, perhaps you could do the following:
Compute product of 3 2x2 matrices
m = 3; n = 2; mats = Array[x[#1][#2, #3] &, {m, n, n}]; product = Dot
@@ mats;
Replace all heads with List, calling Expand to undo automatic
factoring
tuples = Apply[List, product[[1, 1]] // Expand, {0, 2}];
To get into format you specified, merge the last 2 levels of the tree
indices = Flatten[tuples, {{1}, {2, 3}}]
You should get
{{1, 1, 1, 1, 1, 1}, {1, 2, 2, 1, 1, 1}, {1, 1, 1, 2, 2, 1}, {1, 2, 2,
2, 2, 1}}
A question for mathgroup -- Mathematica will automatically factor
equations involving Plus/Times. Why doesn't clearing definitions for
Plus/Times prevent this? Is there anything I can do to override the
default handling of these operators?
Yaroslav
On Nov 9, 2:28 am, Frank Brand <frank.br... at t-online.de> wrote:
> Hi all,
>
> thanks for responding!
> I should be more precise in what I'm looking for.
> What I'm especially interested in is the preserved order of FACTORS in
> the sums of the components of the resulting product of the two matrices,
> so e.g.
> I'd like to have a[2,1]*a[27,3]*a[1,5] instead of a[1,5]*a[2,1]*a[27,3]
> (Mathematica's natural order), because I'm interested in the resulting
> index sets like {2, 1, 27, 3, 1, 5}.
> Do you have any idea how to realize this?
>
> Greetings
> Frank
Prev by Date:
** Re: Can you get a package back to a notebook easily?**
Next by Date:
**Re: trying to "simplify" very large output**
Previous by thread:
**Re: Matrix multiplication speed up**
Next by thread:
**affine transformation to rasters**
| |