Exemplo n.º 1
0
int main(void)
{
    slong i;
    FLINT_TEST_INIT(state);

    flint_printf("pow....");
    fflush(stdout);

    

    for (i = 0; i < 100 * flint_test_multiplier(); i++)
    {
        fmpz_mat_t A, B, C;
        slong i, n;
        ulong e;

        n = n_randint(state, 10);
        e = n_randint(state, 20);

        fmpz_mat_init(A, n, n);
        fmpz_mat_init(B, n, n);
        fmpz_mat_init(C, n, n);

        fmpz_mat_randtest(A, state, n_randint(state, 200) + 1);
        fmpz_mat_randtest(B, state, n_randint(state, 200) + 1);

        /* Make sure noise in the output is ok */
        fmpz_mat_randtest(B, state, n_randint(state, 200) + 1);

        fmpz_mat_pow(B, A, e);

        fmpz_mat_one(C);
        for (i = 0; i < e; i++)
            fmpz_mat_mul(C, C, A);

        if (!fmpz_mat_equal(C, B))
        {
            flint_printf("FAIL: results not equal\n");
            abort();
        }

        fmpz_mat_pow(A, A, e);

        if (!fmpz_mat_equal(A, B))
        {
            flint_printf("FAIL: aliasing failed\n");
            abort();
        }

        fmpz_mat_clear(A);
        fmpz_mat_clear(B);
        fmpz_mat_clear(C);
    }

    FLINT_TEST_CLEANUP(state);
    
    flint_printf("PASS\n");
    return 0;
}
Exemplo n.º 2
0
void
fmpz_holonomic_forward_fmpz_mat(fmpz_mat_t M, fmpz_t Q,
    const fmpz_holonomic_t op, long start, long n)
{
    long r = fmpz_holonomic_order(op);

    if (r == 0 || n == 0)
    {
        fmpz_mat_one(M);
        fmpz_one(Q);
        return;
    }

    if (n < 0)
    {
        abort();
    }

    if (fmpz_holonomic_seq_is_cfinite(op))
    {
        _fmpz_holonomic_eval_companion_matrix_fmpz(M, Q, op, 0);
        fmpz_mat_pow(M, M, n);
        fmpz_pow_ui(Q, Q, n);
    }
    else if (fmpz_holonomic_seq_is_hypgeom(op))
    {
        _fmpz_holonomic_bsplit_hypgeom_fmpz(M->rows[0], Q,
            op->coeffs, op->coeffs + 1, start, 0, n);
    }
    else
    {
        _fmpz_holonomic_forward_bsplit_fmpz(M, Q, op, start, 0, n);
    }
}