[ff1121]: / src / include / function / testfun.h  Maximize  Restore  History

Download this file

90 lines (69 with data), 3.3 kB

 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef FUNC_TEST_H_
#define FUNC_TEST_H_
#include "ScalarFunction.h"
#include "VectorFunction.h"
/*
Function in JAGS are set up to take vectors of pointers as
arguments, with additional arguments for lengths or dimensions
of the arguments when necessary. This is not a good choice for the
testing framework.
These are wrappers to the members of Function and its subclasses
that take care of setting up the arguments in the right way. We
use these to simplify the testing framework.
*/
/* All functions */
//Check all possible values of mask using a predicate (see below)
bool isdiscrete(jags::Function const *f, unsigned int npar,
bool (*predicate) (std::vector<bool> const &));
//suitable predicates for isdiscrete
bool always(std::vector<bool> const &); //returns true
bool never(std::vector<bool> const &); //returns false
bool all(std::vector<bool> const &); //returns true if all arguments are true
bool any(std::vector<bool> const &); //returns true if any argyments are true
//Returns true if f is never a scale function
bool neverscale(jags::Function const *f, unsigned int npar);
//Returns true if f is never a linear function
bool neverlinear(jags::Function const *f, unsigned int npar);
//Returns true if f is never a power function
bool neverpow(jags::Function const *f, unsigned int npar);
//Returns true if f is never a linear, scale, or power function
bool neverslp(jags::Function const *f, unsigned int npar);
/* Scalar functions */
//Check that the limits of a scalar function are valid
void checkLimits(jags::ScalarFunction const *f, double lower, double upper);
//Single argument
double eval(jags::ScalarFunction const *f, double x);
bool checkval(jags::ScalarFunction const *f, double x);
//Two arguments
double eval(jags::ScalarFunction const *f, double x, double y);
bool checkval(jags::ScalarFunction const *f, double x, double y);
//Three arguments
double eval(jags::ScalarFunction const *f, double x, double y, double z);
bool checkval(jags::ScalarFunction const *f, double x, double y, double z);
/* Vector functions */
//Construct an STL vector from an array and the array length
std::vector<double> mkVec(double const *x, unsigned int N);
//Single argument
std::vector<double> veval(jags::VectorFunction const *f,
std::vector<double> const &x);
bool checkval(jags::VectorFunction const *f, std::vector<double> const &x);
bool checkparlen(jags::VectorFunction const *f, unsigned int n);
//Two arguments
std::vector<double> veval(jags::VectorFunction const *f,
std::vector<double> const &x,
std::vector<double> const &y);
bool checkval(jags::VectorFunction const *f, std::vector<double> const &x,
std::vector<double> const &y);
bool checkparlen(jags::VectorFunction const *f, unsigned int n1,
unsigned int n2);
/* Vector functions returning a scalar */
//Single argument
double eval(jags::VectorFunction const *f, std::vector<double> const &x);
//Two arguments
double eval(jags::VectorFunction const *f, std::vector<double> const &x,
std::vector<double> const &y);
double eval(jags::VectorFunction const *f, double x,
std::vector<double> const &y);
double eval(jags::VectorFunction const *f, std::vector<double> const &x,
double y);
#endif /* FUNC_TEST_H_ */