Skip to content

Commit 667a690

Browse files
committed
minor performance improvements
1 parent c5e1d42 commit 667a690

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ julia> dPl!(P,0.5)
145145
0.0 0.375 0.0
146146
```
147147

148-
Note that the column number that will be populated depends on the order of the derivative, assuming 0-based indexing. Therefore `Pl!` will fill column 0, `dPl!` will fill columnn 1 and `d2Pl!` will fill column 2. Combinations of these will fill multiple columns as expected.
148+
Note that the column number that will be populated depends on the order of the derivative, assuming 0-based indexing. Therefore `Pl!` will fill column 0, `dPl!` will fill column 1 and `d2Pl!` will fill column 2. Combinations of these will fill multiple columns as expected.
149149

150150
# License
151151

src/LegendrePolynomials.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ It defaults to lmax = maximum(axes(arr,1))
309309
function dPl!(arr::AbstractVector{<:Real},x::Real;lmax::Integer=maximum(axes(arr,1)))
310310
P = zeros(axes(arr,1),0:1)
311311
Pl_dPl_d2Pl!(P,x;lmax=lmax)
312-
@inbounds @. arr[:] = P[:,1]
312+
@views @. arr = P[:,1]
313313
arr
314314
end
315315

316316
function dPl!(arr::AbstractMatrix{<:Real},x::Real;
317317
lmax::Integer=maximum(axes(arr,1)))
318318
P = zeros(axes(arr,1),0:1)
319319
Pl_dPl_d2Pl!(P,x;lmax=lmax)
320-
@inbounds @. arr[:,1] = P[:,1]
320+
@views @. arr[:,1] = P[:,1]
321321
arr
322322
end
323323

@@ -358,15 +358,15 @@ It defaults to lmax = maximum(axes(arr,1))
358358
function d2Pl!(arr::AbstractVector{<:Real},x::Real;lmax::Integer=maximum(axes(arr,1)))
359359
P = zeros(axes(arr,1),0:2)
360360
Pl_dPl_d2Pl!(P,x;lmax=lmax)
361-
@. arr[:] = P[:,2]
361+
@views @. arr = P[:,2]
362362
arr
363363
end
364364

365365
function d2Pl!(arr::AbstractMatrix{<:Real},
366366
x::Real;lmax::Integer=maximum(axes(arr,1)))
367367
P = zeros(axes(arr,1),0:2)
368368
Pl_dPl_d2Pl!(P,x;lmax=lmax)
369-
@. arr[:,2] = P[:,2]
369+
@views @. arr[:,2] = P[:,2]
370370
arr
371371
end
372372

@@ -391,8 +391,7 @@ function dPl_d2Pl!(arr::AbstractMatrix{<:Real},x::Real;
391391
P = zeros(axes(arr,1),0:2)
392392
Pl_dPl_d2Pl!(P,x;lmax=lmax)
393393

394-
@. arr[:,1] = P[:,1]
395-
@. arr[:,2] = P[:,2]
394+
@views @. arr[:,1:2] = P[:,1:2]
396395

397396
arr
398397
end
@@ -418,8 +417,8 @@ function Pl_d2Pl!(arr::AbstractMatrix{<:Real},x::Real;
418417
P = zeros(axes(arr,1),0:2)
419418
Pl_dPl_d2Pl!(P,x;lmax=lmax)
420419

421-
@. arr[:,0] = P[:,0]
422-
@. arr[:,2] = P[:,2]
420+
@views @. arr[:,0] = P[:,0]
421+
@views @. arr[:,2] = P[:,2]
423422

424423
arr
425424
end

0 commit comments

Comments
 (0)