ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
imat7.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 #include "admb_messages.h"
7 
13 int sum(const imatrix& matrix)
14 {
15  int min = matrix.rowmin();
16  int max = matrix.rowmax();
17 
18  int total = 0;
19  const ivector* pmatrixi = &matrix(min);
20  for (int i = min; i <= max; ++i)
21  {
22  total += sum(*pmatrixi);
23  ++pmatrixi;
24  }
25  return total;
26 }
33 int colsum(const imatrix& matrix, int column)
34 {
35 #ifndef OPT_LIB
36  if (column < matrix.colmin() || column > matrix.colmax())
37  {
38  ADMB_ARRAY_BOUNDS_ERROR("Specified column is out of bounds",
39  "in colsum(const imatrix&,int column)",
40  matrix.colmin(), matrix.colmax(), column);
41  }
42 #endif
43  int sum = 0;
44  int min = matrix.rowmin();
45  int max = matrix.rowmax();
46  const ivector* pmatrixi = &matrix(min);
47  for (int i = min; i <= max; ++i)
48  {
49  sum += *(pmatrixi->get_v() + column);
50  ++pmatrixi;
51  }
52  return sum;
53 }
60 ivector column(const imatrix& matrix, int column)
61 {
62 #ifndef OPT_LIB
63  if (column < matrix.colmin() || column > matrix.colmax())
64  {
65  ADMB_ARRAY_BOUNDS_ERROR("Specified column is out of bounds",
66  "in column(const imatrix&, int column)",
67  matrix.colmin(), matrix.colmax(), column);
68  }
69 #endif
70  int min = matrix.rowmin();
71  int max = matrix.rowmax();
72  ivector vector(min, max);
73  int* pvectori = &vector(min);
74  const ivector* pmatrixi = &matrix(min);
75  for (int i = min; i <= max; ++i)
76  {
77  *pvectori = *(pmatrixi->get_v() + column);
78  ++pmatrixi;
79  ++pvectori;
80  }
81  return vector;
82 }
Description not yet available.
Definition: imatrix.h:69
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
int rowmin() const
Definition: imatrix.h:146
int * get_v() const
Definition: ivector.h:114
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
#define min(a, b)
Definition: cbivnorm.cpp:188
int colmin(void) const
Definition: imatrix.h:155
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double colsum(const dmatrix &m, int col)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat27.cpp:10
int colmax(void) const
Definition: imatrix.h:159
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
Definition: admb_messages.h:47
dvector column(const dmatrix &matrix, int j)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat6.cpp:13
#define max(a, b)
Definition: cbivnorm.cpp:189
int rowmax() const
Definition: imatrix.h:150