JanJereczek / FastIsostasy.jl

Accelerated computation of glacial isostatic adjustment for laterally-variable solid-Earth
GNU General Public License v3.0
9 stars 0 forks source link

Replace large divisions by inverse multiplications #112

Closed JanJereczek closed 2 months ago

JanJereczek commented 4 months ago

For instance, currently:

RHS .= term ./ kappa

New:

_kappa = 1./kappa    # at init only
RHS .= term .* kappa

Can improve performance without any effort.

JanJereczek commented 2 months ago
A = rand(700, 700)
A_ = 1 ./ A

@btime 3.0 ./ $A
  290.679 μs (2 allocations: 3.74 MiB)

@btime 3.0 .* $A_
  283.003 μs (2 allocations: 3.74 MiB)

Only minor improvement. Not applying this change in favor of more legible code.