ADMB Documentation  11.1.2192
 All Classes Files Functions Variables Typedefs Friends Defines
ivect6.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: ivect6.cpp 1695 2014-02-27 19:21:37Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00018 int sum(const ivector &v)
00019 {
00020   int value = 0;
00021   for (int i = v.indexmin(); i <= v.indexmax(); i++)
00022   {
00023     value += v.elem(i);
00024   }
00025   return value;
00026 }
00034 ivector pow(const ivector& v1, int x)
00035 {
00036   ivector tmp(v1.indexmin(),v1.indexmax());
00037   for (int i=v1.indexmin();i<=v1.indexmax();i++)
00038   {
00039 #if defined(_MSC_VER) || defined(__SUNPRO_CC)
00040     tmp.elem(i) = pow(double(v1.elem(i)),x);
00041 #else
00042     tmp.elem(i) = pow(v1.elem(i),x);
00043 #endif
00044   }
00045   return tmp;
00046 }
00054 ivector pow(int x, const ivector& v1)
00055 {
00056   ivector tmp(v1.indexmin(), v1.indexmax());
00057   for (int i = v1.indexmin(); i <= v1.indexmax(); i++)
00058   {
00059 #if defined(_MSC_VER) || defined(__SUNPRO_CC)
00060     tmp.elem(i) = pow(double(x), v1.elem(i));
00061 #else
00062     tmp.elem(i) = pow(x, v1.elem(i));
00063 #endif
00064   }
00065   return tmp;
00066 }