27 cerr <<
"error -- non square matrix passed to "
28 "dvector eigen(const dmatrix& m)\n";
34 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
35 int n = [](
unsigned int rowsize) ->
int
37 assert(rowsize <= INT_MAX);
38 return static_cast<int>(rowsize);
41 int n =
static_cast<int>(m1.
rowsize());
70 cerr <<
"Error -- non square matrix passed to "
71 "void tridag(const dmatrix& m)\n";
77 cerr <<
"Error -- incorrect vector size passed to "
78 "void tridag(const dmatrix& m)\n";
81 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
82 int n = [](
unsigned int rowsize) ->
int
84 assert(rowsize <= INT_MAX);
85 return static_cast<int>(rowsize);
88 int n =
static_cast<int>(m.
rowsize());
91 double scale,hh,h,g,f;
99 for (
int k=1;k<=l;k++)
100 scale +=
fabs(m[i][k]);
105 for (
int k=1;k<=l;k++)
108 h += m[i][k]*m[i][k];
123 for (
int k=1;k<=j;k++)
124 g += m[j][k]*m[i][k];
125 for (
int k=j+1;k<=l;k++)
126 g += m[k][j]*m[i][k];
135 for (
int k=1;k<=j;k++)
136 m[j][k] -= (f*e[k]+g*m[i][k]);
160 for (
int k=1;k<=l;k++)
161 g += m[i][k]*m[k][j];
162 for (
int k=1;k<=l;k++)
163 m[k][j] -= g*m[k][i];
168 for (j=1;j<=l;j++) m[j][i]=m[i][j]=0.0;
178 double SIGN(
const double x,
double y)
208 int max_iterations=30;
209 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
210 int n = [](
unsigned int size) ->
int
212 assert(size <= INT_MAX);
213 return static_cast<int>(size);
216 int n =
static_cast<int>(d.
size());
218 max_iterations+=10*(n/100);
220 double s,r,p,g,f,dd,c,b;
222 for (i=2;i<=n;i++) e[i-1]=e[i];
227 for (m=l;m<=n-1;m++) {
229 if (
fabs(e[m])+dd == dd)
break;
233 if (iter++ == max_iterations)
235 cerr <<
"Maximum number of iterations exceeded in"
236 " dvector eigen(const dmatrix& m)\n";
239 g=(d[l+1]-d[l])/(2.0*e[l]);
241 g=d[m]-d[l]+e[l]/(g+
SIGN(r,g));
244 for (i=m-1;i>=l;i--) {
259 r=(d[i]-g)*s+2.0*c*b;
265 for (
int k=1;k<=n;k++)
268 z[k][i+1]=s*z[k][i]+c*f;
269 z[k][i]=c*z[k][i]-s*f;
296 int max_iterations=30;
297 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
298 int n = [](
unsigned int size) ->
int
300 assert(size <= INT_MAX);
301 return static_cast<int>(size);
304 int n =
static_cast<int>(d.
size());
306 max_iterations+=10*(n/100);
308 double s,r,p,g,f,dd,c,b;
310 for (i=2;i<=n;i++) e[i-1]=e[i];
315 for (m=l;m<=n-1;m++) {
317 if (
fabs(e[m])+dd == dd)
break;
321 if (iter++ == max_iterations)
323 cerr <<
"Maximum number of iterations exceeded in"
324 " dvector eigen(const dmatrix& m)\n";
327 g=(d[l+1]-d[l])/(2.0*e[l]);
329 g=d[m]-d[l]+e[l]/(g+
SIGN(r,g));
332 for (i=m-1;i>=l;i--) {
347 r=(d[i]-g)*s+2.0*c*b;
386 int max_iterations=30;
387 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
388 int n = [](
unsigned int size) ->
int
390 assert(size <= INT_MAX);
391 return static_cast<int>(size);
394 int n =
static_cast<int>(d.size());
396 max_iterations+=10*(n/100);
398 double s,r,p,g,f,dd,c,b;
400 for (i=2;i<=n;i++) e[i-1]=e[i];
405 for (m=l;m<=n-1;m++) {
407 if (
fabs(e[m])+dd == dd)
break;
411 if (iter++ == max_iterations)
413 cerr <<
"Maximum number of iterations exceeded in"
414 " dvector eigen(const dmatrix& m)\n";
417 g=(d[l+1]-d[l])/(2.0*e[l]);
419 g=d[m]-d[l]+e[l]/(g+
SIGN(r,g));
422 for (i=m-1;i>=l;i--) {
437 r=(d[i]-g)*s+2.0*c*b;
442 for (
int k=1;k<=n;k++)
445 z[k][i+1]=s*z[k][i]+c*f;
446 z[k][i]=c*z[k][i]-s*f;
dvar_vector get_eigen_values(const dvar_vector &_ddd, const dvar_vector &_eee)
Eigenvalues and eigenvectors.
dvector eigenvalues(const banded_symmetric_dmatrix &_SS)
Description not yet available.
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.
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmax() const
Get maximum valid index.
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 colshift(int min)
Description not yet available.
unsigned int rowsize() const