From db4b46ccfdc3723dda54bae6642d97a71c8a7d76 Mon Sep 17 00:00:00 2001 From: Milan Date: Mon, 21 Oct 2024 15:21:20 +0100 Subject: [PATCH] boundschecks fixed --- src/SpeedyTransforms/legendre.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SpeedyTransforms/legendre.jl b/src/SpeedyTransforms/legendre.jl index b0e72de3c..06e7dd5e1 100644 --- a/src/SpeedyTransforms/legendre.jl +++ b/src/SpeedyTransforms/legendre.jl @@ -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 @@ -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 @@ -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