Skip to content

Commit

Permalink
Support Julia v1.3 (#126)
Browse files Browse the repository at this point in the history
* Support Julia v1.3

* Skip Float16 det test, add tests for #118

* v0.10.1, add missing similar

* Increase coverage

* Fix tests
  • Loading branch information
dlfivefifty authored Aug 22, 2019
1 parent ce6ff41 commit 409aed0
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 35 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ julia:
- 1.0
- 1.1
- 1.2
- 1.3
- nightly
matrix:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "0.10"
version = "0.10.1"

[deps]
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ environment:
matrix:
- julia_version: 1
- julia_version: 1.1
- julia_version: 1.2
- julia_version: 1.2
- julia_version: 1.3
- julia_version: nightly

platform:
Expand Down
8 changes: 7 additions & 1 deletion src/BandedMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LinearAlgebra.LAPACK: liblapack, chkuplo, chktrans
import LinearAlgebra: cholesky, cholesky!, cholcopy, norm, diag, eigvals!, eigvals, eigen!, eigen,
qr, qr!, axpy!, ldiv!, mul!, lu, lu!, ldlt, ldlt!, AbstractTriangular,
chkstride1, kron, lmul!, rmul!, factorize, StructuredMatrixStyle, logabsdet,
svdvals, svdvals!, QRPackedQ, checknonsingular, ipiv2perm, _apply_ipiv!, tril!,
svdvals, svdvals!, QRPackedQ, checknonsingular, ipiv2perm, tril!,
triu!, Givens
import MatrixFactorizations: ql, ql!, QLPackedQ, reflector!, reflectorApply!
import SparseArrays: sparse
Expand Down Expand Up @@ -70,6 +70,12 @@ else
import Base: require_one_based_indexing
end

if VERSION < v"1.3-"
const _apply_ipiv_rows! = LinearAlgebra._apply_ipiv!
else
import LinearAlgebra: _apply_ipiv_rows!
end

include("blas.jl")
include("lapack.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/banded/BandedMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ end
similar(bm::AbstractBandedMatrix, n::Integer, m::Integer) = similar(bm, eltype(bm), m, n)
similar(bm::AbstractBandedMatrix, n::Integer, m::Integer, l::Integer, u::Integer) =
similar(bm, eltype(bm), m, n, l, u)

similar(bm::AbstractBandedMatrix, nm::Tuple{<:Integer,<:Integer}) = similar(bm, nm...)


## Abstract Array Interface
Expand Down
3 changes: 2 additions & 1 deletion src/banded/bandedqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ end
# rmul!(A::AbstractMatrix, adjQ::Adjoint{<:Any,<:QRPackedQ{<:Any,<:BandedMatrix}}) = banded_rmul!(A, adjA)
# rmul!(A::StridedMatrix, adjQ::Adjoint{<:Any,<:QRPackedQ{<:Any,<:BandedMatrix}}) = banded_rmul!(A, adjA)
rmul!(A::StridedVecOrMat{T}, Q::QRPackedQ{T,B}) where {T<:BlasFloat,B<:BandedMatrix{T}} = banded_rmul!(A, Q)
rmul!(A::StridedVecOrMat{T}, adjQ::Adjoint{T,QRPackedQ{T,B}}) where {T<:BlasFloat,B<:BandedMatrix{T}} = banded_rmul!(A, adjQ)
rmul!(A::StridedVecOrMat{T}, adjQ::Adjoint{<:Any,QRPackedQ{T,B}}) where {T<:BlasComplex,B<:BandedMatrix{T}} = banded_rmul!(A, adjQ)
rmul!(A::StridedVecOrMat{T}, adjQ::Adjoint{<:Any,QRPackedQ{T,B}}) where {T<:BlasReal,B<:BandedMatrix{T}} = banded_rmul!(A, adjQ)


function _banded_widerect_ldiv!(A::QR{T}, B) where T
Expand Down
5 changes: 0 additions & 5 deletions src/banded/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ function ldiv!(A::BandedLU{T,<:BandedMatrix}, B::StridedVecOrMat{T}) where {T<:B
LAPACK.gbtrs!('N', l, u-l, m, data, A.ipiv, B)
end

function ldiv!(A::BandedLU, B::AbstractVecOrMat)
_apply_ipiv!(A, B)
ldiv!(UpperTriangular(A.factors), ldiv!(UnitLowerTriangular(A.factors), B))
end

function ldiv!(A::BandedLU{T}, B::AbstractVecOrMat{Complex{T}}) where T<:Real
# c2r = reshape(transpose(reinterpret(T, reshape(B, (1, length(B))))), size(B, 1), 2*size(B, 2))
a = real.(B)
Expand Down
3 changes: 3 additions & 0 deletions test/test_banded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ Base.similar(::MyMatrix, ::Type{T}, m::Int, n::Int) where T = MyMatrix{T}(undef,
@test size(similar(banded)) == size(banded)
@test similar(banded).l == banded.l
@test similar(banded).u == banded.u
@test @inferred(similar(banded,(5,5))) isa BandedMatrix{Int32, Matrix{Int32}}
@test @inferred(similar(banded,5,5)) isa BandedMatrix{Int32, Matrix{Int32}}
@test @inferred(similar(banded,5,5,1,1)) isa BandedMatrix{Int32, Matrix{Int32}}

banded = convert(BandedMatrix{<:, MyMatrix}, brand(Int32, 10, 12, 1, 2))
@test banded isa BandedMatrix{Int32, MyMatrix{Int32}}
Expand Down
48 changes: 25 additions & 23 deletions test/test_bandedqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,31 @@ end
end

@testset "lmul!/rmul!" begin
A = brand(100,100,3,4)
Q,R = qr(A)
x = randn(100)
b = randn(100,2)
@test lmul!(Q, copy(x)) Matrix(Q)*x
@test lmul!(Q, copy(b)) Matrix(Q)*b
@test lmul!(Q', copy(x)) Matrix(Q)'*x
@test lmul!(Q', copy(b)) Matrix(Q)'*b
c = randn(2,100)
@test rmul!(copy(c), Q) c*Matrix(Q)
@test rmul!(copy(c), Q') c*Matrix(Q')

A = brand(100,100,3,4)
Q,L = ql(A)
x = randn(100)
b = randn(100,2)
@test lmul!(Q, copy(x)) Matrix(Q)*x
@test lmul!(Q, copy(b)) Matrix(Q)*b
@test lmul!(Q', copy(x)) Matrix(Q)'*x
@test lmul!(Q', copy(b)) Matrix(Q)'*b
c = randn(2,100)
@test rmul!(copy(c), Q) c*Matrix(Q)
@test rmul!(copy(c), Q') c*Matrix(Q')
for T in (Float32, Float64, ComplexF32, ComplexF64)
A = brand(T,100,100,3,4)
Q,R = qr(A)
x = randn(T,100)
b = randn(T,100,2)
@test lmul!(Q, copy(x)) Matrix(Q)*x
@test lmul!(Q, copy(b)) Matrix(Q)*b
@test lmul!(Q', copy(x)) Matrix(Q)'*x
@test lmul!(Q', copy(b)) Matrix(Q)'*b
c = randn(T,2,100)
@test rmul!(copy(c), Q) c*Matrix(Q)
@test rmul!(copy(c), Q') c*Matrix(Q')

A = brand(T,100,100,3,4)
Q,L = ql(A)
x = randn(T,100)
b = randn(T,100,2)
@test lmul!(Q, copy(x)) Matrix(Q)*x
@test lmul!(Q, copy(b)) Matrix(Q)*b
@test lmul!(Q', copy(x)) Matrix(Q)'*x
@test lmul!(Q', copy(b)) Matrix(Q)'*b
c = randn(T,2,100)
@test rmul!(copy(c), Q) c*Matrix(Q)
@test rmul!(copy(c), Q') c*Matrix(Q')
end
end

@testset "Mixed types" begin
Expand Down
9 changes: 8 additions & 1 deletion test/test_linalg.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BandedMatrices, LazyArrays, LinearAlgebra, Test
using BandedMatrices, LazyArrays, LinearAlgebra, FillArrays, Test
import Base.Broadcast: materialize, broadcasted
import BandedMatrices: BandedMulAddStyle, BandedColumns
import LazyArrays: SymmetricLayout, MemoryLayout, Applied
Expand Down Expand Up @@ -243,5 +243,12 @@ import LazyArrays: SymmetricLayout, MemoryLayout, Applied
A = brand(10,10,1,1)
@test x'A x'Matrix(A) transpose(x)A
end

@testset "mismatched dimensions (#118)" begin
m = BandedMatrix(Eye(3), (0,0))
@test_throws DimensionMismatch m * [1,2]
@test_throws DimensionMismatch m * [1, 2, 3, 4]
@test_throws DimensionMismatch m \ [1, 2]
end
end

3 changes: 2 additions & 1 deletion test/test_symbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ end
y = F\b
@test x y
@test_throws DimensionMismatch F\[b;b]
@test det(F) det(SAL)

T  Float16 && (@test det(F) det(SAL))
end
for T in (Int16, Int32, Int64, BigInt)
A = BandedMatrix{T}(undef, (4,4), (1,1))
Expand Down

2 comments on commit 409aed0

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/2867

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.1 -m "<description of version>" 409aed0bbf17a72edd3566b396a6ed07b2a19251
git push origin v0.10.1

Please sign in to comment.