Home > manopt > manifolds > rotations > randskew.m

randskew

PURPOSE ^

Generates random skew symmetric matrices with normal entries.

SYNOPSIS ^

function S = randskew(n, N)

DESCRIPTION ^

 Generates random skew symmetric matrices with normal entries.
 
 function S = randskew(n, N)

 S is an n-by-n-by-N matrix where each slice S(:, :, i) for i = 1..N is a
 random skew-symmetric matrix with upper triangular entries distributed
 independently following a normal distribution (Gaussian, zero mean, unit
 variance).

 See also: randrot

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function S = randskew(n, N)
0002 % Generates random skew symmetric matrices with normal entries.
0003 %
0004 % function S = randskew(n, N)
0005 %
0006 % S is an n-by-n-by-N matrix where each slice S(:, :, i) for i = 1..N is a
0007 % random skew-symmetric matrix with upper triangular entries distributed
0008 % independently following a normal distribution (Gaussian, zero mean, unit
0009 % variance).
0010 %
0011 % See also: randrot
0012 
0013 % This file is part of Manopt: www.manopt.org.
0014 % Original author: Nicolas Boumal, Sept. 25, 2012.
0015 % Contributors:
0016 % Change log:
0017 
0018 
0019     if nargin < 2
0020         N = 1;
0021     end
0022 
0023     % Subindices of the (strictly) upper triangular entries of an n-by-n
0024     % matrix
0025     [I J] = find(triu(ones(n), 1));
0026     
0027     K = repmat(1:N, n*(n-1)/2, 1);
0028     
0029     % Indices of the strictly upper triangular entries of all N slices of
0030     % an n-by-n-by-N matrix
0031     L = sub2ind([n n N], repmat(I, N, 1), repmat(J, N, 1), K(:));
0032     
0033     % Allocate memory for N random skew matrices of size n-by-n and
0034     % populate each upper triangular entry with a random number following a
0035     % normal distribution and copy them with opposite sign on the
0036     % corresponding lower triangular side.
0037     S = zeros(n, n, N);
0038     S(L) = randn(size(L));
0039     S = S-multitransp(S);
0040 
0041 end

Generated on Fri 08-Sep-2017 12:43:19 by m2html © 2005