2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2014-05-15 19:56:11 +02:00
|
|
|
Copyright (C) 2012 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +02:00
|
|
|
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/>.
|
|
|
|
*/
|
2014-05-15 19:56:11 +02:00
|
|
|
|
|
|
|
#include "acb_mat.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2015-11-05 17:47:49 +00:00
|
|
|
slong iter;
|
2014-05-15 19:56:11 +02:00
|
|
|
flint_rand_t state;
|
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("det....");
|
2014-05-15 19:56:11 +02:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
|
2014-05-15 19:56:11 +02:00
|
|
|
{
|
|
|
|
fmpq_mat_t Q;
|
|
|
|
fmpq_t Qdet;
|
|
|
|
acb_mat_t A;
|
|
|
|
acb_t Adet, imagunit;
|
2015-11-05 17:47:49 +00:00
|
|
|
slong n, qbits, prec;
|
2014-05-15 19:56:11 +02:00
|
|
|
int imaginary;
|
|
|
|
|
|
|
|
n = n_randint(state, 8);
|
|
|
|
qbits = 1 + n_randint(state, 100);
|
|
|
|
prec = 2 + n_randint(state, 200);
|
|
|
|
imaginary = n_randint(state, 2);
|
|
|
|
|
|
|
|
fmpq_mat_init(Q, n, n);
|
|
|
|
fmpq_init(Qdet);
|
|
|
|
|
|
|
|
acb_mat_init(A, n, n);
|
|
|
|
acb_init(Adet);
|
|
|
|
acb_init(imagunit);
|
|
|
|
|
|
|
|
fmpq_mat_randtest(Q, state, qbits);
|
|
|
|
fmpq_mat_det(Qdet, Q);
|
|
|
|
|
|
|
|
acb_mat_set_fmpq_mat(A, Q, prec);
|
|
|
|
|
|
|
|
if (imaginary)
|
|
|
|
{
|
|
|
|
acb_onei(imagunit);
|
|
|
|
acb_mat_scalar_mul_acb(A, A, imagunit, prec);
|
|
|
|
}
|
|
|
|
|
|
|
|
acb_mat_det(Adet, A, prec);
|
|
|
|
|
|
|
|
if (imaginary)
|
|
|
|
{
|
|
|
|
acb_onei(imagunit);
|
|
|
|
acb_inv(imagunit, imagunit, prec);
|
|
|
|
acb_pow_ui(imagunit, imagunit, n, prec);
|
|
|
|
acb_mul(Adet, Adet, imagunit, prec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!acb_contains_fmpq(Adet, Qdet))
|
|
|
|
{
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("FAIL (containment, iter = %wd)\n", iter);
|
|
|
|
flint_printf("n = %wd, prec = %wd\n", n, prec);
|
|
|
|
flint_printf("\n");
|
2014-05-15 19:56:11 +02:00
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("Q = \n"); fmpq_mat_print(Q); flint_printf("\n\n");
|
|
|
|
flint_printf("Qdet = \n"); fmpq_print(Qdet); flint_printf("\n\n");
|
2014-05-15 19:56:11 +02:00
|
|
|
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("A = \n"); acb_mat_printd(A, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("Adet = \n"); acb_printd(Adet, 15); flint_printf("\n\n");
|
|
|
|
flint_printf("Adet = \n"); acb_print(Adet); flint_printf("\n\n");
|
2014-05-15 19:56:11 +02:00
|
|
|
|
2017-02-28 16:50:03 +01:00
|
|
|
flint_abort();
|
2014-05-15 19:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fmpq_mat_clear(Q);
|
|
|
|
fmpq_clear(Qdet);
|
|
|
|
acb_mat_clear(A);
|
|
|
|
acb_clear(Adet);
|
|
|
|
acb_clear(imagunit);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
2015-11-06 16:17:27 +00:00
|
|
|
flint_printf("PASS\n");
|
2014-05-15 19:56:11 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|