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