ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
imat5.cpp
Go to the documentation of this file.
1 
6 #if (__cplusplus > 199711L)
7  #include <iterator>
8  #include <algorithm>
9 #endif
10 #include "fvar.hpp"
11 
18 {
19  if (allocated(*this))
20  {
21  if (rowmin() != other.rowmin() || rowmax() != other.rowmax()
22  || colmin() != other.colmin() || colmax() != other.colmax())
23  {
24  cerr << "Incompatible array bounds in "
25  << "imatrix& imatrix::operator=(const imatrix&)\n";
26  ad_exit(1);
27  }
28  // check for condition that both matrices point to the same object
29  if (m != other.m)
30  {
31 #if (__cplusplus <= 199711L)
32  for (int i = rowmin(); i <= rowmax(); ++i)
33  {
34  *(m+i) = other[i];
35  }
36 #else
37  ivector* iter = other.begin();
38  std::for_each(begin(), end(), [&iter](ivector& v) {
39  v = *iter;
40  ++iter;
41  });
42 #endif
43  }
44  }
45  else
46  {
47  index_min = other.index_min;
48  index_max = other.index_max;
49  shape = other.shape;
50  if (shape)
51  {
52  (shape->ncopies)++;
53  }
54  m = other.m;
55  }
56  return *this;
57 }
64 {
65 #if (__cplusplus <= 199711L)
66  for (int i = indexmin(); i <= indexmax(); ++i)
67  {
68  elem(i) = value;
69  }
70 #else
71  std::for_each(begin(), end(), [value](ivector& v) {
72  v = value;
73  });
74 #endif
75  return *this;
76 }
ivector * m
Definition: imatrix.h:74
ivector & elem(int i)
Definition: imatrix.h:233
int indexmax() const
Definition: imatrix.h:142
mat_shapex * shape
Definition: imatrix.h:75
Description not yet available.
Definition: imatrix.h:69
int indexmin() const
Definition: imatrix.h:138
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
ivector * end() const
Definition: imatrix.h:134
int index_max
Definition: imatrix.h:73
int rowmin() const
Definition: imatrix.h:146
exitptr ad_exit
Definition: gradstrc.cpp:53
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
int colmin(void) const
Definition: imatrix.h:155
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
ivector * begin() const
Definition: imatrix.h:130
int colmax(void) const
Definition: imatrix.h:159
unsigned int ncopies
Definition: fvar.hpp:2034
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
int rowmax() const
Definition: imatrix.h:150
imatrix & operator=(const imatrix &t)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: imat5.cpp:17
int index_min
Definition: imatrix.h:72