Skip to content

Commit 239fcfb

Browse files
committed
use SparseArrays
1 parent 50fdbd1 commit 239fcfb

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1212
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
1313
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1414
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
15+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1516
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1617
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1718
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

src/MultipleScattering.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export scattering_matrix
4848

4949
import Printf: @printf
5050

51+
using SparseArrays: sparse
5152
using StaticArrays: SVector
5253
using OffsetArrays: OffsetArray
5354

src/physics/special_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ A version of the Gaunt coefficients which are used to write the product of two s
183183
184184
gaunt_coefficient(l1,m1,l2,m2,l3,m3) = 4*π*im^{l2+l3-l1} Integral[Y_{l1,m1}*conj(Y_{l2,m2})*conj(Y_{l3,m3})]
185185
186-
where the integral is over the solid angle.
186+
where the integral is over the solid angle. In the papers by Art Gower, this symbol is denoted by `c_{(l1,m1),(l2,m2)(l3,m3)}`.
187187
188188
The most standard gaunt coefficients `G(l1,m1;l2,m2;l3)` are related through the identity:
189189

src/scattering_matrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function scattering_matrix(medium::PhysicalMedium, particles::AbstractParticles,
1616
# Faire: this could potentially return an MMatrix
1717
function S_block(j,l)
1818
if j == l
19-
return zeros(Complex{T}, N, N)
19+
return sparse(zeros(Complex{T}, N, N))
2020
else
2121
x_lj = origin(particles[j]) .- origin(particles[l])
2222
U = outgoing_translation_matrix(medium, basis_order, basis_order, ω, x_lj)
@@ -28,7 +28,7 @@ function scattering_matrix(medium::PhysicalMedium, particles::AbstractParticles,
2828
S_blocks = [S_block(j,l) for j in 1:P, l in 1:P]
2929

3030
# Reshape S_blocks into big matrix
31-
S = zeros(Complex{T}, P*N, P*N)
31+
S = sparse(zeros(Complex{T}, P*N, P*N))
3232
for i in 1:P
3333
for j in 1:P
3434
S[((i-1)*N+1):(i*N), ((j-1)*N+1):(j*N)] .= S_blocks[i,j]

src/source.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ struct PlaneSource{T<:Real,Dim,FieldDim,P<:PhysicalMedium} <: AbstractSource{P}
3737
end
3838

3939
field(s::PlaneSource{T}) where T = function (x::AbstractArray{T}, ω::T)
40-
s.amplitude * exp(im */ s.medium.c) * dot(x - s.position,s.direction))
41-
end
40+
s.amplitude * exp(im */ s.medium.c) * dot(x - s.position,s.direction))
41+
end
4242

4343
field(s::PlaneSource{T,Dim,1}) where {T, Dim} = function (x::AbstractArray{T}, ω::T)
44-
s.amplitude[1] * exp(im */ s.medium.c) * dot(x - s.position,s.direction))
45-
end
44+
s.amplitude[1] * exp(im */ s.medium.c) * dot(x - s.position,s.direction))
45+
end
4646

4747
field(s::PlaneSource{T}, x::AbstractArray{T}, ω::T) where T = field(s)(x,ω)
4848

0 commit comments

Comments
 (0)