ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_ar3.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017 dvar_vector fabs(const dvar_vector& t1)
00018   {
00019      RETURN_ARRAYS_INCREMENT();
00020 
00021      dvar_vector tmp(t1.indexmin(),t1.indexmax());
00022 
00023      for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00024      {
00025        tmp.elem(i)=fabs(t1.elem(i));
00026      }
00027      RETURN_ARRAYS_DECREMENT();
00028      return(tmp);
00029   }
00030 
00035 dvector value(const dvar_vector& t1)
00036   {
00037      RETURN_ARRAYS_INCREMENT();
00038 
00039      dvector tmp(t1.indexmin(),t1.indexmax());
00040 
00041      for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00042      {
00043        tmp.elem(i)=value(t1.elem(i));
00044      }
00045      RETURN_ARRAYS_DECREMENT();
00046      return(tmp);
00047   }
00048 
00053 dvariable norm(const dvar_vector& t1)
00054   {
00055     RETURN_ARRAYS_INCREMENT();
00056     dvariable tmp;
00057     tmp=t1*t1;
00058     if (value(tmp)>0.0)
00059     {
00060      tmp=pow(tmp,.5);
00061     }
00062     RETURN_ARRAYS_DECREMENT();
00063     return(tmp);
00064   }
00065 
00070 dvariable norm2(const dvar_vector& t1)
00071   {
00072     RETURN_ARRAYS_INCREMENT();
00073     dvariable tmp;
00074     tmp=t1*t1;
00075     RETURN_ARRAYS_DECREMENT();
00076     return(tmp);
00077   }
00078 dvariable sumsq(const dvar_vector& t1) {return(norm2(t1));}
00079 
00084 dvar_vector sfabs(const dvar_vector& t1)
00085   {
00086      RETURN_ARRAYS_INCREMENT();
00087 
00088      dvar_vector tmp(t1.indexmin(),t1.indexmax());
00089 
00090      for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00091      {
00092        tmp.elem(i)=sfabs(t1.elem(i));
00093      }
00094      RETURN_ARRAYS_DECREMENT();
00095      return(tmp);
00096   }