11function LinearAlgebra. Array (A:: DerivativeOperator{T} , N:: Int = A. len) where T
22 L = zeros (T, N, N+ 2 )
33 bl = A. boundary_point_count
4- stl = A. stencil_length
4+ stencil_length = A. stencil_length
55 bstl = A. boundary_stencil_length
66 coeff = A. coefficients
7- stl_2 = div (stl,2 )
8- for i in 1 : A. boundary_point_count
7+
8+ if use_winding (A)
9+ stencil_pivot = 1 + A. stencil_length% 2
10+ else
11+ stencil_pivot = div (stencil_length,2 )
12+ end
13+
14+ for i in 1 : bl
915 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
1016 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (A. low_boundary_coefs[i]) : A. low_boundary_coefs[i]
1117 L[i,1 : bstl] = cur_coeff * cur_stencil
1218 end
19+
1320 for i in bl+ 1 : N- bl
1421 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
1522 stencil = eltype (A. stencil_coefs) <: AbstractVector ? A. stencil_coefs[i] : A. stencil_coefs
1623 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (stencil) : stencil
17- L[i,i+ 1 - stl_2 : i + 1 + stl_2 ] = cur_coeff * cur_stencil
24+ L[i,i+ 1 - stencil_pivot : i - stencil_pivot + stencil_length ] = cur_coeff * cur_stencil
1825 end
26+
1927 for i in N- bl+ 1 : N
2028 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
2129 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (A. high_boundary_coefs[i- N+ bl]) : A. high_boundary_coefs[i- N+ bl]
2735function SparseArrays. SparseMatrixCSC (A:: DerivativeOperator{T} , N:: Int = A. len) where T
2836 L = spzeros (T, N, N+ 2 )
2937 bl = A. boundary_point_count
30- stl = A. stencil_length
31- stl_2 = div (stl ,2 )
38+ stencil_length = A. stencil_length
39+ stencil_pivot = div (stencil_length ,2 )
3240 bstl = A. boundary_stencil_length
3341 coeff = A. coefficients
42+
43+ if use_winding (A)
44+ stencil_pivot = 1 + A. stencil_length% 2
45+ else
46+ stencil_pivot = div (stencil_length,2 )
47+ end
48+
3449 for i in 1 : A. boundary_point_count
3550 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
3651 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (A. low_boundary_coefs[i]) : A. low_boundary_coefs[i]
3752 L[i,1 : bstl] = cur_coeff * cur_stencil
3853 end
54+
3955 for i in bl+ 1 : N- bl
4056 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
4157 stencil = eltype (A. stencil_coefs) <: AbstractVector ? A. stencil_coefs[i] : A. stencil_coefs
4258 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (stencil) : stencil
43- L[i,i+ 1 - stl_2 : i + 1 + stl_2 ] = cur_coeff * cur_stencil
59+ L[i,i+ 1 - stencil_pivot : i - stencil_pivot + stencil_length ] = cur_coeff * cur_stencil
4460 end
61+
4562 for i in N- bl+ 1 : N
4663 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
4764 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (A. high_boundary_coefs[i- N+ bl]) : A. high_boundary_coefs[i- N+ bl]
5673
5774function BandedMatrices. BandedMatrix (A:: DerivativeOperator{T} , N:: Int = A. len) where T
5875 bl = A. boundary_point_count
59- stl = A. stencil_length
76+ stencil_length = A. stencil_length
6077 bstl = A. boundary_stencil_length
6178 coeff = A. coefficients
62- stl_2 = div (stl,2 )
63- L = BandedMatrix {T} (Zeros (N, N+ 2 ), (max (stl- 3 ,0 ,bstl),max (stl- 1 ,0 ,bstl)))
79+ if use_winding (A)
80+ stencil_pivot = 1 + A. stencil_length% 2
81+ else
82+ stencil_pivot = div (stencil_length,2 )
83+ end
84+ L = BandedMatrix {T} (Zeros (N, N+ 2 ), (max (stencil_length- 3 ,0 ,bstl),max (stencil_length- 1 ,0 ,bstl)))
85+
6486 for i in 1 : A. boundary_point_count
6587 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
6688 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (A. low_boundary_coefs[i]) : A. low_boundary_coefs[i]
@@ -70,7 +92,7 @@ function BandedMatrices.BandedMatrix(A::DerivativeOperator{T}, N::Int=A.len) whe
7092 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
7193 stencil = eltype (A. stencil_coefs) <: AbstractVector ? A. stencil_coefs[i] : A. stencil_coefs
7294 cur_stencil = use_winding (A) && cur_coeff < 0 ? reverse (stencil) : stencil
73- L[i,i+ 1 - stl_2 : i + 1 + stl_2 ] = cur_coeff * cur_stencil
95+ L[i,i+ 1 - stencil_pivot : i - stencil_pivot + stencil_length ] = cur_coeff * cur_stencil
7496 end
7597 for i in N- bl+ 1 : N
7698 cur_coeff = typeof (coeff) <: AbstractVector ? coeff[i] : coeff isa Number ? coeff : true
@@ -361,4 +383,4 @@ function BlockBandedMatrices.BandedBlockBandedMatrix(A::DerivativeOperator{T,N},
361383 B = Kron (BandedMatrix (Eye (n)), BandedMatrix (A))
362384 end
363385 return BandedBlockBandedMatrix (B)
364- end
386+ end
0 commit comments