_padic_radix_mat_charpoly_berkowitz, padic_radix_mat_charpoly_hessenberg, padic_radix_mat_charpoly_lift, padic_radix_mat_charpoly
#include <flint/padic_radix.h>int _padic_radix_mat_charpoly_berkowitz(padic_radix_struct * cp, const gr_mat_t mat, gr_ctx_t ctx)sourceint padic_radix_mat_charpoly_hessenberg(padic_radix_struct * cp, const gr_mat_t mat, gr_ctx_t ctx)sourceint padic_radix_mat_charpoly_lift(padic_radix_struct * cp, const gr_mat_t mat, gr_ctx_t ctx)sourceint padic_radix_mat_charpoly(padic_radix_struct * cp, const gr_mat_t mat, gr_ctx_t ctx)sourceSet cp to the characteristic polynomial of the square matrix mat.
The berkowitz version is the division-free Berkowitz algorithm, with the matrix-vector products done on the matrix packed once (falling back to _gr_mat_charpoly_berkowitz for dimension at most 5, in contexts without a relative precision, and for matrices with exact nonzero entries). For integral entries known to it gives every coefficient to precision about , which is optimal when the matrix is cyclic modulo but can lose many digits otherwise (dozens for the low coefficients of moderately structured matrices of dimension 16).
The hessenberg version reduces the matrix to Hessenberg form by similarity transformations with pivots of minimal valuation (so that the transformations are in ), in operations; it loses a few digits.
The lift version gives the optimal precision. With the matrix scaled by a power of to make it integral, the exact lift of the entries and , a perturbation with changes by plus terms of order at least two in , whose coefficients (minors of ) are integral. Hence with , the precision of the differential of . The coefficients are computed modulo by the hessenberg version at a raised working precision (retried with more digits if needed, with the berkowitz version as a last resort), and the by the recurrence , , modulo one word first and modulo if valuations at that bound matter, with matrix products. Exact matrices give the exact characteristic polynomial (multimodular), rounded to the context precision.
The lifted entries are reduced modulo the largest working precision, so that entries of high valuation cost nothing. The working precision , where is the scaling, is large when an entry has a much smaller valuation (or error term) than the others; the lift version returns GR_UNABLE when , where is the largest relative precision of an inexact entry. For exact matrices it returns GR_UNABLE when the exact characteristic polynomial would exceed the size_limit of the context, when the entries of have more than digits for a finite context precision , or when they are dominated by powers of (valuations above four times the size of the units plus 256 digits), which Berkowitz's algorithm in handles without expanding them.
padic_radix_mat_charpoly implements the generic method. For matrices with integral entries of uniform precision that are cyclic modulo (tested with a random Krylov basis over ), the optimal precision is for every coefficient: the hessenberg version is tried first and accepted if it attains it (as for matrices that are generic modulo ), and otherwise the berkowitz version, which always does, is used. Other matrices use the lift version, together with Danilevsky's algorithm (keeping the more precise result for each coefficient) where the bound limits it, and the berkowitz version when the lift version gives up. With the context flag PADIC_RADIX_FAST_LINALG, the hessenberg version is used for all matrices.
The FLINT team, “_padic_radix_mat_charpoly_berkowitz, padic_radix_mat_charpoly_hessenberg, padic_radix_mat_charpoly_lift, padic_radix_mat_charpoly (padic_radix.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/padic_radix/_padic_radix_mat_charpoly_berkowitz.html (generated 2026-11-02).
@misc{flint-doc-padic-radix-padic-radix-mat-charpoly-berkowitz,
author = {{The FLINT team}},
title = {{\_padic\_radix\_mat\_charpoly\_berkowitz, padic\_radix\_mat\_charpoly\_hessenberg, padic\_radix\_mat\_charpoly\_lift, padic\_radix\_mat\_charpoly (padic\_radix.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/padic_radix/_padic_radix_mat_charpoly_berkowitz.html},
note = {Generated 2026-11-02}
}