comparison toolbox/cycol.m @ 2:c124219d7bfa draft

Re-add the 1995 toolbox after noticing the statement in the ~higham/mctoolbox/ webpage.
author Antonio Pino Robles <data.script93@gmail.com>
date Thu, 07 May 2015 18:36:24 +0200
parents 8f23314345f4
children
comparison
equal deleted inserted replaced
1:e471a92d17be 2:c124219d7bfa
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);