SPEED
GET_LEGENDRE_VALUE.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
29
30
31 subroutine get_legendre_value(p2,p2der,p1,p1der,n,x)
32
33 implicit real*8 (a-h,o-z)
34
35 p2 = 1.d0
36 p2der = 0.d0
37 if (n .eq. 0) return
38 p1 = p2
39 p2 = x
40 p1der = p2der
41 p2der = 1.d0
42 if (n .eq. 1) return
43 do k = 1, n-1
44 p0 = p1
45 p1 = p2
46 p0der = p1der
47 p1der = p2der
48 dk = dfloat(k)
49 a1 = (2.d0*dk+1.d0) / (dk+1.d0)
50 a2 = -dk / (dk+1.d0)
51 p2 = a1*p1*x + a2*p0
52 p2der = a1*p1 + a1*p1der*x + a2*p0der
53 enddo
54
55 return
56 end subroutine get_legendre_value
57
subroutine get_legendre_value(p2, p2der, p1, p1der, n, x)
Computes Legendre polynomial and its derivative on a given point x.