No BSD License  

Highlights from
Multi dimensional matrix product, outer product and partial trace

5.0

5.0 | 2 ratings Rate this file 20 Downloads (last 30 days) File Size: 2.77 KB File ID: #10062

Multi dimensional matrix product, outer product and partial trace

by Wynton Moore

 

19 Feb 2006 (Updated 27 Jun 2006)

This set of 3 files is aimed at efficiently extending matrix multiplication to higher dimensional ar

| Watch this File

File Information
Description

This set of 3 files is aimed at efficiently extending matrix multiplication to higher dimensional arrays. It can also be used to compute the outer product of two arrays, and perform a trace over any two dimensions of an array.

In computing the matrix product of two arrays, first an outer product is taken, and then the resulting array is traced over the appropriate two dimensions. In my tests this has been 25-30 times faster than using "for" loops alone.

Example: to calculate the product of A and B, summing on the 2nd dimension of A and the 5th dimension of B, one would write C = gmdmp(A, 2, B, 5). Dimensions 2 of A and 5 of B need not be of identical length.

Errors: Due to use of the "squeeze" function, problems may be encountered with "diagsum" if there are singleton dimensions which are to be retained. This will usually just result in the output array having those singleton dimensions removed. However, an error may be encountered if the input array is of rank >2 and its last dimension is a singleton.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
21 Jul 2006 Keith Bonin

Works very well! Thanks.

26 Aug 2010 Dag Lindbo  
Please login to add a comment or rating.
Updates
27 Jun 2006

Removing incorrect use of the word "tensor" in file description.

Tag Activity for this File
Tag Applied By Date/Time
matrices Wynton Moore 22 Oct 2008 08:16:15
matrix array product rank 3d outer trace Wynton Moore 22 Oct 2008 08:16:15

Contact us at files@mathworks.com