ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
f3arr4.cpp
Go to the documentation of this file.
00001 
00006 #include "fvar.hpp"
00007 
00012 dvar3_array operator-(const double d, const dvar3_array& m2)
00013    {
00014      RETURN_ARRAYS_INCREMENT();
00015      dvar3_array tmp;
00016      tmp.allocate(m2);
00017      for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
00018      {
00019        tmp(i)=d-m2(i);
00020      }
00021      RETURN_ARRAYS_DECREMENT();
00022      return tmp;
00023    }
00027 dvariable mean(const dvar3_array& m)
00028 {
00029   dvariable tmp;
00030   const int count = size_count(m);
00031   if (count > 0)
00032   {
00033     tmp = sum(m) / count;
00034   }
00035   else
00036   {
00037     cerr << "Error[" << __FILE__ << ':' << __LINE__ << "]:"
00038             "Division by zero in mean(dvar3_array)."
00039          << '\n';
00040     ad_exit(1);
00041   }
00042   return tmp;
00043 }