ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
imat2.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 
7 #ifdef __TURBOC__
8  #pragma hdrstop
9 #endif
10 
11 #if !defined(OPT_LIB)
12 
20 int& imatrix::operator()(int i, int j)
21 {
22  if (i < rowmin())
23  {
24  cerr << "matrix bound exceeded -- row index too low in "
25  << "imatrix::operator()(int, int)\n"
26  << "value was \"" << i << "\".\n";
27  ad_exit(1);
28  }
29  if (i > rowmax())
30  {
31  cerr << "matrix bound exceeded -- row index too high in "
32  << "imatrix::operator()(int, int)\n"
33  << "value was \"" << i << "\".\n";
34  ad_exit(1);
35  }
36  ivector* pmi = m + i;
37  if (j < pmi->indexmin())
38  {
39  cerr << "matrix bound exceeded -- column index too low in "
40  << "imatrix::operator()(int, int)\n"
41  << "value was \"" << j << "\".\n";
42  ad_exit(1);
43  }
44  if (j > pmi->indexmax())
45  {
46  cerr << "matrix bound exceeded -- column index too high in "
47  << "imatrix::operator()(int, int)\n"
48  << "value was \"" << j << "\".\n";
49  ad_exit(1);
50  }
51  return *(pmi->v + j);
52 }
60 const int& imatrix::operator()(int i, int j) const
61 {
62  if (i < rowmin())
63  {
64  cerr << "matrix bound exceeded -- row index too low in "
65  << "imatrix::operator()(int, int)\n"
66  << "value was \"" << i << "\".\n";
67  ad_exit(1);
68  }
69  if (i > rowmax())
70  {
71  cerr << "matrix bound exceeded -- row index too high in "
72  << "imatrix::operator()(int, int)\n"
73  << "value was \"" << i << "\".\n";
74  ad_exit(1);
75  }
76  ivector* pmi = m + i;
77  if (j < pmi->indexmin())
78  {
79  cerr << "matrix bound exceeded -- column index too low in "
80  << "imatrix::operator()(int, int)\n"
81  << "value was \"" << j << "\".\n";
82  ad_exit(1);
83  }
84  if (j > pmi->indexmax())
85  {
86  cerr << "matrix bound exceeded -- column index too high in "
87  << "imatrix::operator()(int, int)\n"
88  << "value was \"" << j << "\".\n";
89  ad_exit(1);
90  }
91  return *(pmi->v + j);
92 }
93 #endif
ivector * m
Definition: imatrix.h:74
int indexmin() const
Definition: imatrix.h:138
int rowmin() const
Definition: imatrix.h:146
exitptr ad_exit
Definition: gradstrc.cpp:53
ivector & operator()(int)
Definition: imatrix.h:205
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmax() const
Definition: ivector.h:104
int * v
Definition: ivector.h:55
int rowmax() const
Definition: imatrix.h:150