Skip to content

Commit

Permalink
boundschecks fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
milankl committed Oct 21, 2024
1 parent 628c860 commit db4b46c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/SpeedyTransforms/legendre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
isoddlmax = isodd(length(lmax))
lmax_even = length(lmax) - isoddlmax # if lmax is odd do last odd element after the loop

@boundscheck axes(north) == axes(south) || throw(DimensionMismatch)
@boundscheck axes(specs, 1) == axes(legendre) || throw(DimensionMismatch)
@boundscheck axes(specs, 2) <= axes(north) || throw(DimensionMismatch)
@boundscheck size(north) == size(south) || throw(DimensionMismatch)
@boundscheck size(specs, 1) == length(legendre) || throw(DimensionMismatch)
@boundscheck size(specs, 2) <= length(north) || throw(DimensionMismatch)

@inbounds for k in nlayers
# "even" and "odd" coined with 0-based indexing, i.e. the even l=0 mode is 1st element
Expand Down Expand Up @@ -91,7 +91,7 @@ function _legendre!(
end

# (forward) Legendre kernel, called from _legendre!
function _fused_oddeven_outer_product_accumulate!(
@inline function _fused_oddeven_outer_product_accumulate!(
specs::AbstractMatrix, # output, accumulated spherical harmonic coefficients
legendre::AbstractVector, # input, Legendre polynomials
even::AbstractVector, # input, even harmonics
Expand All @@ -101,6 +101,10 @@ function _fused_oddeven_outer_product_accumulate!(
isoddlmax = isodd(lmax)
lmax_even = lmax - isoddlmax

@boundscheck size(odd) == size(even) || throw(DimensionMismatch)
@boundscheck size(specs, 1) == length(legendre) || throw(DimensionMismatch)
@boundscheck size(specs, 2) <= length(even) || throw(DimensionMismatch)

@inbounds for k in 1:nlayers
even_k, odd_k = even[k], odd[k]
for l in 1:2:lmax_even
Expand Down

0 comments on commit db4b46c

Please sign in to comment.