ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_m46.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_m46.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017 dvar_vector diagonal(const dvar_matrix& m)
00018 {
00019   if (m.indexmin() != m.colmin() || m.indexmax() != m.colmax())
00020   {
00021     cerr << "Error matrix not square in function diagonal" << endl;
00022     exit(21);
00023   }
00024   int mmin=m.indexmin();
00025   int mmax=m.indexmax();
00026   dvar_vector tmp(mmin,mmax);
00027   for (int i=mmin;i<=mmax;i++)
00028     tmp(i)=m(i,i);
00029   return tmp;
00030 }