ADMB Documentation  11.1.1955
 All Classes Files Functions Variables Typedefs Friends Defines
fv1f1b.hpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fv1f1b.hpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  *
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "New BSD" license
00009  *
00010  * License:
00011  *
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  *
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  *
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  */
00045 #include <fvar.hpp>
00046 
00051   class f1b1_data{
00052   {
00053   public:
00054     double        u;
00055     dvector       udot;      // tangent vector for u
00056     dvector       uhat;      // adjoint vector for u
00057     dvector       uhatdot;   // adjoint vector for udot
00058 
00059     f1b_data(int n) : udot(1,n), uhat(1,n), uhatdot(1,n) {}
00060     int nvar(void) {return udot.indexmax();}
00061   };
00062 
00067   class single_f1b1_function
00068   {
00069   public:
00070     double (*f)(double);
00071     double (*d1f)(double);
00072     double (*d11f)(double);
00073     single_f1b1_node operator () (dep_data& v)
00074     {
00075       f1b1_data * dep=v->dep;
00076       f1b_data tmp(dep->nvar());
00077       tmp.u=f(dep->u);
00078       udot=d1f(dep->u)*dep->udot;
00079       single_f1b1_node node : ;
00080       node.ind=*v;
00081     }
00082   }
00083 
00088   class double_f1b1_function
00089   {
00090   public:
00091     double (*f)(double,double);
00092     double (*d1f)(double,double);
00093     double (*d2f)(double,double);
00094     double (*d12f)(double,double);
00095     double (*d22f)(double,double);
00096     double_f1b1_node operator () (dep_data& v,dep_data& w)
00097     {
00098       f1b1_data * dep1=v->dep;
00099       f1b1_data * dep2=w->dep;
00100       f1b1_data * = new f1b1_data(tmp(dep->nvar()));
00101       tmp.u=f(dep1->u,dep2->u);
00102       udot=d1f(dep1->u)*dep1->udot;
00103       udot+=d2f(dep1->u)*dep1->udot;
00104     }
00105     class single_f1b1_node : dep_data(f1b1_data);
00106   };
00107 
00112   class dep_data
00113   {
00114   public:
00115     f1b1_data * dep;
00116     dep_data(f1b1_data * t) { dep=t;}
00117   };
00118 
00123   class single_f1b1_node : public dep_data {
00124   {
00125   public:
00126     dep_data * ind1;
00127     single_f1b1_function * f;
00128   };
00129 
00134   class double_f1b1_node : public dep_data {
00135   {
00136     dep_data * ind1;
00137     dep_data * ind2;
00138     double_f1b1_function * f;
00139   };