mp_limb_t nmod_mat_det(const nmod_mat_t A) { nmod_mat_t tmp; mp_limb_t det; long dim = A->r; if (dim != A->c) { printf("nmod_mat_det: nonsquare matrix"); abort(); } if (dim == 0) return 1UL; if (dim == 1) return nmod_mat_entry(A, 0, 0); nmod_mat_init_set(tmp, A); det = _nmod_mat_det(tmp); nmod_mat_clear(tmp); return det; }
int nmod_mat_inv(nmod_mat_t B, const nmod_mat_t A) { nmod_mat_t I; long i, dim; int result; dim = A->r; switch (dim) { case 0: result = 1; break; case 1: if (nmod_mat_entry(A, 0, 0) == 0UL) { result = 0; } else { nmod_mat_entry(B, 0, 0) = n_invmod(nmod_mat_entry(A, 0, 0), B->mod.n); result = 1; } break; default: nmod_mat_init(I, dim, dim, B->mod.n); for (i = 0; i < dim; i++) nmod_mat_entry(I, i, i) = 1UL; result = nmod_mat_solve(B, A, I); nmod_mat_clear(I); } return result; }
int main(void) { int i; FLINT_TEST_INIT(state); flint_printf("multi_CRT_ui...."); fflush(stdout); for (i = 0; i < 1000 * flint_test_multiplier(); i++) { slong bits, prime_bits, rows, cols, num_primes, j; fmpz_t mod; fmpz_mat_t A, B, C; nmod_mat_t Amod[1000]; mp_limb_t primes[1000]; bits = n_randint(state, 500) + 1; rows = n_randint(state, 10); cols = n_randint(state, 10); prime_bits = 1 + n_randint(state, FLINT_BITS - 1); fmpz_mat_init(A, rows, cols); fmpz_mat_init(B, rows, cols); fmpz_mat_init(C, rows, cols); fmpz_mat_randtest(A, state, bits); fmpz_init(mod); num_primes = 0; primes[0] = n_nextprime(UWORD(1) << prime_bits, 0); fmpz_set_ui(mod, primes[0]); /* + 1 for sign */ while (fmpz_bits(mod) <= bits + 1) { primes[num_primes + 1] = n_nextprime(primes[num_primes], 0); fmpz_mul_ui(mod, mod, primes[num_primes + 1]); num_primes++; } num_primes++; for (j = 0; j < num_primes; j++) nmod_mat_init(Amod[j], rows, cols, primes[j]); fmpz_mat_multi_mod_ui(Amod, num_primes, A); fmpz_mat_multi_CRT_ui(B, Amod, num_primes, 1); if (!fmpz_mat_equal(B, A)) { flint_printf("FAIL!\n"); flint_printf("primes: "); for (j = 0; j < num_primes; j++) flint_printf("%wu ", primes[j]); flint_printf("\nA: \n"); fmpz_mat_print_pretty(A); flint_printf("\nB: \n"); fmpz_mat_print_pretty(B); flint_printf("\n"); abort(); } for (j = 0; j < num_primes; j++) nmod_mat_clear(Amod[j]); fmpz_mat_clear(A); fmpz_mat_clear(B); fmpz_mat_clear(C); fmpz_clear(mod); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
int main(void) { long i; flint_rand_t state; flint_randinit(state); printf("solve_triu_recursive...."); fflush(stdout); for (i = 0; i < 1000; i++) { nmod_mat_t A, X, B, Y; mp_limb_t m; long rows, cols; int unit; m = n_randtest_prime(state, 0); rows = n_randint(state, 100); cols = n_randint(state, 100); unit = n_randint(state, 2); nmod_mat_init(A, rows, rows, m); nmod_mat_init(B, rows, cols, m); nmod_mat_init(X, rows, cols, m); nmod_mat_init(Y, rows, cols, m); nmod_mat_randtriu(A, state, unit); nmod_mat_randtest(X, state); nmod_mat_mul(B, A, X); /* Check Y = A^(-1) * (A * X) = X */ nmod_mat_solve_triu_recursive(Y, A, B, unit); if (!nmod_mat_equal(Y, X)) { printf("FAIL!\n"); printf("A:\n"); nmod_mat_print_pretty(A); printf("X:\n"); nmod_mat_print_pretty(X); printf("B:\n"); nmod_mat_print_pretty(B); printf("Y:\n"); nmod_mat_print_pretty(Y); abort(); } /* Check aliasing */ nmod_mat_solve_triu_recursive(B, A, B, unit); if (!nmod_mat_equal(B, X)) { printf("FAIL!\n"); printf("aliasing test failed"); printf("A:\n"); nmod_mat_print_pretty(A); printf("B:\n"); nmod_mat_print_pretty(B); abort(); } nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(X); nmod_mat_clear(Y); } flint_randclear(state); printf("PASS\n"); return 0; }
int main(void) { flint_rand_t state; long i; printf("sqr...."); fflush(stdout); flint_randinit(state); /* Check evaluation homomorphism */ for (i = 0; i < 1000; i++) { nmod_poly_mat_t A, C; nmod_mat_t a, c, d; mp_limb_t x, mod; long m, deg; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); deg = 1 + n_randint(state, 10); nmod_poly_mat_init(A, m, m, mod); nmod_poly_mat_init(C, m, m, mod); nmod_mat_init(a, m, m, mod); nmod_mat_init(c, m, m, mod); nmod_mat_init(d, m, m, mod); nmod_poly_mat_randtest(A, state, deg); nmod_poly_mat_randtest(C, state, deg); /* noise in output */ nmod_poly_mat_sqr(C, A); x = n_randint(state, 0); nmod_poly_mat_evaluate_nmod(a, A, x); nmod_poly_mat_evaluate_nmod(d, C, x); nmod_mat_mul(c, a, a); if (!nmod_mat_equal(c, d)) { printf("FAIL:\n"); printf("A:\n"); nmod_poly_mat_print(A, "x"); printf("C:\n"); nmod_poly_mat_print(C, "x"); printf("\n"); abort(); } nmod_poly_mat_clear(A); nmod_poly_mat_clear(C); nmod_mat_clear(a); nmod_mat_clear(c); nmod_mat_clear(d); } /* Check aliasing B and A */ for (i = 0; i < 1000; i++) { nmod_poly_mat_t A, B; long m, deg; mp_limb_t mod; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); deg = 1 + n_randint(state, 10); nmod_poly_mat_init(A, m, m, mod); nmod_poly_mat_init(B, m, m, mod); nmod_poly_mat_randtest(A, state, deg); nmod_poly_mat_randtest(B, state, deg); /* noise in output */ nmod_poly_mat_sqr(B, A); nmod_poly_mat_sqr(A, A); if (!nmod_poly_mat_equal(B, A)) { printf("FAIL (aliasing):\n"); printf("A:\n"); nmod_poly_mat_print(A, "x"); printf("B:\n"); nmod_poly_mat_print(B, "x"); printf("\n"); abort(); } nmod_poly_mat_clear(A); nmod_poly_mat_clear(B); } flint_randclear(state); _fmpz_cleanup(); printf("PASS\n"); return 0; }
int main(void) { flint_rand_t state; long i; printf("mul_interpolate...."); fflush(stdout); flint_randinit(state); /* Check evaluation homomorphism */ for (i = 0; i < 1000; i++) { nmod_poly_mat_t A, B, C; nmod_mat_t a, b, c, d; mp_limb_t mod, x; long m, n, k, deg; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); n = n_randint(state, 20); k = n_randint(state, 20); deg = 1 + n_randint(state, 10); nmod_poly_mat_init(A, m, n, mod); nmod_poly_mat_init(B, n, k, mod); nmod_poly_mat_init(C, m, k, mod); nmod_mat_init(a, m, n, mod); nmod_mat_init(b, n, k, mod); nmod_mat_init(c, m, k, mod); nmod_mat_init(d, m, k, mod); nmod_poly_mat_randtest(A, state, deg); nmod_poly_mat_randtest(B, state, deg); nmod_poly_mat_randtest(C, state, deg); /* noise in output */ if (nmod_poly_mat_max_length(A) + nmod_poly_mat_max_length(B) - 1 <= mod) { nmod_poly_mat_mul_interpolate(C, A, B); x = n_randint(state, mod); nmod_poly_mat_evaluate_nmod(a, A, x); nmod_poly_mat_evaluate_nmod(b, B, x); nmod_poly_mat_evaluate_nmod(d, C, x); nmod_mat_mul(c, a, b); if (!nmod_mat_equal(c, d)) { printf("FAIL:\n"); printf("A:\n"); nmod_poly_mat_print(A, "x"); printf("B:\n"); nmod_poly_mat_print(B, "x"); printf("C:\n"); nmod_poly_mat_print(C, "x"); printf("\n"); abort(); } } nmod_poly_mat_clear(A); nmod_poly_mat_clear(B); nmod_poly_mat_clear(C); nmod_mat_clear(a); nmod_mat_clear(b); nmod_mat_clear(c); nmod_mat_clear(d); } /* Check aliasing C and A */ for (i = 0; i < 1000; i++) { nmod_poly_mat_t A, B, C; long m, n, deg; mp_limb_t mod; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); n = n_randint(state, 20); deg = 1 + n_randint(state, 10); nmod_poly_mat_init(A, m, n, mod); nmod_poly_mat_init(B, n, n, mod); nmod_poly_mat_init(C, m, n, mod); nmod_poly_mat_randtest(A, state, deg); nmod_poly_mat_randtest(B, state, deg); nmod_poly_mat_randtest(C, state, deg); /* noise in output */ if (nmod_poly_mat_max_length(A) + nmod_poly_mat_max_length(B) - 1 <= mod) { nmod_poly_mat_mul_interpolate(C, A, B); nmod_poly_mat_mul_interpolate(A, A, B); if (!nmod_poly_mat_equal(C, A)) { printf("FAIL:\n"); printf("A:\n"); nmod_poly_mat_print(A, "x"); printf("B:\n"); nmod_poly_mat_print(B, "x"); printf("C:\n"); nmod_poly_mat_print(C, "x"); printf("\n"); abort(); } } nmod_poly_mat_clear(A); nmod_poly_mat_clear(B); nmod_poly_mat_clear(C); } /* Check aliasing C and B */ for (i = 0; i < 1000; i++) { nmod_poly_mat_t A, B, C; long m, n, deg; mp_limb_t mod; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); n = n_randint(state, 20); deg = 1 + n_randint(state, 10); nmod_poly_mat_init(A, m, m, mod); nmod_poly_mat_init(B, m, n, mod); nmod_poly_mat_init(C, m, n, mod); nmod_poly_mat_randtest(A, state, deg); nmod_poly_mat_randtest(B, state, deg); nmod_poly_mat_randtest(C, state, deg); /* noise in output */ if (nmod_poly_mat_max_length(A) + nmod_poly_mat_max_length(B) - 1 <= mod) { nmod_poly_mat_mul_interpolate(C, A, B); nmod_poly_mat_mul_interpolate(B, A, B); if (!nmod_poly_mat_equal(C, B)) { printf("FAIL:\n"); printf("A:\n"); nmod_poly_mat_print(A, "x"); printf("B:\n"); nmod_poly_mat_print(B, "x"); printf("C:\n"); nmod_poly_mat_print(C, "x"); printf("\n"); abort(); } } nmod_poly_mat_clear(A); nmod_poly_mat_clear(B); nmod_poly_mat_clear(C); } flint_randclear(state); _fmpz_cleanup(); printf("PASS\n"); return 0; }
void _nmod_poly_compose_mod_brent_kung(mp_ptr res, mp_srcptr poly1, long len1, mp_srcptr poly2, mp_srcptr poly3, long len3, nmod_t mod) { nmod_mat_t A, B, C; mp_ptr t, h; long i, n, m; n = len3 - 1; if (len3 == 1) return; if (len1 == 1) { res[0] = poly1[0]; return; } if (len3 == 2) { res[0] = _nmod_poly_evaluate_nmod(poly1, len1, poly2[0], mod); return; } m = n_sqrt(n) + 1; nmod_mat_init(A, m, n, mod.n); nmod_mat_init(B, m, m, mod.n); nmod_mat_init(C, m, n, mod.n); h = _nmod_vec_init(n); t = _nmod_vec_init(n); /* Set rows of B to the segments of poly1 */ for (i = 0; i < len1 / m; i++) _nmod_vec_set(B->rows[i], poly1 + i*m, m); _nmod_vec_set(B->rows[i], poly1 + i*m, len1 % m); /* Set rows of A to powers of poly2 */ A->rows[0][0] = 1UL; _nmod_vec_set(A->rows[1], poly2, n); for (i = 2; i < m; i++) _nmod_poly_mulmod(A->rows[i], A->rows[i-1], n, poly2, n, poly3, len3, mod); nmod_mat_mul(C, B, A); /* Evaluate block composition using the Horner scheme */ _nmod_vec_set(res, C->rows[m - 1], n); _nmod_poly_mulmod(h, A->rows[m - 1], n, poly2, n, poly3, len3, mod); for (i = m - 2; i >= 0; i--) { _nmod_poly_mulmod(t, res, n, h, n, poly3, len3, mod); _nmod_poly_add(res, t, n, C->rows[i], n, mod); } _nmod_vec_clear(h); _nmod_vec_clear(t); nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(C); }
int main(void) { slong m, n, mod, mod2, rep; FLINT_TEST_INIT(state); flint_printf("transpose...."); fflush(stdout); /* Rectangular transpose, same modulus */ for (rep = 0; rep < 100 * flint_test_multiplier(); rep++) { nmod_mat_t A, B, C; m = n_randint(state, 20); n = n_randint(state, 20); mod = n_randtest_not_zero(state); nmod_mat_init(A, m, n, mod); nmod_mat_init(B, n, m, mod); nmod_mat_init(C, m, n, mod); nmod_mat_randtest(A, state); nmod_mat_randtest(B, state); nmod_mat_transpose(B, A); nmod_mat_transpose(C, B); if (!nmod_mat_equal(C, A)) { flint_printf("FAIL: C != A\n"); abort(); } nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(C); } /* Rectangular transpose, different modulus */ for (rep = 0; rep < 100 * flint_test_multiplier(); rep++) { nmod_mat_t A, AT, B, BT, AT2; m = n_randint(state, 20); n = n_randint(state, 20); mod = n_randtest_not_zero(state); mod2 = n_randtest_not_zero(state); nmod_mat_init(A, m, n, mod); nmod_mat_init(AT, n, m, mod); nmod_mat_init(B, m, n, mod2); nmod_mat_init(BT, n, m, mod2); nmod_mat_init(AT2, n, m, mod2); nmod_mat_randtest(A, state); nmod_mat_set(B, A); nmod_mat_transpose(AT, A); nmod_mat_transpose(BT, B); nmod_mat_set(AT2, AT); if (!nmod_mat_equal(BT, AT2)) { flint_printf("FAIL: AT != BT\n"); abort(); } nmod_mat_clear(A); nmod_mat_clear(AT); nmod_mat_clear(AT2); nmod_mat_clear(B); nmod_mat_clear(BT); } /* Self-transpose */ for (rep = 0; rep < 100 * flint_test_multiplier(); rep++) { nmod_mat_t A, B; m = n_randint(state, 20); mod = n_randtest_not_zero(state); nmod_mat_init(A, m, m, mod); nmod_mat_init(B, m, m, mod); nmod_mat_randtest(A, state); nmod_mat_set(B, A); nmod_mat_transpose(B, B); nmod_mat_transpose(B, B); if (!nmod_mat_equal(B, A)) { flint_printf("FAIL: B != A\n"); abort(); } nmod_mat_clear(A); nmod_mat_clear(B); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
int main(void) { flint_rand_t state; long i; printf("nullspace...."); fflush(stdout); flint_randinit(state); for (i = 0; i < 10000; i++) { nmod_mat_t A, B, ker; mp_limb_t mod; long m, n, d, r, nullity, nulrank; m = n_randint(state, 30); n = n_randint(state, 30); for (r = 0; r <= FLINT_MIN(m,n); r++) { mod = n_randtest_prime(state, 0); d = n_randint(state, 2*m*n + 1); nmod_mat_init(A, m, n, mod); nmod_mat_init(ker, n, n, mod); nmod_mat_init(B, m, n, mod); nmod_mat_randrank(A, state, r); /* Densify */ if (n_randlimb(state) % 2) nmod_mat_randops(A, d, state); nullity = nmod_mat_nullspace(ker, A); nulrank = nmod_mat_rank(ker); if (nullity != nulrank) { printf("FAIL:\n"); printf("rank(ker) != nullity!\n"); nmod_mat_print_pretty(A); printf("\n"); abort(); } if (nullity + r != n) { printf("FAIL:\n"); printf("nullity + rank != n\n"); nmod_mat_print_pretty(A); printf("\n"); abort(); } nmod_mat_mul(B, A, ker); if (nmod_mat_rank(B) != 0) { printf("FAIL:\n"); printf("A * ker != 0\n"); nmod_mat_print_pretty(A); printf("\n"); abort(); } nmod_mat_clear(A); nmod_mat_clear(ker); nmod_mat_clear(B); } } flint_randclear(state); printf("PASS\n"); return 0; }
int main(void) { long i; flint_rand_t state; flint_randinit(state); printf("mul...."); fflush(stdout); for (i = 0; i < 10000; i++) { nmod_mat_t A, B, C, D; mp_limb_t mod; long m, k, n; m = n_randint(state, 50); k = n_randint(state, 50); n = n_randint(state, 50); /* We want to generate matrices with many entries close to half or full limbs with high probability, to stress overflow handling */ switch (n_randint(state, 3)) { case 0: mod = n_randtest_not_zero(state); break; case 1: mod = ULONG_MAX/2 + 1 - n_randbits(state, 4); break; case 2: default: mod = ULONG_MAX - n_randbits(state, 4); break; } nmod_mat_init(A, m, n, mod); nmod_mat_init(B, n, k, mod); nmod_mat_init(C, m, k, mod); nmod_mat_init(D, m, k, mod); if (n_randint(state, 2)) nmod_mat_randtest(A, state); else nmod_mat_randfull(A, state); if (n_randint(state, 2)) nmod_mat_randtest(B, state); else nmod_mat_randfull(B, state); nmod_mat_randtest(C, state); /* make sure noise in the output is ok */ nmod_mat_mul(C, A, B); nmod_mat_mul_check(D, A, B); if (!nmod_mat_equal(C, D)) { printf("FAIL: results not equal\n"); nmod_mat_print_pretty(A); nmod_mat_print_pretty(B); nmod_mat_print_pretty(C); nmod_mat_print_pretty(D); abort(); } nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(C); nmod_mat_clear(D); } flint_randclear(state); printf("PASS\n"); return 0; }
int main(void) { slong i; FLINT_TEST_INIT(state); flint_printf("rref...."); fflush(stdout); for (i = 0; i < 1000 * flint_test_multiplier(); i++) { nmod_mat_t A, B, C, D; mp_limb_t mod; slong j, k, m, n, rank1, rank2; slong *perm; int equal; mp_limb_t c; mod = n_randtest_prime(state, 0); m = n_randint(state, 20); n = n_randint(state, 20); perm = _perm_init(2*m); nmod_mat_init(A, m, n, mod); nmod_mat_init(D, 2*m, n, mod); nmod_mat_randtest(A, state); nmod_mat_init_set(B, A); nmod_mat_init_set(C, A); rank1 = nmod_mat_rref(B); if (!check_rref_form(perm, B, rank1)) { flint_printf("FAIL (malformed rref)\n"); nmod_mat_print_pretty(A); flint_printf("\n\n"); nmod_mat_print_pretty(B); flint_printf("\n\n"); abort(); } /* Concatenate the original matrix with the rref, scramble the rows, and check that the rref is the same */ _perm_randtest(perm, 2 * m, state); for (j = 0; j < m; j++) { do { c = n_randint(state, mod); } while (c == 0); for (k = 0; k < n; k++) nmod_mat_entry(D, perm[j], k) = nmod_mul(nmod_mat_entry(A, j, k), c, A->mod); } for (j = 0; j < m; j++) { do { c = n_randint(state, mod); } while (c == 0); for (k = 0; k < n; k++) nmod_mat_entry(D, perm[m + j], k) = nmod_mul(nmod_mat_entry(B, j, k), c, A->mod); } rank2 = nmod_mat_rref(D); equal = (rank1 == rank2); if (equal) { for (j = 0; j < rank2; j++) for (k = 0; k < n; k++) equal = equal && (nmod_mat_entry(B, j, k) == nmod_mat_entry(D, j, k)); for (j = rank2; j < 2 * rank2; j++) for (k = 0; k < n; k++) equal = equal && (nmod_mat_entry(D, j, k) == 0); } if (!equal) { flint_printf("FAIL (rank1 = %wd, rank2 = %wd)!\n", rank1, rank2); nmod_mat_print_pretty(A); flint_printf("\n\n"); nmod_mat_print_pretty(B); flint_printf("\n\n"); nmod_mat_print_pretty(D); flint_printf("\n\n"); abort(); } _perm_clear(perm); nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(C); nmod_mat_clear(D); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }
int main() { long iter; flint_rand_t state; printf("forward_nmod_mat...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000; iter++) { fmpz_holonomic_t op; fmpz_mat_t M1; fmpz_t Q1; nmod_mat_t M2, L, R; mp_limb_t Q2; long start, n, r; mp_limb_t p; fmpz_holonomic_init(op); fmpz_holonomic_randtest(op, state, 4, 4, 10); r = fmpz_holonomic_order(op); start = n_randint(state, 10); n = n_randint(state, 100); p = n_randtest_prime(state, 0); fmpz_mat_init(M1, r, r); fmpz_init(Q1); nmod_mat_init(M2, r, r, p); nmod_mat_init(L, r, r, p); nmod_mat_init(R, r, r, p); fmpz_holonomic_forward_fmpz_mat(M1, Q1, op, start, n); fmpz_holonomic_forward_nmod_mat(M2, &Q2, op, start, n); fmpz_mat_get_nmod_mat(L, M1); nmod_mat_scalar_mul(L, L, Q2); nmod_mat_scalar_mul(R, M2, fmpz_fdiv_ui(Q1, p)); /* check Q2 * M1 = Q1 * M2 */ if (!nmod_mat_equal(L, R)) { printf("FAIL\n"); fmpz_holonomic_print(op, "n", "Sn"); printf("\n\n"); printf("start = %lu, n = %lu\n", start, n); fmpz_mat_print_pretty(M1); printf("\n\n"); fmpz_print(Q1); printf("\n\n"); nmod_mat_print_pretty(M2); printf("\n\n"); printf("%lu\n\n", Q2); abort(); } fmpz_mat_clear(M1); fmpz_clear(Q1); nmod_mat_clear(M2); nmod_mat_clear(L); nmod_mat_clear(R); fmpz_holonomic_clear(op); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
int main(void) { slong i; FLINT_TEST_INIT(state); flint_printf("solve_triu...."); fflush(stdout); for (i = 0; i < 10 * flint_test_multiplier(); i++) { nmod_mat_t A, X, B, Y; mp_limb_t m; slong rows, cols; int unit; m = n_randtest_prime(state, 0); rows = n_randint(state, 200); cols = n_randint(state, 200); unit = n_randint(state, 2); nmod_mat_init(A, rows, rows, m); nmod_mat_init(B, rows, cols, m); nmod_mat_init(X, rows, cols, m); nmod_mat_init(Y, rows, cols, m); nmod_mat_randtriu(A, state, unit); nmod_mat_randtest(X, state); nmod_mat_mul(B, A, X); /* Check Y = A^(-1) * (A * X) = X */ nmod_mat_solve_triu(Y, A, B, unit); if (!nmod_mat_equal(Y, X)) { flint_printf("FAIL!\n"); flint_printf("A:\n"); nmod_mat_print_pretty(A); flint_printf("X:\n"); nmod_mat_print_pretty(X); flint_printf("B:\n"); nmod_mat_print_pretty(B); flint_printf("Y:\n"); nmod_mat_print_pretty(Y); abort(); } /* Check aliasing */ nmod_mat_solve_triu(B, A, B, unit); if (!nmod_mat_equal(B, X)) { flint_printf("FAIL!\n"); flint_printf("aliasing test failed"); flint_printf("A:\n"); nmod_mat_print_pretty(A); flint_printf("B:\n"); nmod_mat_print_pretty(B); abort(); } nmod_mat_clear(A); nmod_mat_clear(B); nmod_mat_clear(X); nmod_mat_clear(Y); } FLINT_TEST_CLEANUP(state); flint_printf("PASS\n"); return 0; }