Home > manopt > tools > multitransp.m

multitransp

PURPOSE ^

Transposing arrays of matrices.

SYNOPSIS ^

function b = multitransp(a, dim)

DESCRIPTION ^

 Transposing arrays of matrices.
 
    B = MULTITRANSP(A) is equivalent to B = MULTITRANSP(A, DIM), where
    DIM = 1.

    B = MULTITRANSP(A, DIM) is equivalent to
    B = PERMUTE(A, [1:DIM-1, DIM+1, DIM, DIM+2:NDIMS(A)]), where A is an
    array containing N P-by-Q matrices along its dimensions DIM and DIM+1,
    and B is an array containing the Q-by-P transpose (.') of those N
    matrices along the same dimensions. N = NUMEL(A) / (P*Q), i.e. N is
    equal to the number of elements in A divided by the number of elements
    in each matrix.

    MULTITRANSP, PERMUTE and IPERMUTE are a generalization of TRANSPOSE
    (.') for N-D arrays.

    Example:
       A 5-by-9-by-3-by-2 array may be considered to be a block array
       containing ten 9-by-3 matrices along dimensions 2 and 3. In this
       case, its size is so indicated:  5-by-(9-by-3)-by-2 or 5x(9x3)x2.
       If A is ................ a 5x(9x3)x2 array of 9x3 matrices,
       C = MULTITRANSP(A, 2) is a 5x(3x9)x2 array of 3x9 matrices.

    See also PERMUTE, IPERMUTE, MULTIPROD, MULTITRACE, MULTISCALE.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function b = multitransp(a, dim)
0002 % Transposing arrays of matrices.
0003 %
0004 %    B = MULTITRANSP(A) is equivalent to B = MULTITRANSP(A, DIM), where
0005 %    DIM = 1.
0006 %
0007 %    B = MULTITRANSP(A, DIM) is equivalent to
0008 %    B = PERMUTE(A, [1:DIM-1, DIM+1, DIM, DIM+2:NDIMS(A)]), where A is an
0009 %    array containing N P-by-Q matrices along its dimensions DIM and DIM+1,
0010 %    and B is an array containing the Q-by-P transpose (.') of those N
0011 %    matrices along the same dimensions. N = NUMEL(A) / (P*Q), i.e. N is
0012 %    equal to the number of elements in A divided by the number of elements
0013 %    in each matrix.
0014 %
0015 %    MULTITRANSP, PERMUTE and IPERMUTE are a generalization of TRANSPOSE
0016 %    (.') for N-D arrays.
0017 %
0018 %    Example:
0019 %       A 5-by-9-by-3-by-2 array may be considered to be a block array
0020 %       containing ten 9-by-3 matrices along dimensions 2 and 3. In this
0021 %       case, its size is so indicated:  5-by-(9-by-3)-by-2 or 5x(9x3)x2.
0022 %       If A is ................ a 5x(9x3)x2 array of 9x3 matrices,
0023 %       C = MULTITRANSP(A, 2) is a 5x(3x9)x2 array of 3x9 matrices.
0024 %
0025 %    See also PERMUTE, IPERMUTE, MULTIPROD, MULTITRACE, MULTISCALE.
0026 
0027 % $ Version: 1.0 $
0028 % CODE      by:                 Paolo de Leva (IUSM, Rome, IT) 2005 Sep 9
0029 % COMMENTS  by:                 Code author                    2006 Nov 21
0030 % OUTPUT    tested by:          Code author                    2005 Sep 13
0031 % -------------------------------------------------------------------------
0032 
0033 % Setting DIM if not supplied.
0034 if nargin == 1, dim = 1; end
0035 
0036 % Transposing
0037 order = [1:dim-1, dim+1, dim, dim+2:ndims(a)];
0038 b = permute(a, order);
0039 
0040 end

Generated on Sat 12-Nov-2016 14:11:22 by m2html © 2005