JuliaLang/julia — pull request #9326 by davidavdav (2014-12-12 07:59:48+00:00)
Title: Generalize container matrix to AbstractMatrix for most factorization types

This PR generalizes the container type of most factorization types from `Matrix` to `AbstractMatrix`. This is similar to what has already been implemented for LU. The types are now all parameterized by the container type, as in
```julia
type Factortype{T,S<:AbstractMatrix}
factor::S
Factortype(f::AbstractArray{T}) = new(f)
end
Factortype{T}(f::AbstractType{T}) = Factortype{T,typeof(f)}(f)
```
This rather cumbersome type def makes sure that `factor` is actually an `AbstractMatrix{T}`, i.e., that the `T`s are consistent. Further, it provides a convenience constructor `Factortype(a::AbstractArray)`.

The main reason for submitting this PR is that I was including support for factorization in NamedArrays. For LU I could have an LU{NamedMatrix}, effectively keeping dimension names, but this was not possible for the other factorization types.

Additionally, this PR
- changes the definition of LU to include this matrix-type checking
- fixes a bug in `cholfact(x::Number)`
- adds a test for `cholfact(x::Number)`

It is amazing how important the unit tests were, even for such a small PR. Despite the repetitive nature of the changes, I managed to come up with 3 or 4 different ways to make typo/errors, but these are now all resolved.