Sort Lyapunov exponents and print more
This commit is contained in:
@ -128,16 +128,29 @@ int lyapunov(
|
||||
// extract eigenvalues (diagonal elements of Du_prod)
|
||||
for(i=0; i<MATSIZE; i++){
|
||||
lyapunov[i]=log(cabs(Du_prod[i*MATSIZE+i]))/(time-prevtime);
|
||||
// add to average
|
||||
lyapunov_avg[i]=lyapunov_avg[i]*prevtime/time+lyapunov[i]*(time-prevtime)/time;
|
||||
}
|
||||
|
||||
// sort lyapunov exponents
|
||||
qsort(lyapunov, MATSIZE, sizeof(double), compare_double);
|
||||
|
||||
// average lyapunov
|
||||
for(i=0; i<MATSIZE; i++){
|
||||
// exclude inf
|
||||
if(! isinf(lyapunov[i])){
|
||||
lyapunov_avg[i]=lyapunov_avg[i]*prevtime/time+lyapunov[i]*(time-prevtime)/time;
|
||||
}
|
||||
}
|
||||
|
||||
// print
|
||||
fprintf(stderr,"% .15e\n",time);
|
||||
for(i=0; i<MATSIZE; i++){
|
||||
printf("% .15e % .15e % .15e\n",time, lyapunov[i], lyapunov_avg[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr,"% .15e",time);
|
||||
// print largest and smallest lyapunov exponent
|
||||
if(MATSIZE>0){
|
||||
fprintf(stderr," % .15e % .15e\n", lyapunov[0], lyapunov[MATSIZE-1]);
|
||||
}
|
||||
|
||||
// set Du_prod to Q:
|
||||
LAPACKE_zungrq(LAPACK_COL_MAJOR, MATSIZE, MATSIZE, MATSIZE, Du_prod, MATSIZE, tmp2);
|
||||
@ -151,6 +164,17 @@ int lyapunov(
|
||||
return(0);
|
||||
}
|
||||
|
||||
// comparison function for qsort
|
||||
int compare_double(const void* x, const void* y) {
|
||||
if (*(const double*)x<*(const double*)y) {
|
||||
return(-1);
|
||||
} else if (*(const double*)x>*(const double*)y) {
|
||||
return(+1);
|
||||
} else {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Jacobian of u_n -> u_{n+1}
|
||||
int ns_D_step(
|
||||
_Complex double* out,
|
||||
|
Reference in New Issue
Block a user