ADMB Documentation  11.1.2192
 All Classes Files Functions Variables Typedefs Friends Defines
dvect2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvect2.cpp 1712 2014-02-28 23:52:33Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00020 dvector elem_prod(const dvector& t1, const dvector& t2)
00021   {
00022      if (t1.indexmin() != t2.indexmin() ||  t1.indexmax() != t2.indexmax())
00023      {
00024        cerr << "Index bounds do not match in dvector "
00025        "elem_prod(const dvector&, const dvector&)\n";
00026        ad_exit(1);
00027      }
00028      dvector tmp(t1.indexmin(),t1.indexmax());
00029 
00030 #ifndef USE_ASSEMBLER
00031      for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00032      {
00033        tmp[i]=t1[i]*t2[i];
00034      }
00035 #else
00036      int min=t1.indexmin();
00037      int n=t1.indexmax()-min+1;
00038      dp_vector_elem_prod(&(tmp(min)),&(t1(min)),&(t2(min)),n);
00039 #endif
00040 
00041      return(tmp);
00042   }
00043 
00052 dvector elem_div(const dvector& t1, const dvector& t2)
00053   {
00054      if (t1.indexmin() != t2.indexmin() ||  t1.indexmax() != t2.indexmax())
00055      {
00056        cerr << "Index bounds do not match in "
00057        "dvector elem_div(const dvector&, const dvector&)\n";
00058        ad_exit(1);
00059      }
00060      dvector tmp(t1.indexmin(),t1.indexmax());
00061 
00062 #ifndef USE_ASSEMBLER
00063      for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
00064      {
00065        tmp[i]=t1[i]/t2[i];
00066      }
00067 #else
00068      int min=t1.indexmin();
00069      int n=t1.indexmax()-min+1;
00070      dp_vector_elem_prod(&(tmp(min)),&(t1(min)),&(t2(min)),n);
00071 #endif
00072 
00073      return(tmp);
00074   }