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 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 }
Generated on Tue Mar 8 2016 19:51:33 for ADMB Documentation by 1.8.0 |