NLSL: fmomnt.f90 Source File

NLSL

- Main Page
- Modules
- Data Types List
- Files

- File List
- File Members

fmomnt.f90
Go to the documentation of this file.
1 c NLSL Version 1.4 10/10/94
2 c----------------------------------------------------------------------
3 c =========================
4 c function FMOMNT
5 c =========================
6 c
7 c Returns the first moment of a tabulated function in index units
8 c (first x-value is 1, second is 2, etc.). If f is tabulated as zeroth
9 c derivative data, the first moment is defined as
10 c
11 c intgrl[ x*f(x) dx ] / intgrl[ f(x) dx ]
12 c
13 c If f is first derivative, the first moment returned is
14 c
15 c intgrl[ x* intgrl[ f(x) dx ] dx ] / intgrl[ intgrl[ f(x) dx ] dx ]
16 c
17 c Inputs:
18 c ay Tabulated function values (equal x-spacing assumed)
19 c n Number of points in ay
20 c ideriv Derivative flag (0=zeroth, 1=first)
21 c----------------------------------------------------------------------
22 c
23 function fmomnt( ay, n, ideriv )
24 implicit none
25 integer ideriv,n
26 double precision ay(n),fmomnt
27 c
28 integer i
29 double precision ai,ain,am1,sglsum
30 c
31 double precision ZERO
32 parameter(zero=0.0d0)
33 c
34 c ----
35 c
36 am1=zero
37 ain=zero
38 c *** 0th derivative data
39 if (ideriv.eq.0) then
40 do 2 i=1,n
41 ai=dfloat(i)
42 am1=am1+ai*ay(i)
43 ain=ain+ay(i)
44 2 continue
45 else
46 c *** 1st derivative data
47 sglsum=zero
48 do 4 i=1,n
49 ai=dfloat(i)
50 sglsum=sglsum+ay(i)
51 am1=am1+ai*sglsum
52 ain=ain+sglsum
53 4 continue
54 end if
55 c
56 if (ain.ne.zero) then
57 fmomnt = am1/ain
58 else
59 fmomnt=zero
60 end if
61 return
62 end
fmomnt
double precision function fmomnt(ay, n, ideriv)
Definition: fmomnt.f90:24