using (faster) Horner evaluation

https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation
This commit is contained in:
Martin Diehl 2022-05-08 13:32:14 +02:00
parent 72c29f744c
commit 240426402c
1 changed files with 3 additions and 3 deletions

View File

@ -105,9 +105,9 @@ pure function eval(self,x) result(y)
integer :: i
y = self%coef(0)
do i = 1, ubound(self%coef,1)
y = y + self%coef(i) * (x-self%x_ref)**i
y = 0.0_pReal
do i = ubound(self%coef,1), 0 , -1
y = y*(x-self%x_ref) + self%coef(i)
enddo
end function eval