#include "gr_mat.h"
#include "gr_poly.h"
int
_gr_mat_charpoly_generic(gr_ptr cp, const gr_mat_t mat, gr_ctx_t ctx)
{
return _gr_mat_charpoly_berkowitz(cp, mat, ctx);
}
int gr_mat_charpoly_generic(gr_poly_t cp, const gr_mat_t mat, gr_ctx_t ctx)
{
int status;
if (mat->r != mat->c)
return GR_DOMAIN;
gr_poly_fit_length(cp, mat->r + 1, ctx);
_gr_poly_set_length(cp, mat->r + 1, ctx);
status = _gr_mat_charpoly_generic(cp->coeffs, mat, ctx);
_gr_poly_normalise(cp, ctx);
return status;
}
int
_gr_mat_charpoly(gr_ptr cp, const gr_mat_t mat, gr_ctx_t ctx)
{
return GR_MAT_UNARY_OP_GET_SCALAR(ctx, MAT_CHARPOLY)(cp, mat, ctx);
}
int gr_mat_charpoly(gr_poly_t cp, const gr_mat_t mat, gr_ctx_t ctx)
{
int status;
if (mat->r != mat->c)
return GR_DOMAIN;
gr_poly_fit_length(cp, mat->r + 1, ctx);
_gr_poly_set_length(cp, mat->r + 1, ctx);
status = _gr_mat_charpoly(cp->coeffs, mat, ctx);
_gr_poly_normalise(cp, ctx);
return status;
}