JuliaLang/julia — pull request #8796 by andreasnoack (2014-10-23 23:04:02+00:00)
Title: WIP:Make LinAlg more type stable

This is a followup on #8753. This is a first attempt to make the code in `LinAlg` a bit more type stable. It is very convenient to dispatch on whether a matrix is upper or lower triangular, e.g. `Triangular{:U}+Triangular{:U} = Triangular{:U}` but `Triangular{:U}+Triangular{:L} = Matrix`. Unfortunately, it makes it them a bit more complicated to construct because the two first parameters are the element matrix types which is inferred from the input matrix whereas the last two determines if the matrix is upper or lower and if it has unit diagonal. The last two are useful to provide as a user, such that a non-triangular matrix can be interpreted as triangular.

As a consequence, the present convenience constructor is not type stable, which can cause significant allocation. To solve the problem, I have introduced a parametric type with the only purpose of wrapping the arguments of the convenience constructor, such that they are types instead of value. For now, I have named the type `Token`, because we couldn't really find a good name in #8753. Hopefully, we can avoid the new type and just wrap a value in curly brackets and have it interpreted as a type.