22 #define ISZERO(d) ((d)==0.0)
24 #if !defined(EIGEN_VECTORS)
25 # define EIGEN_VECTORS
48 cerr <<
"Error -- non square matrix passed to dvector"
49 " eigen(const dmatrix& m)" <<
endl;
54 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
55 int n = [](
unsigned int rowsize) ->
int
57 assert(rowsize <= INT_MAX);
58 return static_cast<int>(rowsize);
61 int n =
static_cast<int>(m1.
rowsize());
94 cerr <<
"Error -- non square matrix passed to dvector"
95 " eigen(_CONST dmatrix& m)" <<
endl;
100 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
101 int n = [](
unsigned int rowsize) ->
int
103 assert(rowsize <= INT_MAX);
104 return static_cast<int>(rowsize);
107 int n =
static_cast<int>(m1.
rowsize());
114 cerr <<
"incompatible sizes in vector and matrix passed to"
115 " dmatrix eigenvector routine" <<
endl;
155 cerr <<
"Error -- non square matrix passed to "
156 "void tridag(const dmatrix& m)\n";
162 cerr <<
"Error -- incorrect vector size passed to "
163 "void tridag(const dmatrix& m)\n";
166 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
167 int n = [](
unsigned int rowsize) ->
int
169 assert(rowsize <= INT_MAX);
170 return static_cast<int>(rowsize);
173 int n =
static_cast<int>(m.
rowsize());
176 double scale,hh,h,g,f;
185 scale +=
fabs(m[i][k]);
193 h += m[i][k]*m[i][k];
209 g += m[j][k]*m[i][k];
211 g += m[k][j]*m[i][k];
221 m[j][k] -= (f*e[k]+g*m[i][k]);
246 g += m[i][k]*m[k][j];
248 m[k][j] -= g*m[k][i];
253 for (j=1;j<=l;j++) m[j][i]=m[i][j]=0.0;
293 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
294 int n = [](
unsigned int size) ->
int
296 assert(size <= INT_MAX);
297 return static_cast<int>(size);
300 int n =
static_cast<int>(d.
size());
303 double s,r,p,g,f,dd,c,b;
305 for (i=2;i<=n;i++) e[i-1]=e[i];
310 for (m=l;m<=n-1;m++) {
312 if (
fabs(e[m])+dd == dd)
break;
318 cerr <<
"Maximum number of iterations exceeded in"
319 " dvector eigen(const dmatrix& m)\n";
322 g=(d[l+1]-d[l])/(2.0*e[l]);
324 g=d[m]-d[l]+e[l]/(g+
SIGNV(r,g));
327 for (i=m-1;i>=l;i--) {
342 r=(d[i]-g)*s+2.0*c*b;
348 for (
int k=1;k<=n;k++)
351 z[k][i+1]=s*z[k][i]+c*f;
352 z[k][i]=c*z[k][i]-s*f;
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Vector of double precision numbers.
int indexmin() const
Get minimum valid index.
df1_two_variable fabs(const df1_two_variable &x)
unsigned int colsize() const
void get_eigen(const dvar_vector &d, const dvar_vector &e, const dvar_matrix &z)
Eigenvalues.
void get_eigenv(const dvar_vector &d, const dvar_vector &e, const dvar_matrix &z)
Eigenvalues and eigenvectors.
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
prnstream & endl(prnstream &)
dmatrix eigenvectors(const banded_symmetric_dmatrix &_SS, const dvector &_e)
Description not yet available.
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
unsigned int size() const
Get number of elements in array.
void tri_dag(const dvar_matrix &, const dvar_vector &, const dvar_vector &)
Householder transformation for eigenvalue computation.
void rowshift(int min)
Changes the range of valid indices for the rows.
void tri_dagv(const dvar_matrix &, const dvar_vector &, const dvar_vector &)
Householder transformation for eivenvector computation.
void colshift(int min)
Description not yet available.
unsigned int rowsize() const
dvariable SIGNV(const prevariable &x, const prevariable &y)
Change sign.