ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat6.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 
13 dvector column(const dmatrix& matrix, int j)
14 {
15  return extract_column(matrix, j);
16 }
24 dvector row(const dmatrix& matrix, int i)
25 {
26  return extract_row(matrix, i);
27 }
34 dvector extract_column(const dmatrix& matrix, int j)
35 {
36 #ifndef OPT_LIB
37  if (j < matrix.colmin() || j > matrix.colmax())
38  {
39  cerr << "Error: Invalid matrix column index specified in "
40  << "dvector extract_column(const dmatrix&, int).\n",
41  ad_exit(1);
42  }
43 #endif
44  int min = matrix.rowmin();
45  int max = matrix.rowmax();
46  dvector column(min, max);
47 
48  double* pcolumni = column.get_v() + min;
49  const dvector* pmatrixi = &matrix(min);
50  for (int i = min; i <= max; ++i)
51  {
52  *pcolumni = *(pmatrixi->get_v() + j);
53 
54  ++pmatrixi;
55  ++pcolumni;
56  }
57  return column;
58 }
66 dvector extract_row(const dmatrix& matrix, int i)
67 {
68  if (i < matrix.rowmin() || i > matrix.rowmax())
69  {
70  cerr << "Error: Invalid matrix row index specified in "
71  << "dvector extract_row(const dmatrix&, int).\n",
72  ad_exit(1);
73  }
74 
75  dvector row(matrix(i).indexmin(), matrix(i).indexmax());
76  row = matrix.elem(i);
77 
78  return row;
79 }
Vector of double precision numbers.
Definition: dvector.h:50
exitptr ad_exit
Definition: gradstrc.cpp:53
dvector row(const dmatrix &matrix, int i)
Returns a copied row for matrix at i.
Definition: dmat6.cpp:24
dvector extract_column(const dmatrix &matrix, int j)
Extract copy of jth column vector from matrix m.
Definition: dmat6.cpp:34
int rowmax() const
Definition: fvar.hpp:2929
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int colmin(void) const
Definition: fvar.hpp:2939
Description not yet available.
Definition: fvar.hpp:2819
dvector & elem(int i)
Definition: fvar.hpp:3011
dvector extract_row(const dmatrix &matrix, int i)
Returns a copied row for matrix at i.
Definition: dmat6.cpp:66
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
double *& get_v(void)
Definition: dvector.h:148
int rowmin() const
Definition: fvar.hpp:2925
int colmax(void) const
Definition: fvar.hpp:2943