Skip to content

Commit

Permalink
fill in missing nmod functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tthsqe12 committed Dec 7, 2021
1 parent 997d514 commit 75f95ee
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
15 changes: 3 additions & 12 deletions fq_default_mat.h
Expand Up @@ -683,10 +683,7 @@ FQ_DEFAULT_MAT_INLINE int fq_default_mat_fprint(FILE * file,
}
else if (ctx->type == FQ_DEFAULT_NMOD)
{
flint_printf("operation not implemented\n");
flint_abort();
return -1;
/*return nmod_mat_fprint(file, mat->nmod);*/
return nmod_mat_fprint(file, mat->nmod);
}
else
{
Expand All @@ -707,10 +704,7 @@ FQ_DEFAULT_MAT_INLINE int fq_default_mat_fprint_pretty(FILE * file,
}
else if (ctx->type == FQ_DEFAULT_NMOD)
{
flint_printf("operation not implemented\n");
flint_abort();
return -1;
/*return nmod_mat_fprint_pretty(file, mat->nmod);*/
return nmod_mat_fprint_pretty(file, mat->nmod);
}
else
{
Expand All @@ -732,10 +726,7 @@ int fq_default_mat_print(const fq_default_mat_t mat,
}
else if (ctx->type == FQ_DEFAULT_NMOD)
{
flint_printf("operation not implemented\n");
flint_abort();
return -1;
/*return nmod_mat_print(mat->nmod);*/
return nmod_mat_print(mat->nmod);
}
else
{
Expand Down
17 changes: 16 additions & 1 deletion nmod_mat.h
Expand Up @@ -129,7 +129,22 @@ FLINT_DLL void nmod_mat_randtril(nmod_mat_t mat, flint_rand_t state, int unit);
FLINT_DLL void nmod_mat_randtriu(nmod_mat_t mat, flint_rand_t state, int unit);


FLINT_DLL void nmod_mat_print_pretty(const nmod_mat_t mat);
FLINT_DLL int nmod_mat_fprint_pretty(FILE* file, const nmod_mat_t mat);

NMOD_MAT_INLINE void nmod_mat_print_pretty(const nmod_mat_t mat)
{
nmod_mat_fprint_pretty(stdout, mat);
}

NMOD_MAT_INLINE int nmod_mat_print(const nmod_mat_t mat)
{
return nmod_mat_fprint_pretty(stdout, mat);
}

NMOD_MAT_INLINE int nmod_mat_fprint(FILE* f, const nmod_mat_t mat)
{
return nmod_mat_fprint_pretty(f, mat);
}

FLINT_DLL int nmod_mat_equal(const nmod_mat_t mat1, const nmod_mat_t mat2);

Expand Down
39 changes: 26 additions & 13 deletions nmod_mat/print_pretty.c → nmod_mat/fprint_pretty.c
@@ -1,5 +1,6 @@
/*
Copyright (C) 2010 Fredrik Johansson
Copyright (C) 2021 Daniel Schultz
This file is part of FLINT.
Expand All @@ -11,40 +12,52 @@

#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
#include "flint.h"
#include "nmod_mat.h"
#include "nmod_vec.h"
#include "ulong_extras.h"

void
nmod_mat_print_pretty(const nmod_mat_t mat)
int nmod_mat_fprint_pretty(FILE* file, const nmod_mat_t mat)
{
slong i, j;
int width;
int z, width;
char fmt[FLINT_BITS + 5];

flint_printf("<%wd x %wd integer matrix mod %wu>\n", mat->r, mat->c, mat->mod.n);
z = flint_fprintf("<%wd x %wd integer matrix mod %wu>\n", mat->r, mat->c, mat->mod.n);
if (z <= 0)
return z;

if (!(mat->c) || !(mat->r))
return;
return z;

width = n_sizeinbase(mat->mod.n, 10);

flint_sprintf(fmt, "%%%dwu", width);
z = flint_sprintf(fmt, "%%%dwu", width);
if (z <= 0)
return z;

for (i = 0; i < mat->r; i++)
{
flint_printf("[");
z = flint_printf("[");
if (z <= 0)
return z;

for (j = 0; j < mat->c; j++)
{
flint_printf(fmt, mat->rows[i][j]);
z = flint_printf(fmt, mat->rows[i][j]);
if (z <= 0)
return z;

if (j + 1 < mat->c)
flint_printf(" ");
{
z = flint_printf(" ");
if (z <= 0)
return z;
}
}

flint_printf("]\n");
if (z <= 0)
return z;
}

return z;
}

0 comments on commit 75f95ee

Please sign in to comment.