cseife_deriv.c 1.63 KB
Newer Older
Simone Butzer's avatar
Simone Butzer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*! \file cseife_deriv.c
 * \brief calculate time derivative (implementation)
 * 
 * ----------------------------------------------------------------------------
 * 
 * $Id: cseife_deriv.c 3373 2010-11-14 13:29:20Z tforb $
 * \date 28/06/2005
 * 
 * calculate time derivative (implementation)
 * 
 * Copyright 1984 by Erhard Wielandt
 * This algorithm was part of seife.f. A current version of seife.f can be
 * obtained from http://www.software-for-seismometry.de/
 * 
 * REVISIONS and CHANGES 
 *  - 28/06/2005   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */
#define TF_CSEIFE_DERIV_C_VERSION \
  "TF_CSEIFE_DERIV_C   V1.0   "
#define TF_CSEIFE_DERIV_C_CVSID \
  "$Id: cseife_deriv.c 3373 2010-11-14 13:29:20Z tforb $"

#include <cseife.h>

/* subs/seife_deriv.f -- translated by f2c (version 20000121).
   You must link the resulting object file with the libraries:
	-lf2c -lm   (in that order)

   the code was derived through f2c, but modified thereafter
*/

/* derivative (time constant t0) */
void seife_dif(double* x, int n, double dt, double tau)
{
    /* System generated locals */
    int i__1;

    /* Local variables */
    static int j;
    static double twodt;

/*  derivative (non-recursive, non-causal, symmetric-difference) */
    /* Parameter adjustments */
    --x;

    if (tau < 1.e-23) {
	tau = 1.;
    }
    twodt = dt * 2. / tau;
    i__1 = n - 2;
    for (j = 1; j <= i__1; ++j) {
/* L1: */
	x[j] = (x[j + 2] - x[j]) / twodt;
    }
    for (j = n - 1; j >= 2; --j) {
/* L2: */
	x[j] = x[j - 1];
    }
    x[n] = x[n - 1];
} /* seife_dif */


/* ----- END OF cseife_deriv.c ----- */