Home > manopt > tools > multiscale.m

# multiscale

## PURPOSE Multiplies the 2D slices in a 3D matrix by individual scalars.

## SYNOPSIS function A = multiscale(scale, A)

## DESCRIPTION ``` Multiplies the 2D slices in a 3D matrix by individual scalars.

function A = multiscale(scale, A)

Given a vector scale of length N and a 3-dimensional matrix A of size
n-by-m-by-N, returns a matrix A of same size such that
A(:, :, k) := scale(k) * A(:, :, k);

## CROSS-REFERENCE INFORMATION This function calls:
This function is called by:
• robust_pca Computes a robust version of PCA (principal component analysis) on data.

## SOURCE CODE ```0001 function A = multiscale(scale, A)
0002 % Multiplies the 2D slices in a 3D matrix by individual scalars.
0003 %
0004 % function A = multiscale(scale, A)
0005 %
0006 % Given a vector scale of length N and a 3-dimensional matrix A of size
0007 % n-by-m-by-N, returns a matrix A of same size such that
0008 % A(:, :, k) := scale(k) * A(:, :, k);
0009 %
0011
0012 % This file is part of Manopt: www.manopt.org.
0013 % Original author: Nicolas Boumal, Dec. 30, 2012.
0014 % Contributors:
0015 % Change log:
0016
0017
0018     assert(ndims(A) <= 3, ...
0019            ['multiscale is only well defined for matrix arrays of 3 ' ...
0020             'or less dimensions.']);
0021     [n, m, N] = size(A);
0022     assert(numel(scale) == N, ...
0023            ['scale must be a vector whose length equals the third ' ...
0024             'dimension of A, that is, the number of 2D matrix slices ' ...
0025             'in the 3D matrix A.']);
0026
0027     scale = scale(:);
0028     A = reshape(bsxfun(@times, reshape(A, n*m, N), scale'), n, m, N);
0029
0030 end```

Generated on Mon 10-Sep-2018 11:48:06 by m2html © 2005