Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr_poly_integral fails for polynomial over matrix ring #2105

Open
rburing opened this issue Nov 5, 2024 · 1 comment
Open

gr_poly_integral fails for polynomial over matrix ring #2105

rburing opened this issue Nov 5, 2024 · 1 comment

Comments

@rburing
Copy link
Contributor

rburing commented Nov 5, 2024

Example code:

#include <stdio.h>
#include "flint/gr_poly.h"

int main() {
    int status = GR_SUCCESS;

    gr_ctx_t ctx;
    gr_ctx_init_fmpq(ctx);

    gr_ctx_t mat_ctx;
    gr_ctx_init_matrix_ring(mat_ctx, ctx, 2);

    gr_poly_t f;
    gr_poly_init(f, mat_ctx);
    status |= gr_poly_gen(f, mat_ctx);

    printf("f = ");
    gr_poly_print(f, mat_ctx);
    printf("\n");

    status |= gr_poly_integral(f, f, mat_ctx);

    if (status == GR_SUCCESS) {
        printf("integral(f) = ");
        gr_poly_print(f, mat_ctx);
        printf("\n");
    } else {
        printf("failed to calculate integral(f)\n");
    }

    gr_poly_clear(f, mat_ctx);

    gr_ctx_clear(mat_ctx);
    gr_ctx_clear(ctx);

    flint_cleanup_master();

    return 0;
}

Output:

f = [[1, 0],
[0, 1]]*x
failed to calculate integral(f)

The reason is that gr_div_ui fails for elements of a matrix ring. For example:

    gr_ptr res;
    GR_TMP_INIT(res, mat_ctx);
    int my_status = gr_one(res, mat_ctx);
    my_status |= gr_div_ui(res, res, 12, mat_ctx);
    printf("success = %d\n", (my_status == GR_SUCCESS));
    GR_TMP_CLEAR(res, mat_ctx);

outputs success = 0, even though there would be a well-defined result.

@fredrik-johansson
Copy link
Collaborator

gr_mat is missing most scalar methods. Will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants