Skip to content

Commit 7cec344

Browse files
authored
Update syntax for Julia 1.0 (#18)
* Update syntax for Julia 1.0 * Only test on 1.0+ * don't include BLAS
1 parent 4ebabc4 commit 7cec344

13 files changed

+126
-227
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
8-
- 0.7
97
- 1.0
8+
- 1.1
9+
- 1.2
10+
- 1.3
1011
- nightly
1112
matrix:
1213
allow_failures:

Project.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "HierarchicalMatrices"
2+
uuid = "7c893195-952b-5c83-bb6e-be12f22eed51"
3+
version = "0.2"
4+
5+
[deps]
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
8+
[compat]
9+
julia = "1"
10+
11+
[extras]
12+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
13+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
14+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
15+
16+
[targets]
17+
test = ["Test","Random","InteractiveUtils"]

REQUIRE

-2
This file was deleted.

appveyor.yml

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
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"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 1.1
4+
- julia_version: 1.2
5+
- julia_version: 1.3
6+
- julia_version: nightly
77

8+
platform:
9+
- x86 # 32-bit
10+
- x64 # 64-bit
11+
12+
# Uncomment the following lines to allow failures on nightly julia
13+
# (tests will run but not make your overall status red)
814
matrix:
915
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"
16+
- julia_version: nightly
1217

1318
branches:
1419
only:
@@ -22,24 +27,18 @@ notifications:
2227
on_build_status_changed: false
2328

2429
install:
25-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
26-
# If there's a newer build queued for the same PR, cancel this one
27-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
28-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
29-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
30-
throw "There are newer queued builds for this pull request, failing early." }
31-
# Download most recent Julia Windows binary
32-
- ps: (new-object net.webclient).DownloadFile(
33-
$env:JULIA_URL,
34-
"C:\projects\julia-binary.exe")
35-
# Run installer silently, output to C:\projects\julia
36-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
30+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3731

3832
build_script:
39-
# Need to convert from shallow to complete for Pkg.clone to work
40-
- IF EXIST .git\shallow (git fetch --unshallow)
41-
- C:\projects\julia\bin\julia -e "versioninfo();
42-
Pkg.clone(pwd(), \"HierarchicalMatrices\"); Pkg.build(\"HierarchicalMatrices\")"
33+
- echo "%JL_BUILD_SCRIPT%"
34+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4335

4436
test_script:
45-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"HierarchicalMatrices\")"
37+
- echo "%JL_TEST_SCRIPT%"
38+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
39+
40+
# # Uncomment to support code coverage upload. Should only be enabled for packages
41+
# # which would have coverage gaps without running on Windows
42+
# on_success:
43+
# - echo "%JL_CODECOV_SCRIPT%"
44+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/HierarchicalMatrices.jl

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__precompile__()
22
module HierarchicalMatrices
3-
using Compat, Compat.LinearAlgebra
3+
using LinearAlgebra
44

55
BLOCKRANK(T::Type{R}) where {R<:Real} = 2round(Int, half(T)*log(3+sqrt(T(8)), inv(eps(T))))
66
BLOCKRANK(T::Type{C}) where {C<:Complex} = BLOCKRANK(real(T))
@@ -11,10 +11,9 @@ module HierarchicalMatrices
1111
import Base: div, rem
1212
import Base: broadcast, Matrix, promote_op
1313
import Base: +, -, *, /, \, ==, !=
14-
import Compat.LinearAlgebra: Factorization, rank, norm, cond, istriu, istril, issymmetric, ishermitian,
15-
transpose
16-
import Compat: adjoint
17-
import Compat.LinearAlgebra.BLAS: @blasfunc, libblas, BlasInt, BlasFloat, BlasReal, BlasComplex
14+
import LinearAlgebra: Factorization, rank, norm, cond, istriu, istril, issymmetric, ishermitian,
15+
transpose, adjoint
16+
import LinearAlgebra.BLAS: @blasfunc, libblas, BlasInt, BlasFloat, BlasReal, BlasComplex
1817

1918
export BLOCKSIZE, BLOCKRANK, Block
2019
export AbstractLowRankMatrix, AbstractBarycentricMatrix
@@ -36,18 +35,7 @@ module HierarchicalMatrices
3635
two(x::Number) = oftype(x,2)
3736
two(::Type{T}) where {T<:Number} = convert(T, 2)
3837

39-
if VERSION < v"0.7-"
40-
mul!(args...) = Base.A_mul_B!(args...)
41-
for op in (:At_mul_B!, :Ac_mul_B!, :scale!)
42-
@eval begin
43-
$op(args...) = Base.$op(args...)
44-
end
45-
end
46-
else
47-
mul!(args...) = LinearAlgebra.mul!(args...)
48-
end
49-
50-
const A_mul_B! = mul!
38+
mul!(args...) = LinearAlgebra.mul!(args...)
5139

5240
include("LowRankMatrix.jl")
5341
include("BarycentricMatrix.jl")

src/HierarchicalMatrix.jl

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@hierarchical HierarchicalMatrix LowRankMatrix Matrix
22

33

4-
import Compat.LinearAlgebra: matprod
4+
import LinearAlgebra: matprod
55
function (*)(H::AbstractHierarchicalMatrix{T}, x::AbstractVector{S}) where {T,S}
66
TS = promote_op(matprod, T, S)
77
mul!(zeros(TS, size(H, 1)), H, x)
@@ -11,17 +11,10 @@ function (*)(H::AbstractHierarchicalMatrix{T}, x::AbstractMatrix{S}) where {T,S}
1111
mul!(zeros(TS, size(H, 1), size(x, 2)), H, x)
1212
end
1313

14+
LinearAlgebra.mul!(y::AbstractVecOrMat, H::AbstractHierarchicalMatrix, x::AbstractVecOrMat) = mul!(y, H, x, 1, 1)
15+
LinearAlgebra.rmul!(H::AbstractHierarchicalMatrix, b::Diagonal) = scale!(H, b.diag, 1)
16+
LinearAlgebra.lmul!(b::Diagonal, H::AbstractHierarchicalMatrix) = scale!(b.diag, H, 1)
1417

15-
if VERSION < v"0.7-"
16-
Base.A_mul_B!(y::AbstractVecOrMat, H::AbstractHierarchicalMatrix, x::AbstractVecOrMat) = mul!(y, H, x, 1, 1)
17-
Base.scale!(H::AbstractHierarchicalMatrix, b::AbstractVector) = scale!(H, b, 1)
18-
Base.scale!(b::AbstractVector, H::AbstractHierarchicalMatrix) = scale!(b, H, 1)
19-
else
20-
LinearAlgebra.mul!(y::AbstractVecOrMat, H::AbstractHierarchicalMatrix, x::AbstractVecOrMat) = mul!(y, H, x, 1, 1)
21-
LinearAlgebra.rmul!(H::AbstractHierarchicalMatrix, b::Diagonal) = scale!(H, b.diag, 1)
22-
LinearAlgebra.lmul!(b::Diagonal, H::AbstractHierarchicalMatrix) = scale!(b.diag, H, 1)
23-
24-
end
2518

2619
mul!(y::AbstractVecOrMat, H::AbstractHierarchicalMatrix, x::AbstractVecOrMat, istart::Int, jstart::Int) = mul!(y, H, x, istart, jstart, 1, 1)
2720

src/KernelMatrix.jl

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@hierarchical KernelMatrix BarycentricMatrix2D Matrix
22

33

4-
import Compat.LinearAlgebra: matprod
4+
import LinearAlgebra: matprod
55
function (*)(H::AbstractKernelMatrix{T}, x::AbstractVector{S}) where {T,S}
66
TS = promote_op(matprod, T, S)
77
mul!(zeros(TS, size(H, 1)), H, x)
@@ -11,11 +11,8 @@ function (*)(H::AbstractKernelMatrix{T}, x::AbstractMatrix{S}) where {T,S}
1111
mul!(zeros(TS, size(H, 1), size(x, 2)), H, x)
1212
end
1313

14-
if VERSION < v"0.7-"
15-
Base.A_mul_B!(u::Vector, H::AbstractKernelMatrix, v::AbstractVector) = mul!(u, H, v, 1, 1)
16-
else
17-
LinearAlgebra.mul!(u::Vector, H::AbstractKernelMatrix, v::AbstractVector) = mul!(u, H, v, 1, 1)
18-
end
14+
LinearAlgebra.mul!(u::Vector, H::AbstractKernelMatrix, v::AbstractVector) = mul!(u, H, v, 1, 1)
15+
1916

2017
@generated function mul!(u::Vector{S}, H::KernelMatrix{S}, v::AbstractVector{S}, istart::Int, jstart::Int) where S
2118
L = length(fieldnames(H))-1

src/LowRankMatrix.jl

+10-27
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,19 @@ threadsafeones(::Type{T}, n::Integer) where T = ThreadSafeVector{T}(ones(T, n, T
1818

1919
abstract type AbstractLowRankMatrix{T} <: AbstractMatrix{T} end
2020

21-
if VERSION < v"0.7-"
22-
"""
23-
Store the singular value decomposition of a matrix:
24-
25-
A = UΣV'
26-
27-
"""
28-
struct LowRankMatrix{T} <: AbstractLowRankMatrix{T}
29-
U::Matrix{T}
30-
Σ::Diagonal{T}
31-
V::Matrix{T}
32-
temp::ThreadSafeVector{T}
33-
end
34-
else
35-
"""
36-
Store the singular value decomposition of a matrix:
37-
38-
A = UΣV'
39-
40-
"""
41-
struct LowRankMatrix{T} <: AbstractLowRankMatrix{T}
42-
U::Matrix{T}
43-
Σ::Diagonal{T, Vector{T}}
44-
V::Matrix{T}
45-
temp::ThreadSafeVector{T}
46-
end
47-
end
4821

22+
"""
23+
Store the singular value decomposition of a matrix:
4924
25+
A = UΣV'
5026
27+
"""
28+
struct LowRankMatrix{T} <: AbstractLowRankMatrix{T}
29+
U::Matrix{T}
30+
Σ::Diagonal{T, Vector{T}}
31+
V::Matrix{T}
32+
temp::ThreadSafeVector{T}
33+
end
5134

5235
LowRankMatrix(U::Matrix{T}, Σ::Diagonal{T}, V::Matrix{T}) where T = LowRankMatrix(U, Σ, V, threadsafezeros(T, length.diag)))
5336

src/algebra.jl

+7-9
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ function mul!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecOrMat{
4747
y
4848
end
4949

50-
At_mul_B!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where T = At_mul_B!(y, A, x, istart, jstart, 1, 1)
50+
mul!(y::AbstractVecOrMat{T}, At::Transpose{T,<:AbstractMatrix{T}}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where T = mul!(y, At, x, istart, jstart, 1, 1)
5151

52-
function At_mul_B!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int, INCX::Int, INCY::Int) where T
52+
function mul!(y::AbstractVecOrMat{T}, At::Transpose{T,<:AbstractMatrix{T}}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int, INCX::Int, INCY::Int) where T
53+
A = parent(At)
5354
m, n = size(A)
5455
ishift, jshift = istart-INCY, jstart-INCX
5556
@inbounds for i = 1:n
@@ -63,9 +64,10 @@ function At_mul_B!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecO
6364
y
6465
end
6566

66-
Ac_mul_B!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where T = Ac_mul_B!(y, A, x, istart, jstart, 1, 1)
67+
mul!(y::AbstractVecOrMat{T}, Ac::Adjoint{T,<:AbstractMatrix{T}}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where T = mul!(y, Ac, x, istart, jstart, 1, 1)
6768

68-
function Ac_mul_B!(y::AbstractVecOrMat{T}, A::AbstractMatrix{T}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int, INCX::Int, INCY::Int) where T
69+
function mul!(y::AbstractVecOrMat{T}, Ac::Adjoint{T,<:AbstractMatrix{T}}, x::AbstractVecOrMat{T}, istart::Int, jstart::Int, INCX::Int, INCY::Int) where T
70+
A = parent(Ac)
6971
m, n = size(A)
7072
ishift, jshift = istart-INCY, jstart-INCX
7173
@inbounds for i = 1:n
@@ -109,11 +111,7 @@ function mul!(y::AbstractVecOrMat{T}, L::LowRankMatrix{T}, x::AbstractVecOrMat{T
109111
end
110112

111113
# BLAS'ed
112-
if VERSION < v"0.7-"
113-
#include("blas06.jl")
114-
else
115-
#include("blas.jl")
116-
end
114+
# include("blas.jl")
117115

118116
# BarycentricMatrix
119117

src/blas.jl

+45-29
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,60 @@
1-
for (f!, char) in ((:mul!, 'N'),
2-
(:At_mul_B!, 'T'),
3-
(:Ac_mul_B!, 'C'))
4-
for (fname, elty) in ((:dgemv_, :Float64),
5-
(:sgemv_, :Float32),
6-
(:zgemv_, :Complex128),
7-
(:cgemv_, :Complex64))
8-
@eval begin
9-
function $f!(y::VecOrMat{$elty}, A::Matrix{$elty}, x::VecOrMat{$elty}, istart::Int, jstart::Int, INCX::Int, INCY::Int)
10-
ccall((@blasfunc($fname), libblas), Void,
11-
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
12-
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
13-
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
14-
$char, size(A,1), size(A,2), $elty(1.0),
15-
A, max(1,stride(A,2)), pointer(x, jstart), INCX,
16-
$elty(1.0), pointer(y, istart), INCY)
17-
y
18-
end
1+
for (fname, elty) in ((:dgemv_, :Float64),
2+
(:sgemv_, :Float32),
3+
(:zgemv_, :ComplexF64),
4+
(:cgemv_, :ComplexF32))
5+
@eval begin
6+
function mul!(y::VecOrMat{$elty}, A::Matrix{$elty}, x::VecOrMat{$elty}, istart::Int, jstart::Int, INCX::Int, INCY::Int)
7+
ccall((@blasfunc($fname), libblas), Nothing,
8+
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
9+
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
10+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
11+
'N', size(A,1), size(A,2), $elty(1.0),
12+
A, max(1,stride(A,2)), pointer(x, jstart), INCX,
13+
$elty(1.0), pointer(y, istart), INCY)
14+
y
15+
end
16+
function mul!(y::VecOrMat{$elty}, At::Transpose{$elty,Matrix{$elty}}, x::VecOrMat{$elty}, istart::Int, jstart::Int, INCX::Int, INCY::Int)
17+
A = parent(At)
18+
ccall((@blasfunc($fname), libblas), Nothing,
19+
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
20+
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
21+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
22+
'T', size(A,1), size(A,2), $elty(1.0),
23+
A, max(1,stride(A,2)), pointer(x, jstart), INCX,
24+
$elty(1.0), pointer(y, istart), INCY)
25+
y
1926
end
27+
function mul!(y::VecOrMat{$elty}, Ac::Adjoint{$elty,Matrix{$elty}}, x::VecOrMat{$elty}, istart::Int, jstart::Int, INCX::Int, INCY::Int)
28+
A = parent(Ac)
29+
ccall((@blasfunc($fname), libblas), Nothing,
30+
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
31+
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
32+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
33+
'C', size(A,1), size(A,2), $elty(1.0),
34+
A, max(1,stride(A,2)), pointer(x, jstart), INCX,
35+
$elty(1.0), pointer(y, istart), INCY)
36+
y
37+
end
2038
end
2139
end
2240

2341

24-
25-
2642
for (fname, elty) in ((:dgemv_,:Float64),
2743
(:sgemv_,:Float32),
28-
(:zgemv_,:Complex128),
29-
(:cgemv_,:Complex64))
44+
(:zgemv_,:ComplexF64),
45+
(:cgemv_,:ComplexF32))
3046
@eval begin
3147
function mul!(y::VecOrMat{$elty}, L::LowRankMatrix{$elty}, x::VecOrMat{$elty}, istart::Int, jstart::Int, INCX::Int, INCY::Int)
3248
fill!(L.temp, zero($elty))
33-
ccall((@blasfunc($fname), libblas), Void,
49+
ccall((@blasfunc($fname), libblas), Nothing,
3450
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
3551
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
3652
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
3753
'T', size(L,2), rank(L), $elty(1.0),
3854
L.V, max(1,stride(L.V,2)), pointer(x, jstart), INCX,
3955
$elty(1.0), L.temp, 1)
4056
unsafe_broadcasttimes!(L.temp, L.Σ.diag)
41-
ccall((@blasfunc($fname), libblas), Void,
57+
ccall((@blasfunc($fname), libblas), Nothing,
4258
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
4359
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
4460
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
@@ -55,27 +71,27 @@ end
5571

5672
for (fname, elty) in ((:dgemv_,:Float64),
5773
(:sgemv_,:Float32),
58-
(:zgemv_,:Complex128),
59-
(:cgemv_,:Complex64))
74+
(:zgemv_,:ComplexF64),
75+
(:cgemv_,:ComplexF32))
6076
@eval begin
6177
function mul!(u::Vector{$elty}, B::BarycentricMatrix2D{$elty}, v::Vector{$elty}, istart::Int, jstart::Int)
6278
fill!(B.temp1, zero($elty))
63-
ccall((@blasfunc($fname), libblas), Void,
79+
ccall((@blasfunc($fname), libblas), Nothing,
6480
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
6581
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
6682
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
6783
'T', size(B.V,1), size(B.V,2), $elty(1.0),
6884
B.V, max(1,stride(B.V,2)), pointer(v, jstart), 1,
6985
$elty(1.0), B.temp1, 1)
7086
fill!(B.temp2, zero($elty))
71-
ccall((@blasfunc($fname), libblas), Void,
87+
ccall((@blasfunc($fname), libblas), Nothing,
7288
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
7389
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
7490
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
7591
'N', size(B.B.F,1), size(B.B.F,2), $elty(1.0),
7692
B.B.F, max(1,stride(B.B.F,2)), B.temp1, 1,
7793
$elty(1.0), B.temp2, 1)
78-
ccall((@blasfunc($fname), libblas), Void,
94+
ccall((@blasfunc($fname), libblas), Nothing,
7995
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
8096
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
8197
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),

0 commit comments

Comments
 (0)