FLINT3.7.0-dev

_gr_mat_charpoly, gr_mat_charpoly, _gr_mat_charpoly_generic, gr_mat_charpoly_generic

Synopsis#include <flint/gr_mat.h>
int _gr_mat_charpoly(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx)source
int gr_mat_charpoly(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx)source
int _gr_mat_charpoly_generic(gr_ptr res, const gr_mat_t mat, gr_ctx_t ctx)source
int gr_mat_charpoly_generic(gr_poly_t res, const gr_mat_t mat, gr_ctx_t ctx)source

Set res to the characteristic polynomial \det(xI - A) of a square matrix (GR_DOMAIN otherwise). _gr_mat_charpoly calls the ring method GR_METHOD_MAT_CHARPOLY; the default _gr_mat_charpoly_generic uses Berkowitz's algorithm, which works over any commutative ring. Rings with fast arithmetic override it: nmod and fmpz_mod use Danilevsky's algorithm above dimension 8 (16 for fmpz_mod), falling back to Berkowitz when it meets a non-invertible pivot; fq and its variants use Berkowitz up to dimension 12 and Danilevsky above; fmpz and fmpq call fmpz_mat_charpoly and fmpq_mat_charpoly; mpn_mod has its own. The underscore versions write n + 1 coefficients. See Characteristic and minimal polynomials.

Guides#

Cite this page

The FLINT team, “_gr_mat_charpoly, gr_mat_charpoly, _gr_mat_charpoly_generic, gr_mat_charpoly_generic (gr_mat.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/gr_mat/_gr_mat_charpoly.html (generated 2026-10-20).