Пример #1
0
static void test_lyapunov_spectrum (struct test_solver_info *ts_info)
{
    if (ts_info->length <= 0 || ts_info->dim < 1) return;

    double a;
    a = 4.0;
    ts_info->data[0][0] = 0.223;
    for (int n = 1; n < ts_info->length; n++) {
        ts_info->data[n][0] = logistic_map(ts_info->data[n-1][0], a);
    }
    lyapunov_spectrum((const double* const*)ts_info->data, ts_info->length,
            1, 1, 5, dlogistic_map, &a, ts_info->spectrum, NULL, NULL);

    mu_assert(ts_info->spectrum[0] > 0);

    a = 3.5;
    ts_info->data[0][0] = 0.341;
    for (int n = 1; n < ts_info->length; n++) {
        ts_info->data[n][0] = logistic_map(ts_info->data[n-1][0], a);
    }
    lyapunov_spectrum((const double* const*)ts_info->data, ts_info->length,
            1, 1, 5, dlogistic_map, &a, ts_info->spectrum, NULL, NULL);

    mu_assert(ts_info->spectrum[0] <= 0);


    if (ts_info->dim < 2) return;

    struct henon_info h_info;
    h_info.a = 1.4;
    h_info.b = 0.3;
    ts_info->data[0][0] = 0.4;
    ts_info->data[0][1] = 0.15;
    for (int n = 1; n < ts_info->length; n++) {
        henon_map(&h_info, ts_info->data[n-1], ts_info->data[n]);
    }
    lyapunov_spectrum((const double* const*)ts_info->data, ts_info->length,
            2, 2, 5, dhenon_map, &h_info, ts_info->spectrum, NULL, NULL);

    mu_assert(ts_info->spectrum[0] > 0);
    mu_assert(ts_info->spectrum[1] <= ts_info->spectrum[0]);

    h_info.a = 0.9;
    h_info.b = 0.3;
    ts_info->data[0][0] = 0.4;
    ts_info->data[0][1] = 0.15;
    for (int n = 1; n < ts_info->length; n++) {
        henon_map(&h_info, ts_info->data[n-1], ts_info->data[n]);
    }
    lyapunov_spectrum((const double* const*)ts_info->data, ts_info->length,
            2, 2, 5, dhenon_map, &h_info, ts_info->spectrum, NULL, NULL);

    mu_assert(ts_info->spectrum[0] <= 0);
    mu_assert(ts_info->spectrum[1] <= ts_info->spectrum[0]);
}
Пример #2
0
void thread_code(void *arg) {
	int cpuid = (int)arg;
	set_affinity(cpuid);
	
	int core_id = sched_getcpu();

	double X = logistic_map (X0, a, iters);
	if (core_id == 0) { X = X + errta; }
#if DEBUG
	fprintf(stdout, "core %d at step 1 get result: %.16f \n", core_id, X);
#endif

	double Y = inverse_pair(X, A, M);
#if DEBUG
	fprintf(stdout, "core %d at step 2 get result: %.16f \n", core_id, Y);
#endif
	double Z = logistic_map (Y, a, iters);

	fprintf(stdout, "core %d get result: %.16f \n", core_id, Z);
	pthread_exit(1);
}
Пример #3
0
static void test_lyapunov_exponent (struct test_solver_info *ts_info)
{
    if (ts_info->length <= 0 || ts_info->dim < 1) return;

    double ly_exp;
    double a;
    a = 4.0;
    ts_info->data[0][0] = 0.223;
    for (int n = 1; n < ts_info->length; n++) {
        ts_info->data[n][0] = logistic_map(ts_info->data[n-1][0], a);
    }
    ly_exp = lyapunov_exponent_sss((const double* const*)ts_info->data,
            ts_info->length, 1, 10, 1000);
    mu_assert(ly_exp > 0);
    ly_exp = lyapunov_exponent_wolf((const double* const*)ts_info->data,
            ts_info->length, 1, 0.1);
    mu_assert(ly_exp > 0);

    a = 3.5;
    ts_info->data[0][0] = 0.341;
    for (int n = 1; n < ts_info->length; n++) {
        ts_info->data[n][0] = logistic_map(ts_info->data[n-1][0], a);
    }
    ly_exp = lyapunov_exponent_sss((const double* const*)ts_info->data,
            ts_info->length, 1, 10, 1000);
    mu_assert(ly_exp <= 0);
    ly_exp = lyapunov_exponent_wolf((const double* const*)ts_info->data,
            ts_info->length, 1, 0.1);
    mu_assert(ly_exp <= 0);


    if (ts_info->dim < 2) return;

    struct henon_info h_info;
    h_info.a = 1.4;
    h_info.b = 0.3;
    ts_info->data[0][0] = 0.4;
    ts_info->data[0][1] = 0.15;
    for (int n = 1; n < ts_info->length; n++) {
        henon_map(&h_info, ts_info->data[n-1], ts_info->data[n]);
    }
    ly_exp = lyapunov_exponent_sss((const double* const*)ts_info->data,
            ts_info->length, 2, 10, 1000);
    mu_assert(ly_exp > 0);
    ly_exp = lyapunov_exponent_wolf((const double* const*)ts_info->data,
            ts_info->length, 2, 0.1);
    mu_assert(ly_exp > 0);

    h_info.a = 0.9;
    h_info.b = 0.3;
    ts_info->data[0][0] = 0.4;
    ts_info->data[0][1] = 0.15;
    for (int n = 1; n < ts_info->length; n++) {
        henon_map(&h_info, ts_info->data[n-1], ts_info->data[n]);
    }
    ly_exp = lyapunov_exponent_sss((const double* const*)ts_info->data,
            ts_info->length, 2, 10, 1000);
    mu_assert(ly_exp <= 0);
    ly_exp = lyapunov_exponent_wolf((const double* const*)ts_info->data,
            ts_info->length, 2, 0.1);
    mu_assert(ly_exp <= 0);
}