2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2016-02-27 14:57:28 -05:00
|
|
|
Copyright (C) 2016 Arb authors
|
|
|
|
|
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/>.
|
|
|
|
*/
|
2016-02-27 14:57:28 -05:00
|
|
|
|
|
|
|
#include "bool_mat.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
slong iter;
|
|
|
|
flint_rand_t state;
|
|
|
|
|
|
|
|
flint_printf("complement....");
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
flint_randinit(state);
|
|
|
|
|
|
|
|
/* zero matrix */
|
|
|
|
{
|
|
|
|
slong m, n;
|
|
|
|
for (m = 1; m < 10; m++)
|
|
|
|
{
|
|
|
|
for (n = 1; n < 10; n++)
|
|
|
|
{
|
|
|
|
bool_mat_t zero, C;
|
|
|
|
bool_mat_init(zero, m, n);
|
|
|
|
bool_mat_init(C, m, n);
|
|
|
|
bool_mat_zero(zero);
|
|
|
|
bool_mat_complement(C, zero);
|
|
|
|
if (bool_mat_any(zero) || bool_mat_all(zero) ||
|
|
|
|
!bool_mat_any(C) || !bool_mat_all(C))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL (zero matrix)\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
bool_mat_clear(zero);
|
|
|
|
bool_mat_clear(C);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* identity matrix */
|
|
|
|
{
|
|
|
|
slong n;
|
|
|
|
for (n = 2; n < 10; n++)
|
|
|
|
{
|
|
|
|
bool_mat_t one, C;
|
|
|
|
bool_mat_init(one, n, n);
|
|
|
|
bool_mat_init(C, n, n);
|
|
|
|
bool_mat_one(one);
|
|
|
|
bool_mat_complement(C, one);
|
|
|
|
if (!bool_mat_any(one) || bool_mat_all(one) ||
|
|
|
|
!bool_mat_any(C) || bool_mat_all(C))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL (identity matrix)\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
bool_mat_clear(one);
|
|
|
|
bool_mat_clear(C);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* random matrices */
|
2016-04-10 17:24:58 +02:00
|
|
|
for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++)
|
2016-02-27 14:57:28 -05:00
|
|
|
{
|
|
|
|
slong m, n;
|
2016-03-02 12:29:06 -05:00
|
|
|
bool_mat_t A, C;
|
2016-02-27 14:57:28 -05:00
|
|
|
|
|
|
|
m = n_randint(state, 10) + 1;
|
|
|
|
n = n_randint(state, 10) + 1;
|
|
|
|
|
|
|
|
bool_mat_init(A, m, n);
|
|
|
|
bool_mat_init(C, m, n);
|
|
|
|
|
|
|
|
bool_mat_randtest(A, state);
|
2016-03-02 12:29:06 -05:00
|
|
|
bool_mat_randtest(C, state);
|
2016-02-27 14:57:28 -05:00
|
|
|
bool_mat_complement(C, A);
|
|
|
|
|
|
|
|
if ((bool_mat_all(A) && bool_mat_any(C)) ||
|
|
|
|
(bool_mat_all(C) && bool_mat_any(A)))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-03-02 11:21:06 -05:00
|
|
|
/* involution */
|
|
|
|
{
|
2016-03-02 12:29:06 -05:00
|
|
|
bool_mat_t CC;
|
|
|
|
bool_mat_init(CC, m, n);
|
|
|
|
bool_mat_randtest(CC, state);
|
|
|
|
bool_mat_complement(CC, C);
|
|
|
|
if (!bool_mat_equal(A, CC))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL (involution)\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
bool_mat_clear(CC);
|
2016-03-02 11:21:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* aliasing */
|
|
|
|
bool_mat_complement(A, A);
|
|
|
|
if (!bool_mat_equal(A, C))
|
|
|
|
{
|
|
|
|
flint_printf("FAIL (aliasing)\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2016-02-27 14:57:28 -05:00
|
|
|
bool_mat_clear(A);
|
|
|
|
bool_mat_clear(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
flint_randclear(state);
|
|
|
|
flint_cleanup();
|
|
|
|
flint_printf("PASS\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|