Skip to content

Commit 1b99b91

Browse files
authored
Merge pull request #451 from fredrikekre/fe/0.7
fixes for 0.7
2 parents 4b1afb6 + 5b264a2 commit 1b99b91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+529
-804
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
88
- nightly
99
notifications:
1010
email: false
1111
branches:
1212
only:
1313
- master
1414
- /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags for Documenter.jl, see # 298
15-
matrix:
16-
allow_failures:
17-
- julia: nightly
15+
# matrix:
16+
# allow_failures:
17+
# - julia: nightly
1818
# - os: osx
1919
# uncomment the following lines to override the default test script
2020
#script:

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6.0
2-
Compat 0.66
1+
julia 0.7-alpha

appveyor.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
3+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
4+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
55
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
66
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
77

8-
matrix:
9-
allow_failures:
10-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
8+
# matrix:
9+
# allow_failures:
10+
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11+
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
1212

1313
branches:
1414
only:

docs/src/index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,25 @@ Mutable versions [`MVector`](@ref), [`MMatrix`](@ref) and [`MArray`](@ref) are a
1414
as [`SizedArray`](@ref) for annotating standard `Array`s with static size information.
1515
Further, the abstract [`FieldVector`](@ref) can be used to make fast static vectors
1616
out of any uniform Julia "struct".
17+
18+
## Migrating code from Julia v0.6 to Julia v0.7
19+
20+
When upgrading code that is depending on **StaticArrays** the following notes may be helpful
21+
22+
* `chol` has been renamed to `cholesky` and return a factorization object. To obtain the factor
23+
use `C = cholesky(A).U`, just like for regular Julia arrays.
24+
25+
* `lu` now return a factorization object instead of a tuple with `L`, `U`, and `p`.
26+
They can be obtained by destructing via iteration (`L, U, p = lu(A)`) or by
27+
using `getfield` (`F = lu(A); L, U, p = F.L, F.U, F.p`).
28+
29+
* `qr` now return a factorization object instead of a tuple with `Q` and `R`.
30+
They can be obtained by destructing via iteration (`Q, R = qr(A)`) or by
31+
using `getfield` (`F = qr(A); Q, R = F.Q, F.R`)
32+
33+
* `eig` has been renamed to `eigen`, which return a factorization object, rather than
34+
a tuple with `(values, vectors)`. They can be obtained by destructing via iteration
35+
(`values, vectors = eigen(A)`) or by using `getfield`
36+
(`E = eigen(A); values, vectors = E.values, E.vectors`).
37+
38+
* `unshift` and `shift` have been renamed to `pushfirst` and `popfirst`.

docs/src/pages/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ the dimensions of a static array. An array `sa::SA` of size `(dims...)` is
6363
associated with `Size{(dims...)}()`. The following are equivalent (`@pure`)
6464
constructors:
6565
```julia
66-
Size{(dims...)}()
66+
Size{(dims...,)}()
6767
Size(dims...)
6868
Size(sa::StaticArray)
6969
Size(SA) # SA <: StaticArray

perf/benchmark-qr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using StaticArrays
2-
using BenchmarkTools, Compat
2+
using BenchmarkTools
33

44
a = m = 0
55
for K = 1:22

perf/benchmark_matrix_ops.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using StaticArrays, BenchmarkTools, DataFrames, DataStructures
22

33
Nmax = 20
4-
unary = (det, inv, expm)
4+
unary = (det, inv, exp)
55
binary = (\,)
66

77
data = OrderedDict{Symbol,Any}()

src/SDiagonal.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,14 @@ eye(::Type{SDiagonal{N,T}}) where {N,T} = SDiagonal(ones(SVector{N,T}))
8585
one(::Type{SDiagonal{N,T}}) where {N,T} = SDiagonal(ones(SVector{N,T}))
8686
one(::SDiagonal{N,T}) where {N,T} = SDiagonal(ones(SVector{N,T}))
8787
Base.zero(::SDiagonal{N,T}) where {N,T} = SDiagonal(zeros(SVector{N,T}))
88-
if VERSION < v"0.7-"
89-
expm(D::SDiagonal) = SDiagonal(exp.(D.diag))
90-
logm(D::SDiagonal) = SDiagonal(log.(D.diag))
91-
sqrtm(D::SDiagonal) = SDiagonal(sqrt.(D.diag))
92-
else
93-
exp(D::SDiagonal) = SDiagonal(exp.(D.diag))
94-
log(D::SDiagonal) = SDiagonal(log.(D.diag))
95-
sqrt(D::SDiagonal) = SDiagonal(sqrt.(D.diag))
88+
exp(D::SDiagonal) = SDiagonal(exp.(D.diag))
89+
log(D::SDiagonal) = SDiagonal(log.(D.diag))
90+
sqrt(D::SDiagonal) = SDiagonal(sqrt.(D.diag))
91+
function LinearAlgebra.cholesky(D::SDiagonal)
92+
any(x -> x < 0, D.diag) && throw(LinearAlgebra.PosDefException(1))
93+
C = sqrt.(D.diag)
94+
return Cholesky(SDiagonal(C), 'U', 0)
9695
end
97-
LinearAlgebra.chol(D::SDiagonal) = SDiagonal(chol.(D.diag))
98-
LinearAlgebra.chol(D::SDiagonal{N, T}) where {N, T <: Number} = SDiagonal(sqrt.(D.diag))
99-
LinearAlgebra._chol!(D::SDiagonal, ::Type{UpperTriangular}) = chol(D)
10096

10197
\(D::SDiagonal, B::StaticMatrix) = scalem(1 ./ D.diag, B)
10298
/(B::StaticMatrix, D::SDiagonal) = scalem(1 ./ D.diag, B)

src/StaticArrays.jl

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,15 @@ import Base: getindex, setindex!, size, similar, vec, show, length, convert, pro
1010
iszero, sum, prod, count, any, all, minimum, maximum, extrema, mean,
1111
copy, read, read!, write
1212

13-
if VERSION < v"0.7-"
14-
using Compat
15-
16-
using Base.Random
17-
import Base: rand, randn, randexp, rand!, randn!, randexp!
18-
using Core.Inference.return_type
19-
20-
import Base.LinAlg: transpose, ctranspose, eye, vecdot, eig, eigvals, eigfact, expm,
21-
logm, sqrtm, lyap, trace, kron, diag, vecnorm, norm, dot, diagm, lu,
22-
svd, svdvals, svdfact, factorize, ishermitian, issymmetric,
23-
isposdef, normalize, normalize!, Eigen, det, logdet, cross, diff, qr
24-
const LinearAlgebra = Base.LinAlg
25-
26-
const TransposeVector{T, V<:AbstractVector{T}} = RowVector{T, V}
27-
const AdjointVector{T, V<:AbstractVector{T}} = RowVector{T, ConjVector{T, V}}
28-
29-
const adjoint = ctranspose
30-
const tr = trace
31-
else
32-
using Compat
33-
34-
using Random
35-
import Random: rand, randn, randexp, rand!, randn!, randexp!
36-
using Core.Compiler: return_type
37-
38-
import Base: sqrt, exp, log
39-
40-
using LinearAlgebra
41-
import LinearAlgebra: transpose, adjoint, eye, vecdot, eig, eigvals, eigfact, lyap, tr,
42-
kron, diag, vecnorm, norm, dot, diagm, lu, svd, svdvals, svdfact,
43-
factorize, ishermitian, issymmetric, isposdef, normalize,
44-
normalize!, Eigen, det, logdet, cross, diff, qr
45-
46-
const TransposeVector{T, V<:AbstractVector{T}} = Transpose{T, V}
47-
const AdjointVector{T, V<:AbstractVector{T}} = Adjoint{T, V}
48-
end
13+
using Random
14+
import Random: rand, randn, randexp, rand!, randn!, randexp!
15+
using Core.Compiler: return_type
16+
import Base: sqrt, exp, log
17+
using LinearAlgebra
18+
import LinearAlgebra: transpose, adjoint, eye, vecdot, eigvals, eigen, lyap, tr,
19+
kron, diag, norm, dot, diagm, lu, svd, svdvals, svdfact,
20+
factorize, ishermitian, issymmetric, isposdef, normalize,
21+
normalize!, Eigen, det, logdet, cross, diff, qr
4922

5023
export StaticScalar, StaticArray, StaticVector, StaticMatrix
5124
export Scalar, SArray, SVector, SMatrix
@@ -60,7 +33,7 @@ export @SVector, @SMatrix, @SArray
6033
export @MVector, @MMatrix, @MArray
6134

6235
export similar_type
63-
export push, pop, shift, unshift, insert, deleteat, setindex
36+
export push, pop, pushfirst, popfirst, insert, deleteat, setindex
6437

6538
const _module_arg = isdefined(Base, Symbol("@__MODULE__"))
6639

src/abstractarray.jl

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -125,42 +125,9 @@ reshape(a::Array, s::Size{S}) where {S} = s(a)
125125

126126
# TODO permutedims?
127127

128-
# TODO perhaps could move `Symmetric`, etc into seperate files.
129-
130-
# This is used in Base.LinAlg quite a lot, and it impacts type stability
131-
# since some functions like expm() branch on a check for Hermitian or Symmetric
132-
# TODO much more work on type stability. Base functions are using similar() with
133-
# size, which poses difficulties!!
134-
@inline Base.full(sym::Symmetric{T,SM}) where {T,SM <: StaticMatrix} = _full(Size(SM), sym)
135-
136-
@generated function _full(::Size{S}, sym::Symmetric{T,SM}) where {S, T, SM <: StaticMatrix}
137-
exprs_up = [i <= j ? :(m[$(LinearIndices(S)[i, j])]) : :(m[$(LinearIndices(S)[j, i])]) for i = 1:S[1], j=1:S[2]]
138-
exprs_lo = [i >= j ? :(m[$(LinearIndices(S)[i, j])]) : :(m[$(LinearIndices(S)[j, i])]) for i = 1:S[1], j=1:S[2]]
139-
140-
return quote
141-
@_inline_meta
142-
m = sym.data
143-
if sym.uplo == 'U'
144-
@inbounds return SM(tuple($(exprs_up...)))
145-
else
146-
@inbounds return SM(tuple($(exprs_lo...)))
147-
end
148-
end
149-
end
150-
151-
@inline Base.full(herm::Hermitian{T,SM}) where {T,SM <: StaticMatrix} = _full(Size(SM), herm)
152-
153-
@generated function _full(::Size{S}, herm::Hermitian{T,SM}) where {S, T, SM <: StaticMatrix}
154-
exprs_up = [i <= j ? :(m[$(LinearIndices(S)[i, j])]) : :(conj(m[$(LinearIndices(S)[j, i])])) for i = 1:S[1], j=1:S[2]]
155-
exprs_lo = [i >= j ? :(m[$(LinearIndices(S)[i, j])]) : :(conj(m[$(LinearIndices(S)[j, i])])) for i = 1:S[1], j=1:S[2]]
156-
157-
return quote
158-
@_inline_meta
159-
m = herm.data
160-
if herm.uplo == 'U'
161-
@inbounds return SM(tuple($(exprs_up...)))
162-
else
163-
@inbounds return SM(tuple($(exprs_lo...)))
164-
end
165-
end
128+
# full deprecated in Base
129+
if isdefined(Base, :full)
130+
import Base: full
131+
@deprecate full(sym::Symmetric{T,SM}) where {T,SM <: StaticMatrix} SMatrix(sym)
132+
@deprecate full(herm::Hermitian{T,SM}) where {T,SM <: StaticMatrix} SMatrix(sym)
166133
end

0 commit comments

Comments
 (0)