ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scbound1.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include "fvar.hpp"
12 #ifdef __TURBOC__
13  #pragma hdrstop
14 #endif
15 
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <math.h>
19 
20 double dmin(double,double);
21 double dmax(double, double);
22 
23 #define USE_BARD_PEN
24 
29 double boundpin(const prevariable& xx, double fmin, double fmax,const double& s)
30 {
31  double tinv;
32  double x=value(xx);
33 
34  if (x < fmin)
35  {
36  ad_printf("variable out of bounds in boundpin: variable = %lg", x);
37  ad_printf("; min = %lg", fmin);
38  ad_printf("; max = %lg\n", fmax);
39 
40  x=dmin(fmin+.001,fmin+.01*(fmax-fmin));
41  }
42 
43  if (x > fmax)
44  {
45  ad_printf("variable out of bounds in boundpin: variable = %lg", x);
46  ad_printf("; min = %lg", fmin);
47  ad_printf("; max = %lg\n", fmax);
48 
49  x=dmax(fmax-.001,fmax-.01*(fmax-fmin));
50  }
51 
52  tinv=::asin(2.*(x-fmin)/(fmax-fmin)-1.)/1.57079632679489661;
53  return(s*tinv);
54 }
Base class for dvariable.
Definition: fvar.hpp:1315
#define x
void fmin(double f, const independent_variables &x, const dvector &g, const int &n, const dvector &w, const dvector &h, const fmm_control &fmc)
#define dmin(a, b)
Definition: cbivnorm.cpp:190
#define dmax(a, b)
Definition: cbivnorm.cpp:191
double boundpin(double x, double fmin, double fmax, double s)
Scale model variable over [-1,1]; constant objects.
Definition: boundfun.cpp:378
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
int ad_printf(FILE *stream, const char *format, Args...args)
Definition: fvar.hpp:9487
dvector asin(const dvector &vec)
Returns dvector with principal value of the arc sine of vec, expressed in radians.
Definition: dvect6.cpp:229