1- import  Base. LinAlg. LAPACK:  chkstride1, chkuplo, BlasInt, liblapack
1+ import  LinearAlgebra. LAPACK:  chkstride1, chkuplo, BlasInt, liblapack
2+ import  LinearAlgebra. BLAS:  @blasfunc 
23
3- 
4- immutable ReinschQ{T} <:  AbstractMatrix{T} 
4+ struct  ReinschQ{T} <:  AbstractMatrix{T} 
55    h:: Vector{T} 
66end 
77
@@ -10,7 +10,7 @@ function Base.size(Q::ReinschQ)
1010   (n+ 1 , n- 1 )
1111end 
1212
13- function  Base. getindex {T} (Q:: ReinschQ{T} ,i:: Int ,j:: Int )
13+ function  Base. getindex (Q:: ReinschQ{T} ,i:: Int ,j:: Int )  where  T 
1414    h =  Q. h
1515    if  (i ==  j)
1616        1 / h[i]
@@ -23,7 +23,7 @@ function Base.getindex{T}(Q::ReinschQ{T},i::Int,j::Int)
2323    end 
2424end 
2525
26- function  Base . LinAlg . At_mul_B! (out:: AbstractVector , Q:: ReinschQ , g:: AbstractVector )
26+ function  LinearAlgebra . At_mul_B! (out:: AbstractVector , Q:: ReinschQ , g:: AbstractVector )
2727    n =  length (out)
2828    h =  Q. h
2929    n ==  size (Q,2 ) ||  throw (DimensionMismatch ())
@@ -37,7 +37,7 @@ function Base.LinAlg.At_mul_B!(out::AbstractVector, Q::ReinschQ, g::AbstractVect
3737    out
3838end 
3939
40- function  Base . LinAlg . A_mul_B! (out:: AbstractVector , Q:: ReinschQ , g:: AbstractVector )
40+ function  LinearAlgebra . A_mul_B! (out:: AbstractVector , Q:: ReinschQ , g:: AbstractVector )
4141    n =  length (out)
4242    n ==  size (Q,1 ) ||  throw (DimensionMismatch ())
4343    length (g) ==  size (Q,2 ) ||  throw (DimensionMismatch ())
@@ -51,7 +51,7 @@ function Base.LinAlg.A_mul_B!(out::AbstractVector, Q::ReinschQ, g::AbstractVecto
5151end 
5252
5353
54- immutable  ReinschR{T} <:  AbstractMatrix{T} 
54+ struct  ReinschR{T} <:  AbstractMatrix{T} 
5555    h:: Vector{T} 
5656end 
5757
@@ -60,7 +60,7 @@ function Base.size(R::ReinschR)
6060   (n- 1 , n- 1 )
6161end 
6262
63- function  Base. getindex {T} (R:: ReinschR{T} , i:: Int , j:: Int )
63+ function  Base. getindex (R:: ReinschR{T} , i:: Int , j:: Int )  where  T 
6464    #  TODO : add check bounds
6565    h =  R. h
6666    if  (i== j)
@@ -72,7 +72,7 @@ function Base.getindex{T}(R::ReinschR{T}, i::Int, j::Int)
7272    end 
7373end 
7474
75- function  QtQpR {T<:Real} (h:: AbstractVector{T} , α:: T , w:: AbstractVector{T} = ones (T, length (h)+ 1 ))
75+ function  QtQpR (h:: AbstractVector{T} , α:: T , w:: AbstractVector{T} = ones (T, length (h)+ 1 ))  where  T <: Real 
7676    #  maybe has some redundant calculations but should be good enough for now
7777    n =  length (h)- 1 
7878    Q =  ReinschQ (h)
@@ -97,23 +97,12 @@ function QtQpR{T<:Real}(h::AbstractVector{T}, α::T, w::AbstractVector{T}=ones(T
9797    out
9898end 
9999
100- #  temporary hack to use LAPACK wrapper,
101- #  as in
102- #  https://github.com/ApproxFun/BandedMatrices.jl/blob/master/src/blas.jl
103- if  VERSION  <  v " 0.5.0-dev" 
104-     macro  blasfunc (x)
105-        return  :( $ (BLAS. blasfunc (x) ))
106-     end 
107- else 
108-     import  Base. BLAS. @blasfunc 
109- end 
110- 
111100
112101for  (pbtrf, pbtrs, elty) in 
113102    ((:dpbtrf_ ,:dpbtrs_ ,:Float64 ),
114103     (:spbtrf_ ,:spbtrs_ ,:Float32 ),
115-      (:zpbtrf_ ,:zpbtrs_ ,:Complex128  ),
116-      (:cpbtrf_ ,:cpbtrs_ ,:Complex64  ))
104+      (:zpbtrf_ ,:zpbtrs_ ,:ComplexF64  ),
105+      (:cpbtrf_ ,:cpbtrs_ ,:ComplexF32  ))
117106    @eval  begin 
118107        #  SUBROUTINE DPBTRF( UPLO, N, KD, AB, LDAB, INFO )
119108        #  *     .. Scalar Arguments ..
@@ -127,10 +116,10 @@ for (pbtrf, pbtrs, elty) in
127116            chkstride1 (AB)
128117            n    =  size (AB, 2 )
129118            info =  Ref {BlasInt} ()
130-             ccall ((@blasfunc ($ pbtrf), liblapack), Void ,
131-                   (Ptr {UInt8}, Ptr {BlasInt}, Ptr {BlasInt},
132-                    Ptr{$ elty}, Ptr {BlasInt}, Ptr {BlasInt}),
133-                    & uplo, & n, & kd, AB, & max (1 ,stride (AB,2 )), info)
119+             ccall ((@blasfunc ($ pbtrf), liblapack), Cvoid ,
120+                   (Ref {UInt8}, Ref {BlasInt}, Ref {BlasInt},
121+                    Ptr{$ elty}, Ref {BlasInt}, Ref {BlasInt}),
122+                    uplo, n, kd, AB, max (1 ,stride (AB,2 )), info)
134123            AB
135124        end 
136125
@@ -150,12 +139,12 @@ for (pbtrf, pbtrs, elty) in
150139            if  n !=  size (B,1 )
151140                throw (DimensionMismatch (" Matrix AB has dimensions $(size (AB)) , but right hand side matrix B has dimensions $(size (B)) "  ))
152141            end 
153-             ccall ((@blasfunc ($ pbtrs), liblapack), Void ,
154-                   (Ptr {UInt8}, Ptr {BlasInt}, Ptr {BlasInt},  Ptr {BlasInt},
155-                    Ptr{$ elty}, Ptr {BlasInt}, Ptr{$ elty},   Ptr {BlasInt},
156-                    Ptr {BlasInt}),
157-                   & uplo, & n, & kd, & size (B,2 ), AB,  & max (1 ,stride (AB,2 )),
158-                   B, & max (1 ,stride (B,2 )), info)
142+             ccall ((@blasfunc ($ pbtrs), liblapack), Cvoid ,
143+                   (Ref {UInt8}, Ref {BlasInt}, Ref {BlasInt},  Ref {BlasInt},
144+                    Ptr{$ elty}, Ref {BlasInt}, Ptr{$ elty},   Ref {BlasInt},
145+                    Ref {BlasInt}),
146+                   uplo, n, kd, size (B,2 ), AB,  max (1 ,stride (AB,2 )),
147+                   B, max (1 ,stride (B,2 )), info)
159148            B
160149        end 
161150    end 
0 commit comments