1
1
module LAPACK2
2
2
3
3
using Base. LinAlg: BlasInt, chkstride1, LAPACKException
4
+ using Base. LinAlg. BLAS: @blasfunc
4
5
using Base. LinAlg. LAPACK: chkuplo
5
6
6
7
# LAPACK wrappers
7
8
import Base. BLAS. @blasfunc
8
9
9
10
# # Standard QR/QL
10
- function steqr! (compz:: Char , d:: StridedVector{Float64} , e:: StridedVector{Float64} ,
11
- Z:: StridedMatrix{Float64} , work:: StridedVector{Float64} = compz == ' N' ? Vector {Float64} (0 ) :
12
- Vector {Float64} (max (1 , 2 n - 2 )))
11
+ function steqr! (compz:: Char ,
12
+ d:: StridedVector{Float64} ,
13
+ e:: StridedVector{Float64} ,
14
+ Z:: StridedMatrix{Float64} = compz == ' N' ? Matrix {Float64} (0 ,0 ) : Matrix {Float64} (length (d), length (d)),
15
+ work:: StridedVector{Float64} = compz == ' N' ? Vector {Float64} (0 ) : Vector {Float64} (max (1 , 2 * length (d) - 2 )))
13
16
14
17
# Extract sizes
15
18
n = length (d)
@@ -29,7 +32,7 @@ module LAPACK2
29
32
# Allocations
30
33
info = Vector {BlasInt} (1 )
31
34
32
- ccall ((" dsteqr_" , Base. liblapack_name),Void,
35
+ ccall ((@blasfunc ( " dsteqr_" ) , Base. liblapack_name),Void,
33
36
(Ptr{UInt8}, Ptr{BlasInt}, Ptr{Float64}, Ptr{Float64},
34
37
Ptr{Float64}, Ptr{BlasInt}, Ptr{Float64}, Ptr{BlasInt}),
35
38
& compz, & n, d, e,
@@ -51,7 +54,7 @@ module LAPACK2
51
54
# Allocations
52
55
info = BlasInt[0 ]
53
56
54
- ccall ((: dsterf_ , Base. liblapack_name), Void,
57
+ ccall ((@blasfunc ( " dsterf_" ) , Base. liblapack_name), Void,
55
58
(Ptr{BlasInt}, Ptr{Float64}, Ptr{Float64}, Ptr{BlasInt}),
56
59
& n, d, e, info)
57
60
@@ -61,7 +64,14 @@ module LAPACK2
61
64
end
62
65
63
66
# # Divide and Conquer
64
- function stedc! (compz:: Char , d:: StridedVector{Float64} , e:: StridedVector{Float64} , Z:: StridedMatrix{Float64} , work:: StridedVector{Float64} , lwork:: BlasInt , iwork:: StridedVector{BlasInt} , liwork:: BlasInt )
67
+ function stedc! (compz:: Char ,
68
+ d:: StridedVector{Float64} ,
69
+ e:: StridedVector{Float64} ,
70
+ Z:: StridedMatrix{Float64} ,
71
+ work:: StridedVector{Float64} ,
72
+ lwork:: BlasInt ,
73
+ iwork:: StridedVector{BlasInt} ,
74
+ liwork:: BlasInt )
65
75
66
76
# Extract sizes
67
77
n = length (d)
@@ -75,7 +85,7 @@ module LAPACK2
75
85
# Allocations
76
86
info = BlasInt[0 ]
77
87
78
- ccall ((@blasfunc (: dstedc_ ), Base. liblapack_name), Void,
88
+ ccall ((@blasfunc (" dstedc_" ), Base. liblapack_name), Void,
79
89
(Ptr{UInt8}, Ptr{BlasInt}, Ptr{Float64}, Ptr{Float64},
80
90
Ptr{Float64}, Ptr{BlasInt}, Ptr{Float64}, Ptr{BlasInt},
81
91
Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}),
@@ -88,7 +98,10 @@ module LAPACK2
88
98
return d, Z
89
99
end
90
100
91
- function stedc! (compz:: Char , d:: StridedVector{Float64} , e:: StridedVector{Float64} , Z:: StridedMatrix{Float64} )
101
+ function stedc! (compz:: Char ,
102
+ d:: StridedVector{Float64} ,
103
+ e:: StridedVector{Float64} ,
104
+ Z:: StridedMatrix{Float64} = compz == ' N' ? Matrix {Float64} (0 ,0 ) : Matrix {Float64} (length (d), length (d)))
92
105
93
106
work:: Vector{Float64} = Float64[0 ]
94
107
iwork:: Vector{BlasInt} = BlasInt[0 ]
@@ -105,7 +118,22 @@ module LAPACK2
105
118
# # RRR
106
119
for (lsymb, elty) in ((:dstemr_ , :Float64 ), (:sstemr_ , :Float32 ))
107
120
@eval begin
108
- function stemr! (jobz:: Char , range:: Char , dv:: StridedVector{$elty} , ev:: StridedVector{$elty} , vl:: $elty , vu:: $elty , il:: BlasInt , iu:: BlasInt , w:: StridedVector{$elty} , Z:: StridedMatrix{$elty} , nzc:: BlasInt , isuppz:: StridedVector{BlasInt} , work:: StridedVector{$elty} , lwork:: BlasInt , iwork:: StridedVector{BlasInt} , liwork:: BlasInt )
121
+ function stemr! (jobz:: Char ,
122
+ range:: Char ,
123
+ dv:: StridedVector{$elty} ,
124
+ ev:: StridedVector{$elty} ,
125
+ vl:: $elty ,
126
+ vu:: $elty ,
127
+ il:: BlasInt ,
128
+ iu:: BlasInt ,
129
+ w:: StridedVector{$elty} ,
130
+ Z:: StridedMatrix{$elty} ,
131
+ nzc:: BlasInt ,
132
+ isuppz:: StridedVector{BlasInt} ,
133
+ work:: StridedVector{$elty} ,
134
+ lwork:: BlasInt ,
135
+ iwork:: StridedVector{BlasInt} ,
136
+ liwork:: BlasInt )
109
137
110
138
# Extract sizes
111
139
n = length (dv)
@@ -115,7 +143,7 @@ module LAPACK2
115
143
length (ev) >= n - 1 || throw (DimensionMismatch (" subdiagonal is too short" ))
116
144
117
145
# Allocations
118
- eev:: Vector{$elty} = length (ev) == n - 1 ? [ev, zero ($ elty)] : copy (ev)
146
+ eev:: Vector{$elty} = length (ev) == n - 1 ? [ev; zero ($ elty)] : copy (ev)
119
147
abstol = Vector {$elty} (1 )
120
148
m = Vector {BlasInt} (1 )
121
149
tryrac = BlasInt[1 ]
@@ -130,7 +158,7 @@ module LAPACK2
130
158
& jobz, & range, & n, dv,
131
159
eev, & vl, & vu, & il,
132
160
& iu, m, w, Z,
133
- & ldz, & nzc, isuppz, tryrac,
161
+ & max ( 1 , ldz) , & nzc, isuppz, tryrac,
134
162
work, & lwork, iwork, & liwork,
135
163
info)
136
164
@@ -139,7 +167,15 @@ module LAPACK2
139
167
w, Z, tryrac[1 ]
140
168
end
141
169
142
- function stemr! (jobz:: Char , range:: Char , dv:: StridedVector{$elty} , ev:: StridedVector{$elty} , vl:: $elty = typemin ($ elty), vu:: $elty = typemax ($ elty), il:: BlasInt = 1 , iu:: BlasInt = length (dv))
170
+ function stemr! (jobz:: Char ,
171
+ range:: Char ,
172
+ dv:: StridedVector{$elty} ,
173
+ ev:: StridedVector{$elty} ,
174
+ vl:: $elty = typemin ($ elty),
175
+ vu:: $elty = typemax ($ elty),
176
+ il:: BlasInt = 1 ,
177
+ iu:: BlasInt = length (dv))
178
+
143
179
n = length (dv)
144
180
w = Vector {$elty} (n)
145
181
if jobz == ' N'
@@ -157,7 +193,7 @@ module LAPACK2
157
193
lwork:: BlasInt = - 1
158
194
iwork = BlasInt[0 ]
159
195
liwork:: BlasInt = - 1
160
- Z = Matrix {$elty} (1 , 1 )
196
+ Z = Matrix {$elty} (jobz == ' N ' ? 1 : n , 1 )
161
197
nzc = - 1
162
198
163
199
stemr! (jobz, range, dv, ev, vl, vu, il, iu, w, Z, nzc, isuppz, work, lwork, iwork, liwork)
0 commit comments