ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
dvect17.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvect17.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"
00012 
00019 dvector extract_diagonal(const dmatrix& m)
00020 {
00021   if ( (m.rowmin()!=m.colmin()) || (m.rowmax()!=m.colmax()))
00022   {
00023     cerr << "Error in extract_diagonal function "
00024     "-- input matrix not square" <<endl;
00025     ad_exit(1);
00026   }
00027 
00028   dvector tmp(m.rowmin(),m.rowmax());
00029   for (int i=m.rowmin(); i<=m.rowmax(); i++)
00030   {
00031     tmp.elem(i)=m.elem(i,i);
00032   }
00033 
00034   return(tmp);
00035 }