nmod_mat_randrank
Synopsis
#include <flint/nmod_mat.h>void nmod_mat_randrank(nmod_mat_t mat, flint_rand_t state, slong rank)sourceSets mat to a random matrix of the given rank, with exactly rank nonzero entries, each uniform in [1, n) and no two in the same row or column. Throws an exception if rank is negative or exceeds a dimension. Follow with nmod_mat_randops to obtain a dense matrix of the same rank.
For composite n the nonzero entries need not be invertible, and the rank over \mathbb{Z}/n\mathbb{Z} is then not well defined; the matrix has rank nonzero entries in distinct rows and columns.
Cite this page
The FLINT team, “nmod_mat_randrank (nmod_mat.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nmod_mat/nmod_mat_randrank.html (generated 2026-10-20).
@misc{flint-doc-nmod-mat-nmod-mat-randrank,
author = {{The FLINT team}},
title = {{nmod\_mat\_randrank (nmod\_mat.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/nmod_mat/nmod_mat_randrank.html},
note = {Generated 2026-10-20}
}