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 dvector log(const dvector& t1) 00018 { 00019 dvector tmp(t1.indexmin(),t1.indexmax()); 00020 00021 for (int i=t1.indexmin(); i<=t1.indexmax(); i++) 00022 { 00023 tmp.elem(i)=log(t1.elem(i)); 00024 } 00025 return(tmp); 00026 } 00027 00032 dvector exp(const dvector& t1) 00033 { 00034 dvector tmp(t1.indexmin(),t1.indexmax()); 00035 00036 for (int i=t1.indexmin(); i<=t1.indexmax(); i++) 00037 { 00038 tmp.elem(i)=exp(t1.elem(i)); 00039 } 00040 return(tmp); 00041 } 00042 00047 dvector fabs(const dvector& t1) 00048 { 00049 dvector tmp(t1.indexmin(),t1.indexmax()); 00050 00051 for (int i=t1.indexmin(); i<=t1.indexmax(); i++) 00052 { 00053 tmp.elem(i)=fabs(t1.elem(i)); 00054 } 00055 return(tmp); 00056 } 00057 00062 double max(const dvector& t1) 00063 { 00064 double tmp; 00065 int mmin=t1.indexmin(); 00066 int mmax=t1.indexmax(); 00067 tmp=t1.elem(mmin); 00068 for (int i=mmin+1; i<=mmax; i++) 00069 { 00070 if (tmp<t1.elem(i)) tmp=t1.elem(i); 00071 } 00072 return(tmp); 00073 } 00074 00079 double min(const dvector& t1) 00080 { 00081 double tmp; 00082 int mmin=t1.indexmin(); 00083 int mmax=t1.indexmax(); 00084 tmp=t1.elem(mmin); 00085 for (int i=mmin+1; i<=mmax; i++) 00086 { 00087 if (tmp>t1.elem(i)) tmp=t1.elem(i); 00088 } 00089 return(tmp); 00090 }
Generated on Tue Mar 8 2016 19:51:32 for ADMB Documentation by 1.8.0 |