ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
dmat8.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 #include <cassert>
00013 
00019 bool dmatrix::is_valid_row(const int i) const
00020 {
00021   const bool valid = index_min <= i && i <= index_max;
00022   if (!valid)
00023   {
00024     cerr << "Error: Used invalid i = " << i << " for dmatrix rows bounded by ["
00025          << index_min << ", " << index_max << "].\n";
00026   }
00027   return valid;
00028 }
00029 #if !defined(OPT_LIB)
00030 
00036 dvector& dmatrix::operator()(int i)
00037 {
00038   //check that index i is in range
00039   assert((index_min <= i && i <= index_max) || is_valid_row(i));
00040 
00041   return *(m + i);
00042 }
00043 #endif
00044 
00045 #if !defined(OPT_LIB) || defined(__INTEL_COMPILER)
00046 
00053 double& dmatrix::operator()(int i, int j)
00054 {
00055   //check that index i is in range
00056   assert((index_min <= i && i <= index_max) || is_valid_row(i));
00057 
00058   dvector& dvi = elem(i);
00059 
00060   //check that index j is in range
00061   assert(dvi.is_valid_index(j));
00062 
00063   return *(dvi.v + j);
00064 }
00072 const double& dmatrix::operator()(int i, int j) const
00073 {
00074   //check that index i is in range
00075   assert((index_min <= i && i <= index_max) || is_valid_row(i));
00076 
00077   const dvector& dvi = elem(i);
00078 
00079   //check that index j is in range
00080   assert(dvi.is_valid_index(j));
00081 
00082   return *(dvi.v + j);
00083 }
00084 #endif