1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
Copyright (C) 2018 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "acb_mat.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("eig_global_enclosure....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 250 * arb_test_multiplier(); iter++)
{
acb_mat_t A, X;
acb_ptr E, F, B;
mag_t eps;
slong i, j, n, prec;
int success;
n = n_randint(state, 8);
prec = 2 + n_randint(state, 100);
acb_mat_init(A, n, n);
acb_mat_init(X, n, n);
E = _acb_vec_init(n);
F = _acb_vec_init(n);
B = _acb_vec_init(n);
mag_init(eps);
for (i = 0; i < n; i++)
acb_randtest(E + i, state, prec, 3);
acb_mat_randtest_eig(A, state, E, prec);
acb_mat_approx_eig_qr(F, NULL, X, A, NULL, 0, prec);
/* perturb F further */
if (n_randint(state, 2))
{
for (i = 0; i < n; i++)
{
acb_randtest(B, state, prec, 1);
acb_mul_2exp_si(B, B, -n_randint(state, prec));
acb_add(F + i, F + i, B, prec);
}
}
acb_mat_eig_global_enclosure(eps, A, F, X, prec);
_acb_vec_set(B, F, n);
for (i = 0; i < n; i++)
acb_add_error_mag(B + i, eps);
for (i = 0; i < n; i++)
{
success = 0;
for (j = 0; j < n; j++)
{
if (acb_contains(B + j, E + i))
{
success = 1;
break;
}
}
if (!success)
{
flint_printf("FAIL\n\n");
flint_printf("A =\n");
acb_mat_printd(A, 20);
flint_printf("\n\ni = %wd\n\n", i);
flint_printf("\nE =\n");
for (j = 0; j < n; j++)
{
acb_printn(E + j, 20, 0); flint_printf("\n");
}
flint_printf("\nB =\n");
for (j = 0; j < n; j++)
{
acb_printn(B + j, 20, 0); flint_printf("\n");
}
flint_abort();
}
}
acb_mat_clear(A);
acb_mat_clear(X);
_acb_vec_clear(E, n);
_acb_vec_clear(F, n);
_acb_vec_clear(B, n);
mag_clear(eps);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}
|