gdrsclib
blockmath.h
Go to the documentation of this file.
1 /***************************************************
2 Apache License Version 2.0
3 
4 Copyright 2007-2011 EcoEquity and Stockholm Environment Institute
5 
6 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7 file except in compliance with the License. You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software distributed under
12 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 KIND, either express or implied. See the License for the specific language governing
14 permissions and limitations under the License.
15 ****************************************************/
16 
17 #ifndef BLOCKMATH
18 #define BLOCKMATH
19 
20 #define MAXITER 100
21 // Note that according to dcdflib, smallest is 2^(-52) = 2.22e-16
22 #define EPSILON 1.0e-15
23 // From Abramowitz and Stegun
24 #define INV_SQRT_2PI 0.3989422804014326779399461
25 
26 
27 // Manipulating datablocks
28 struct datablock transform(struct datablock dbin, double (*f)(double), struct appdata ad);
29 
30 // Calculations
31 struct datablock binop(struct datablock a, struct datablock b, char op, struct appdata ad);
32 struct datablock scalmult(double scalar, struct datablock dbin, struct appdata ad);
33 
34 // Filter
35 struct timeseries filter(struct datablock data, struct fixedfactor filter, struct appdata ad);
36 double filteryr(int year, struct datablock data, struct fixedfactor filter, struct appdata ad);
37 
38 // Auxiliary functions
39 double gini2sdlog(double gini);
40 double pnorm(double x);
41 double quick_qnorm(double p);
42 double qnorm(double p);
43 double dnorm(double x);
44 double ztransf(double y, double ybar, double sigma);
45 
46 #endif
For the application, basic dimensions: number of countries and bounding years.
Definition: datastruct.h:48
double dnorm(double x)
The standard normal probability density.
Definition: blockmath.c:201
struct datablock binop(struct datablock a, struct datablock b, char op, struct appdata ad)
Carry out a binary operation (+, -, *, /) on two datablock structures.
Definition: blockmath.c:69
double quick_qnorm(double p)
Abramowitz & Stegun approximation to qnorm to get a good first guess.
Definition: blockmath.c:140
A one-dimensional array that contains information on countries that is the same for all years...
Definition: datastruct.h:84
struct datablock transform(struct datablock dbin, double(*f)(double), struct appdata ad)
Apply a function to a datablock.
Definition: blockmath.c:38
A one-dimensional array that contains global information that is the same for all countries...
Definition: datastruct.h:93
struct datablock scalmult(double scalar, struct datablock dbin, struct appdata ad)
Multiply a datablock by a scaling factor.
Definition: blockmath.c:103
double ztransf(double y, double ybar, double sigma)
The transformed value .
Definition: blockmath.c:213
double * data
The data, length = y_start - y_end + 1 when created.
Definition: datastruct.h:96
double gini2sdlog(double gini)
The standard deviation of the log of income corresponding to a given Gini, assuming lognormal...
Definition: blockmath.c:235
A two-dimensional array that contains information for country/year combinations.
Definition: datastruct.h:59
double pnorm(double x)
The cumulative standardized normal distribution.
Definition: blockmath.c:128
double filteryr(int year, struct datablock data, struct fixedfactor filter, struct appdata ad)
Aggregate data in a datablock using a fixedfactor "filter" for a particular year. ...
Definition: blockmath.c:279
struct timeseries filter(struct datablock data, struct fixedfactor filter, struct appdata ad)
Aggregate data in a datablock using a fixedfactor "filter" to produce a timeseries.
Definition: blockmath.c:250
double qnorm(double p)
The inverse cumulative standardized normal distribution.
Definition: blockmath.c:167