Re: [eigen] [RFC] Test helper to make a matrix with exact rank.

[ Thread Index | Date Index | More Archives ]

2009/2/2 Keir Mierle <mierle@xxxxxxxxx>:
> Here's a test routine to make a matrix with exact size and rank. It uses the
> SVD though, so may be too slow, and doesn't work on complex matrices
> (because SVD doesn't). Nevertheless, it is probably better than the current
> method of generating random matrices when it applies because the matrix will
> have excellent conditioning (i.e. the singular values will be 1, 1, 1, 1 ...
> (up to rank), 0, 0, 0, 0, 0).
> It works by making a random (tall) matrix of the desired size, then setting
> the first 'rank' singular values to 1.0, and the remaining singular values
> to zero. Then the matrix is reconstituted by multiplying it back together,
> creating a matrix with the desired rows, columns, and rank.
> Comments?

Sounds very good.

The code we currently have (doSomeRankPreserving...) works well for
large enough matrices, at least 20x20, but not for smaller sizes. On
the other hand, it is far less expensive for large sizes (O(n^2) vs

So I propose that we make a function doing the old way for size >=
20x20 and doing your way if either of the dimensions is <20.

(Just FYI we need it to be reasonably fast for sizes up to 1000x1000).


Mail converted by MHonArc 2.6.19+