ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
dmat14.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 double trace(const dmatrix& M)
00018 {
00019   double tmp;
00020   tmp=0.0;
00021   if (M.colmin()!=M.rowmin() || M.colmax()!=M.rowmax() )
00022   {
00023     cerr << " Matrix not square in trace\n";
00024     ad_exit(1);
00025   }
00026   for (int i=M.colmin();i<=M.colmax();i++)
00027   {
00028     tmp+=M.elem(i,i);
00029   }
00030   return tmp;
00031 }