JuliaLang/julia — pull request #3158 by malmaud (2013-05-20 18:58:03+00:00)
Title: Added diag! function for setting the diagonal of a matrix

```
julia> A=zeros(3,3)
3x3 Float64 Array:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0

julia> diag!(A,[1.,2.,3.])
3x3 Float64 Array:
1.0 0.0 0.0
0.0 2.0 0.0
0.0 0.0 3.0

julia> diag!(A,[4.,5.],1)
3x3 Float64 Array:
1.0 4.0 0.0
0.0 2.0 5.0
0.0 0.0 3.0

julia> diag!(A,6.,-1)
3x3 Float64 Array:
1.0 4.0 0.0
6.0 2.0 5.0
0.0 6.0 3.0

```