Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00011 #include "fvar.hpp"
00012 #include "admb_messages.h"
00013
00014 #ifndef OPT_LIB
00015
00020 prevariable dvar_matrix::operator () (int i, int j)
00021 {
00022 if (i < rowmin())
00023 {
00024 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00025 "prevariable dvar_matrix::operator () (int i, int j)",
00026 rowmin(), rowmax(), i);
00027 }
00028 if (i > rowmax())
00029 {
00030 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00031 "prevariable dvar_matrix::operator () (int i, int j)",
00032 rowmin(), rowmax(), i);
00033 }
00034 if (j < elem(i).indexmin())
00035 {
00036 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- second index too low",
00037 "prevariable dvar_matrix::operator () (int i, int j)",
00038 elem(i).indexmin(), elem(i).indexmax(), j);
00039 }
00040 if (j > elem(i).indexmax())
00041 {
00042 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- second index too high",
00043 "prevariable dvar_matrix::operator () (int i, int j)",
00044 elem(i).indexmin(), elem(i).indexmax(), j);
00045 }
00046 return ( m[i].va+j );
00047 }
00048
00053 dvar_vector& dvar_matrix::operator[] (int i)
00054 {
00055 if (i < rowmin())
00056 {
00057 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00058 "prevariable dvar_matrix::operator () (int i, int j)",
00059 rowmin(), rowmax(), i);
00060 }
00061 if (i > rowsize() + rowmin() - 1)
00062 {
00063 ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00064 "prevariable dvar_matrix::operator () (int i, int j)",
00065 rowmin(), rowmax(), i);
00066 }
00067 return (m[i]);
00068 }
00069
00074 const prevariable dvar_matrix::operator()(int i, int j) const
00075 {
00076 if (i<rowmin())
00077 {
00078 cerr << "array bound exceeded -- index too low in "
00079 "dvar_matrix::operator(int,int)"
00080 << " first argument was " << i << endl;
00081 ad_exit(21);
00082 }
00083 if (j<elem(i).indexmin())
00084 {
00085 cerr << "array bound exceeded -- index too low in "
00086 "dvar_matrix::operator(int,int)"
00087 << " first argument was " << i << endl;
00088 ad_exit(22);
00089 }
00090 if (i>rowmax())
00091 {
00092 cerr << "array bound exceeded -- index too high in "
00093 "dvar_matrix::operator(int,int)"
00094 << " second argument was " << j << endl;
00095 ad_exit(23);
00096 }
00097 if (j>elem(i).indexmax())
00098 {
00099 cerr << "array bound exceeded -- index too high in "
00100 "dvar_matrix::operator(int,int)"
00101 << " second argument was " << j << endl;
00102 ad_exit(24);
00103 }
00104 return ( m[i].va+j );
00105 }
00106
00111 const dvar_vector& dvar_matrix::operator[](int i) const
00112 {
00113 if (i<rowmin())
00114 {
00115 cerr << "matrix bound exceeded -- row index too low in "
00116 "dvar_matrix::operator[]"
00117 << "value was" << i;
00118 ad_exit(21);
00119 }
00120 if (i>rowsize()+rowmin()-1)
00121 {
00122 cerr << "matrix bound exceeded -- row index too high in "
00123 "dvar_matrix::operator[]"
00124 << "value was" << i;
00125 ad_exit(22);
00126 }
00127 return (m[i]);
00128 }
00129 #endif