ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lmat2.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 //#undef OPT_LIB
12 #include "fvar.hpp"
13 #include "admb_messages.h"
14 #ifdef __TURBOC__
15  #pragma hdrstop
16 #endif
17 #if !defined (OPT_LIB)
18 
23 AD_LONG_INT& lmatrix::operator()(int i, int j)
24  {
25  if (i < rowmin())
26  {
27  ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
28  "AD_LONG_INT& lmatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
29  }
30  if (i > rowmax())
31  {
32  ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
33  "AD_LONG_INT& lmatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
34  }
35  if (j < (*this)(i).indexmin())
36  {
37  ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- column index too low",
38  "AD_LONG_INT& lmatrix::operator() (int i, int j)",
39  (*this)(i).indexmin(), (*this)(i).indexmax(), j);
40  }
41  if (j > (*this)(i).indexmax())
42  {
43  ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- column index too low",
44  "AD_LONG_INT& lmatrix::operator() (int i, int j)",
45  (*this)(i).indexmin(), (*this)(i).indexmax(), j);
46  }
47  return(*((*(m+i)).v+j));
48  }
49 
54 const AD_LONG_INT& lmatrix::operator()(int i, int j) const
55  {
56  if (i<rowmin())
57  {
58  cerr << "matrix bound exceeded -- row index too low in "
59  "lmatrix::operator()(int, int)" << "\nvalue was " << i;
60  ad_exit(21);
61  }
62  if (i>rowmax())
63  {
64  cerr << "matrix bound exceeded -- row index too high in "
65  "lmatrix::operator()(int, int)" << "\nvalue was " << i;
66  ad_exit(22);
67  }
68  if (j<(*this)(i).indexmin())
69  {
70  cerr << "matrix bound exceeded -- column index too low in "
71  "lmatrix::operator()(int, int)" << "\nvalue was " << j;
72  ad_exit(21);
73  }
74  if (j>(*this)(i).indexmax())
75  {
76  cerr << "matrix bound exceeded -- column index too high in "
77  "lmatrix::operator()(int, int)" << "\nvalue was " << j;
78  ad_exit(22);
79  }
80  return(*((*(m+i)).v+j));
81  }
82 #endif
int rowmax(void) const
Definition: fvar.hpp:7596
exitptr ad_exit
Definition: gradstrc.cpp:53
int rowmin(void) const
Definition: fvar.hpp:7592
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
Definition: admb_messages.h:47
lvector * m
Definition: fvar.hpp:7503
#define AD_LONG_INT
Definition: fvar.hpp:81
lvector & operator()(int i)
Definition: fvar.hpp:7547