ADMB Documentation  11.1.2499
 All Classes Files Functions Variables Typedefs Friends Defines
dmat8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dmat8.cpp 1921 2014-04-23 18:47:05Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 #include "admb_messages.h"
00013 
00014 #if !defined(OPT_LIB)
00015 
00020  dvector& dmatrix::operator() (int i)
00021  {
00022      if (i<rowmin())
00023      {
00024        ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00025        "dvector& dmatrix::operator() (int i)", rowmin(), rowmax(), i);
00026      }
00027      if (i>rowmax())
00028      {
00029        ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
00030        "dvector& dmatrix::operator() (int i)", rowmin(), rowmax(), i);
00031      }
00032    return *(m+i);
00033  }
00034 #endif
00035 
00036 #if !defined(OPT_LIB) || defined(__INTEL_COMPILER)
00037 
00041  double& dmatrix::operator() (int i, int j)
00042  {
00043      if (i<rowmin())
00044      {
00045        cerr << "matrix bound exceeded -- row index too low in "
00046                "dmatrix::operator()"
00047              << "value was" << i;
00048        ad_exit(21);
00049      }
00050      if (i>rowmax())
00051      {
00052        cerr << "matrix bound exceeded -- row index too high in "
00053                "dmatrix::operator()"
00054              << "value was" << i;
00055        ad_exit(22);
00056      }
00057 
00058      // if (j<colmin())
00059      if (j<elem(i).indexmin())
00060      {
00061        cerr << "matrix bound exceeded -- column index too low in "
00062                "dmatrix::operator()"
00063              << "value was" << j;
00064        ad_exit(21);
00065      }
00066 
00067      // if (j>colmax())
00068      if (j>elem(i).indexmax())
00069      {
00070        cerr << "matrix bound exceeded -- column index too high in "
00071                "dmatrix::operator()"
00072              << "value was" << j;
00073        ad_exit(22);
00074      }
00075    return( *((m[i]).v+j) );
00076  }
00077 
00082 const double& dmatrix::operator()(int i, int j) const
00083  {
00084      if (i<rowmin())
00085      {
00086        cerr << "matrix bound exceeded -- row index too low in "
00087                "dmatrix::operator()"
00088              << "value was" << i;
00089        ad_exit(21);
00090      }
00091      if (i>rowmax())
00092      {
00093        cerr << "matrix bound exceeded -- row index too high in "
00094                "dmatrix::operator()"
00095              << "value was" << i;
00096        ad_exit(22);
00097      }
00098 
00099      // if (j<colmin())
00100      if (j<elem(i).indexmin())
00101      {
00102        cerr << "matrix bound exceeded -- column index too low in "
00103                "dmatrix::operator()"
00104              << "value was" << j;
00105        ad_exit(21);
00106      }
00107 
00108      // if (j>colmax())
00109      if (j>elem(i).indexmax())
00110      {
00111        cerr << "matrix bound exceeded -- column index too high in "
00112                "dmatrix::operator()"
00113              << "value was" << j;
00114        ad_exit(22);
00115      }
00116    return( *((m[i]).v+j) );
00117  }
00118 #endif