28
28
29
29
size (B:: Butterfly ) = size (B, 1 ), size (B, 2 )
30
30
31
- function Butterfly {T} (A:: AbstractMatrix{T} , L:: Int64 )
31
+ function Butterfly {T} (A:: AbstractMatrix{T} , L:: Int64 ; opts ... )
32
32
m, n = size (A)
33
33
tL = 2 ^ L
34
34
35
- LRAOpts = LRAOptions (T; rtol = eps (real (T))* max (m, n))
35
+ LRAOpts = LRAOptions (T; opts... )
36
+ LRAOpts. rtol = eps (real (T))* max (m, n)
36
37
37
38
columns = Vector {Matrix{T}} (tL)
38
39
factors = Vector {Vector{IDPackedV{T}}} (L+ 1 )
@@ -50,7 +51,7 @@ function Butterfly{T}(A::AbstractMatrix{T}, L::Int64)
50
51
nu = nd
51
52
indices[1 ][1 ] = 1
52
53
for j = 1 : tL
53
- factors[1 ][j] = idfact (view (A, :,nl: nu) , LRAOpts)
54
+ factors[1 ][j] = idfact (A[ :,nl: nu] , LRAOpts)
54
55
permutations[1 ][j] = factors[1 ][j][:P ]
55
56
indices[1 ][j+ 1 ] = indices[1 ][j] + size (factors[1 ][j], 1 )
56
57
cs[1 ][j] = factors[1 ][j]. sk+ nl- 1
@@ -74,7 +75,14 @@ function Butterfly{T}(A::AbstractMatrix{T}, L::Int64)
74
75
shft = 2 jj* div (ctr,2 jj)
75
76
for j = 1 : jj
76
77
cols = vcat (cs[l- 1 ][2 j- 1 + shft],cs[l- 1 ][2 j+ shft])
77
- factors[l][j+ ctr] = idfact (view (A, ml: mu, cols), LRAOpts)
78
+ lc = length (cols)
79
+ Av = A[ml: mu,cols]
80
+ if maximum (abs, Av) < realmin (real (T))/ eps (real (T))
81
+ factors[l][j+ ctr] = IDPackedV {T} (Int64[], collect (1 : lc), Array {T} (0 ,lc))
82
+ else
83
+ LRAOpts. rtol = eps (real (T))* max (length (ml: mu),lc)
84
+ factors[l][j+ ctr] = idfact (Av, LRAOpts)
85
+ end
78
86
permutations[l][j+ ctr] = factors[l][j+ ctr][:P ]
79
87
indices[l][j+ ctr+ 1 ] = indices[l][j+ ctr] + size (factors[l][j+ ctr], 1 )
80
88
cs[l][j+ ctr] = cols[factors[l][j+ ctr]. sk]
@@ -101,11 +109,12 @@ function Butterfly{T}(A::AbstractMatrix{T}, L::Int64)
101
109
Butterfly (columns, factors, permutations, indices, zeros (T, kk), zeros (T, kk), zeros (T, kk))
102
110
end
103
111
104
- function orthogonalButterfly {T} (A:: AbstractMatrix{T} , L:: Int64 )
112
+ function orthogonalButterfly {T} (A:: AbstractMatrix{T} , L:: Int64 ; opts ... )
105
113
m, n = size (A)
106
114
tL = 2 ^ L
107
115
108
- LRAOpts = LRAOptions (T; rtol = eps (real (T))* max (m, n))
116
+ LRAOpts = LRAOptions (T; opts... )
117
+ LRAOpts. rtol = eps (real (T))* max (m, n)
109
118
110
119
columns = Vector {Matrix{T}} (tL)
111
120
factors = Vector {Vector{IDPackedV{T}}} (L+ 1 )
@@ -147,7 +156,14 @@ function orthogonalButterfly{T}(A::AbstractMatrix{T}, L::Int64)
147
156
shft = 2 jj* div (ctr,2 jj)
148
157
for j = 1 : jj
149
158
cols = vcat (cs[l- 1 ][2 j- 1 + shft],cs[l- 1 ][2 j+ shft])
150
- factors[l][j+ ctr] = idfact (view (A, ml: mu, cols), LRAOpts)
159
+ lc = length (cols)
160
+ Av = A[ml: mu,cols]
161
+ if maximum (abs, Av) < realmin (real (T))/ eps (real (T))
162
+ factors[l][j+ ctr] = IDPackedV {T} (Int64[], collect (1 : lc), Array {T} (0 ,lc))
163
+ else
164
+ LRAOpts. rtol = eps (real (T))* max (length (ml: mu),lc)
165
+ factors[l][j+ ctr] = idfact (Av, LRAOpts)
166
+ end
151
167
permutations[l][j+ ctr] = factors[l][j+ ctr][:P ]
152
168
indices[l][j+ ctr+ 1 ] = indices[l][j+ ctr] + size (factors[l][j+ ctr], 1 )
153
169
cs[l][j+ ctr] = cols[factors[l][j+ ctr]. sk]
0 commit comments