ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat12.cpp
Go to the documentation of this file.
1 
5 #include <fvar.hpp>
6 
14 dmatrix symmetrize(const dmatrix& matrix)
15 {
16  if (matrix.rowmin() != matrix.colmin() || matrix.rowmax() != matrix.colmax())
17  {
18  cerr << "Error: Parameter is non square matrix in "
19  << "symmetrize(dmatrix&)\n";
20  ad_exit(1);
21  }
22  int min = matrix.rowmin();
23  int max = matrix.rowmax();
24  dmatrix results(min, max, min, max);
25  for (int i = min; i <= max; ++i)
26  {
27  results(i, i) = matrix(i, i);
28  for (int j = min; j < i; ++j)
29  {
30  results(i,j) = (matrix(i, j) + matrix(j, i)) * 0.5;
31  results(j,i) = results(i,j);
32  }
33  }
34  return results;
35 }
exitptr ad_exit
Definition: gradstrc.cpp:53
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat12.cpp:14
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
#define max(a, b)
Definition: cbivnorm.cpp:189
int rowmin() const
Definition: fvar.hpp:2925
int colmax(void) const
Definition: fvar.hpp:2943