comparison toolbox/cycol.m @ 0:8f23314345f4 draft

Create local repository for matrix toolboxes. Step #0 done.
author Antonio Pino Robles <data.script93@gmail.com>
date Wed, 06 May 2015 14:56:53 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8f23314345f4
1 function A = cycol(n, k)
2 %CYCOL Matrix whose columns repeat cyclically.
3 % A = CYCOL([M N], K) is an M-by-N matrix of the form A = B(1:M,1:N)
4 % where B = [C C C...] and C = RANDN(M, K). Thus A's columns repeat
5 % cyclically, and A has rank at most K. K need not divide N.
6 % K defaults to ROUND(N/4).
7 % CYCOL(N, K), where N is a scalar, is the same as CYCOL([N N], K).
8 %
9 % This type of matrix can lead to underflow problems for Gaussian
10 % elimination: see NA Digest Volume 89, Issue 3 (January 22, 1989).
11
12 m = n(1); % Parameter n specifies dimension: m-by-n.
13 n = n(max(size(n)));
14
15 if nargin < 2, k = max(round(n/4),1); end
16
17 A = randn(m, k);
18 for i=2:ceil(n/k)
19 A = [A A(:,1:k)];
20 end
21
22 A = A(:, 1:n);