Loading...
Searching...
No Matches
FLINTconvert.h File Reference

This file defines functions for conversion to FLINT (www.flintlib.org) and back. More...

`#include "canonicalform.h"`
`#include "fac_util.h"`
`#include <flint/fmpz.h>`
`#include <flint/fmpq.h>`
`#include <flint/fmpz_poly.h>`
`#include <flint/fmpz_mod_poly.h>`
`#include <flint/fmpq_poly.h>`
`#include <flint/nmod_poly.h>`
`#include <flint/nmod_mat.h>`
`#include <flint/fmpz_mat.h>`
`#include <flint/fq.h>`
`#include <flint/fq_poly.h>`
`#include <flint/fq_nmod.h>`
`#include <flint/fq_nmod_poly.h>`
`#include <flint/fq_nmod_mat.h>`
`#include "factory/cf_gmp.h"`

Go to the source code of this file.

## Functions

void | convertCF2Fmpz (fmpz_t result, const CanonicalForm &f)
| conversion of a factory integer to fmpz_t
void | convertCF2initFmpz (fmpz_t result, const CanonicalForm &f)
| conversion of a factory integer to fmpz_t(init.)
void | convertFacCF2Fmpz_poly_t (fmpz_poly_t result, const CanonicalForm &f)
| conversion of a factory univariate polynomial over Z to a fmpz_poly_t
CanonicalForm | convertFmpz2CF (const fmpz_t coefficient)
| conversion of a FLINT integer to CanonicalForm
CanonicalForm | convertFmpz_poly_t2FacCF (const fmpz_poly_t poly, const Variable &x)
| conversion of a FLINT poly over Z to CanonicalForm
void | convertFacCF2nmod_poly_t (nmod_poly_t result, const CanonicalForm &f)
| conversion of a factory univariate polynomials over Z/p (for word size p) to nmod_poly_t
CanonicalForm | convertnmod_poly_t2FacCF (const nmod_poly_t poly, const Variable &x)
| conversion of a FLINT poly over Z/p to CanonicalForm
void | convertCF2Fmpq (fmpq_t result, const CanonicalForm &f)
| conversion of a factory rationals to fmpq_t
CanonicalForm | convertFmpq2CF (const fmpq_t q)
| conversion of a FLINT rational to CanonicalForm
void | convertFacCF2Fmpq_poly_t (fmpq_poly_t result, const CanonicalForm &f)
| conversion of a factory univariate polynomials over Q to fmpq_poly_t
CanonicalForm | convertFmpq_poly_t2FacCF (const fmpq_poly_t p, const Variable &x)
| conversion of a FLINT poly over Q to CanonicalForm
CFFList | convertFLINTnmod_poly_factor2FacCFFList (const nmod_poly_factor_t fac, const mp_limb_t leadingCoeff, const Variable &x)
| conversion of a FLINT factorization over Z/p (for word size p) to a CFFList
CFFList | convertFLINTfmpz_poly_factor2FacCFFList (const fmpz_poly_factor_t fac, const Variable &x)
| conversion of a FLINT factorization over Z to a CFFList
void | convertFacCF2Fmpz_mod_poly_t (fmpz_mod_poly_t result, const CanonicalForm &f, const fmpz_t p)
| conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p)
CanonicalForm | convertFmpz_mod_poly_t2FacCF (const fmpz_mod_poly_t poly, const Variable &x, const modpk &b)
| conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z
CanonicalForm | convertFq_nmod_t2FacCF (const fq_nmod_t poly, const Variable &alpha, const fq_nmod_ctx_t ctx)
| conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha
CanonicalForm | convertFq_t2FacCF (const fq_t poly, const Variable &alpha)
| conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg. variable alpha
void | convertFacCF2Fq_nmod_t (fq_nmod_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
| conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for poly
void | convertFacCF2Fq_t (fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
| conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
void | convertFacCF2Fq_poly_t (fq_poly_t result, const CanonicalForm &f, const fq_ctx_t ctx)
| conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t
void | convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
| conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
CanonicalForm | convertFq_poly_t2FacCF (const fq_poly_t p, const Variable &x, const Variable &alpha, const fq_ctx_t ctx)
| conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg. variable alpha and polynomial variable x
CanonicalForm | convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
| conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variable x
void | convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, const CFMatrix &m)
| conversion of a factory matrix over Z to a fmpz_mat_t
CFMatrix * | convertFmpz_mat_t2FacCFMatrix (const fmpz_mat_t m)
| conversion of a FLINT matrix over Z to a factory matrix
void | convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, const CFMatrix &m)
| conversion of a factory matrix over Z/p to a nmod_mat_t
CFMatrix * | convertNmod_mat_t2FacCFMatrix (const nmod_mat_t m)
| conversion of a FLINT matrix over Z/p to a factory matrix
CFMatrix * | convertFq_nmod_mat_t2FacCFMatrix (const fq_nmod_mat_t m, const fq_nmod_ctx_t &fq_con, const Variable &alpha)
| conversion of a FLINT matrix over F_q to a factory matrix
void | convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const CFMatrix &m)
| conversion of a factory matrix over F_q to a fq_nmod_mat_t
CFFList | convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t fq_con)
| conversion of a FLINT factorization over Fq (for word size p) to a CFFList

## Variables

EXTERN_VAR flint_rand_t | FLINTrandom

## Detailed Description

This file defines functions for conversion to FLINT (www.flintlib.org) and back.

Author
  Martin Lee

Definition in file FLINTconvert.h.

## Function Documentation

## convertCF2Fmpq()

void convertCF2Fmpq | ( | fmpq_t | result,
|  | const CanonicalForm & | f )

conversion of a factory rationals to fmpq_t

Parameters

  [in,out] | result | an fmpq_t
  [in] | f | a CanonicalForm wrapping a rational

Definition at line 156 of file FLINTconvert.cc.

{
//ASSERT (isOn (SW_RATIONAL), "expected rational");
if (f.isImm ())
{
fmpq_set_si(result, f.intval(), 1);
}
else if(f.inQ())
{
InternalCF *fi=f.getval();
if (fi->levelcoeff() == RationalDomain)
{
fmpz_set_mpz(fmpq_numref(result), InternalRational::MPQNUM( fi ));
fmpz_set_mpz(fmpq_denref(result), InternalRational::MPQDEN( fi ));
}
else
{
mpz_t gmp_val;
gmp_numerator (f, gmp_val);
fmpz_set_mpz (fmpq_numref (result), gmp_val);
mpz_clear (gmp_val);
gmp_denominator (f, gmp_val);
fmpz_set_mpz (fmpq_denref (result), gmp_val);
mpz_clear (gmp_val);
}
fi->deleteObject();
}
else if(f.inZ()) /* and not isImm() */
{
InternalInteger *fi=(InternalInteger*)f.getval();
fmpz_set_mpz (fmpq_numref (result), fi->thempi);
fmpz_one(fmpq_denref(result));
fi->deleteObject();
}
else
{
printf("wrong type\n");
}
}
RationalDomain
#define RationalDomain
Definition cf_defs.h:20
f
FILE * f
Definition checklibs.c:9
InternalCF
virtual class for internal CanonicalForm's
Definition int_cf.h:47
InternalCF::levelcoeff
virtual int levelcoeff() const
Definition int_cf.h:68
InternalCF::deleteObject
int deleteObject()
Definition int_cf.h:61
InternalInteger
factory's class for integers
Definition int_int.h:56
InternalInteger::thempi
mpz_t thempi
Definition int_int.h:58
InternalRational::MPQDEN
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition int_rat.h:143
InternalRational::MPQNUM
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition int_rat.h:138
result
return result
Definition facAbsBiFact.cc:76
gmp_numerator
void FACTORY_PUBLIC gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:20
gmp_denominator
void FACTORY_PUBLIC gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition singext.cc:40

## convertCF2Fmpz()

void convertCF2Fmpz | ( | fmpz_t | result,
|  | const CanonicalForm & | f )

conversion of a factory integer to fmpz_t

Parameters

  [out] | result | an fmpz_t
  [in] | f | a CanonicalForm wrapping an integer

Definition at line 120 of file FLINTconvert.cc.

{
if (f.isImm())
*result=f.intval();
else
{
fmpz_init(result);
InternalInteger *fi=(InternalInteger*)f.getval();
fmpz_set_mpz (result, fi->thempi);
}
}

## convertCF2initFmpz()

void convertCF2initFmpz | ( | fmpz_t | result,
|  | const CanonicalForm & | f )

conversion of a factory integer to fmpz_t(init.)

Parameters

  [in,out] | result | an fmpz_t
  [in] | f | a CanonicalForm wrapping an integer

Definition at line 155 of file FLINTconvert.cc.

{
if (f.isImm())
fmpz_set_si (result, f.intval());
else
{
InternalInteger *fi=(InternalInteger*)f.getval();
mpz_set(_fmpz_promote(result),fi->thempi);
_fmpz_demote_val(result);
fi->deleteObject();
}
}

## convertFacCF2Fmpq_poly_t()

void convertFacCF2Fmpq_poly_t | ( | fmpq_poly_t | result,
|  | const CanonicalForm & | f )

conversion of a factory univariate polynomials over Q to fmpq_poly_t

Parameters

  [in,out] | result | an fmpq_poly_t
  [in] | f | univariate poly over Q

Definition at line 320 of file FLINTconvert.cc.

{
bool isRat= isOn (SW_RATIONAL);
if (!isRat)
On (SW_RATIONAL);
fmpq_poly_init2 (result, degree (f)+1);
_fmpq_poly_set_length (result, degree (f) + 1);
CanonicalForm den= bCommonDen (f);
convertFacCF2Fmpz_array (fmpq_poly_numref (result), f*den);
convertCF2initFmpz (fmpq_poly_denref (result), den); // assumes initialized
if (!isRat)
Off (SW_RATIONAL);
}
convertFacCF2Fmpz_array
void convertFacCF2Fmpz_array(fmpz *result, const CanonicalForm &f)
Definition FLINTconvert.cc:314
convertCF2initFmpz
void convertCF2initFmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t(init.)
Definition FLINTconvert.cc:133
isOn
bool isOn(int sw)
switches
Definition canonicalform.cc:1971
On
void On(int sw)
switches
Definition canonicalform.cc:1957
Off
void Off(int sw)
switches
Definition canonicalform.cc:1964
degree
int degree(const CanonicalForm &f)
Definition canonicalform.h:316
den
CanonicalForm den(const CanonicalForm &f)
Definition canonicalform.h:340
bCommonDen
CanonicalForm bCommonDen(const CanonicalForm &f)
void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r,...
Definition cf_algorithm.cc:293
SW_RATIONAL
static const int SW_RATIONAL
set to 1 for computations over Q
Definition cf_defs.h:31
CanonicalForm
factory's main class
Definition canonicalform.h:86

## convertFacCF2Fmpz_mod_poly_t()

void convertFacCF2Fmpz_mod_poly_t | ( | fmpz_mod_poly_t | result,
|  | const CanonicalForm & | f,
|  | const fmpz_t | p )

conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p)

Parameters

  [in,out] | result | fmpz_mod_poly_t
  [in] | f | univariate poly over Z
  [in] | p | some integer p

Definition at line 397 of file FLINTconvert.cc.

{
#if (__FLINT_RELEASE >= 20700)
fmpz_mod_ctx_t ctx;
fmpz_mod_ctx_init(ctx,p);
fmpz_mod_poly_init2 (result, degree (f) + 1, ctx);
#else
fmpz_mod_poly_init2 (result, p, degree (f) + 1);
#endif
fmpz_poly_t buf;
convertFacCF2Fmpz_poly_t (buf, f);
#if (__FLINT_RELEASE >= 20700)
fmpz_mod_poly_set_fmpz_poly (result, buf, ctx);
fmpz_mod_ctx_clear(ctx);
#else
fmpz_mod_poly_set_fmpz_poly (result, buf);
#endif
fmpz_poly_clear (buf);
}
convertFacCF2Fmpz_poly_t
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
Definition FLINTconvert.cc:146
p
int p
Definition cfModGcd.cc:4086
buf
int status int void * buf
Definition si_signals.h:69

## convertFacCF2Fmpz_poly_t()

void convertFacCF2Fmpz_poly_t | ( | fmpz_poly_t | result,
|  | const CanonicalForm & | f )

conversion of a factory univariate polynomial over Z to a fmpz_poly_t

Parameters

  [in,out] | result | an fmpz_poly_t
  [in] | f | univariate poly over Z

Definition at line 146 of file FLINTconvert.cc.

{
fmpz_poly_init2 (result, degree (f)+1);
_fmpz_poly_set_length(result, degree(f)+1);
for (CFIterator i= f; i.hasTerms(); i++)
convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
}
i
int i
Definition cfEzgcd.cc:132
CFIterator
class to iterate through CanonicalForm's
Definition cf_iter.h:44

## convertFacCF2Fq_nmod_poly_t()

void convertFacCF2Fq_nmod_poly_t | ( | fq_nmod_poly_t | result,
|  | const CanonicalForm & | f,
|  | const fq_nmod_ctx_t | ctx )

conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t

Parameters

  [in,out] | result | fq_nmod_poly_t
  [in] | f | univariate poly over Fq
  [in] | ctx | Fq context

Definition at line 526 of file FLINTconvert.cc.

{
fq_nmod_poly_init2 (result, degree (f)+1, ctx);
_fq_nmod_poly_set_length (result, degree (f) + 1, ctx);
fq_nmod_t buf;
fq_nmod_init2 (buf, ctx);
for (CFIterator i= f; i.hasTerms(); i++)
{
convertFacCF2Fq_nmod_t (buf, i.coeff(), ctx);
fq_nmod_poly_set_coeff (result, i.exp(), buf, ctx);
fq_nmod_zero (buf, ctx);
}
fq_nmod_clear (buf, ctx);
}
convertFacCF2Fq_nmod_t
void convertFacCF2Fq_nmod_t(fq_nmod_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for po...
Definition FLINTconvert.cc:442

## convertFacCF2Fq_nmod_t()

void convertFacCF2Fq_nmod_t | ( | fq_nmod_t | result,
|  | const CanonicalForm & | f,
|  | const fq_nmod_ctx_t | ctx )

conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for poly

Parameters

  [in,out] | result | fq_nmod_t
  [in] | f | element of Fq
  [in] | ctx | Fq context

Definition at line 442 of file FLINTconvert.cc.

{
bool save_sym_ff= isOn (SW_SYMMETRIC_FF);
if (save_sym_ff) Off (SW_SYMMETRIC_FF);
#if __FLINT_RELEASE >= 20503
nmod_poly_t res;
nmod_poly_init(res,getCharacteristic());
#endif
for (CFIterator i= f; i.hasTerms(); i++)
{
CanonicalForm c= i.coeff();
if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
if (!c.isImm())
{ //This case will never happen if the characteristic is in fact a prime
// number, since all coefficients are represented as immediates
printf("convertFacCF2Fq_nmod_t: coefficient not immediate!, char=%d\n",
getCharacteristic());
}
else
{
STICKYASSERT (i.exp() <= fq_nmod_ctx_degree(ctx), "convertFacCF2Fq_nmod_t: element is not reduced");
#if __FLINT_RELEASE >= 20503
nmod_poly_set_coeff_ui (res, i.exp(), c.intval());
#else
nmod_poly_set_coeff_ui (result, i.exp(), c.intval());
#endif
}
}
#if __FLINT_RELEASE >= 20503
fq_nmod_init(result,ctx);
fq_nmod_set_nmod_poly(result,res,ctx);
#endif
if (save_sym_ff) On (SW_SYMMETRIC_FF);
}
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition cf_char.cc:70
STICKYASSERT
#define STICKYASSERT(expression, message)
Definition cf_assert.h:64
SW_SYMMETRIC_FF
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition cf_defs.h:33
CanonicalForm::intval
long intval() const
conversion functions
Definition canonicalform.cc:200
CanonicalForm::isImm
bool isImm() const
Definition canonicalform.h:110
CanonicalForm::mapinto
CanonicalForm mapinto() const
Definition canonicalform.cc:210
res
CanonicalForm res
Definition facAbsFact.cc:60
nmod_poly_init
nmod_poly_init(FLINTmipo, getCharacteristic())

## convertFacCF2Fq_poly_t()

void convertFacCF2Fq_poly_t | ( | fq_poly_t | result,
|  | const CanonicalForm & | f,
|  | const fq_ctx_t | ctx )

conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t

Parameters

  [in,out] | result | fq_poly_t
  [in] | f | univariate poly over Fq
  [in] | ctx | Fq context

Definition at line 509 of file FLINTconvert.cc.

{
fq_poly_init2 (result, degree (f)+1, ctx);
_fq_poly_set_length (result, degree (f) + 1, ctx);
for (CFIterator i= f; i.hasTerms(); i++)
{
fq_t buf;
convertFacCF2Fq_t (buf, i.coeff(), ctx);
fq_poly_set_coeff (result, i.exp(), buf, ctx);
fq_clear (buf, ctx);
}
}
convertFacCF2Fq_t
void convertFacCF2Fq_t(fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
Definition FLINTconvert.cc:485

## convertFacCF2Fq_t()

void convertFacCF2Fq_t | ( | fq_t | result,
|  | const CanonicalForm & | f,
|  | const fq_ctx_t | ctx )

conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t

Parameters

  [in,out] | result | fq_t
  [in] | f | element of Fq
  [in] | ctx | Fq context

Definition at line 485 of file FLINTconvert.cc.

{
fmpz_poly_init2 (result, fq_ctx_degree(ctx));
_fmpz_poly_set_length(result, fq_ctx_degree(ctx));
for (CFIterator i= f; i.hasTerms(); i++)
{
ASSERT(i.exp() < result->length, "input is not reduced");
convertCF2initFmpz (fmpz_poly_get_coeff_ptr(result, i.exp()), i.coeff()); // assumes initialized
}
_fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs, result->length,
fq_ctx_prime(ctx));
_fmpz_poly_normalise (result);
}
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99

## convertFacCF2nmod_poly_t()

void convertFacCF2nmod_poly_t | ( | nmod_poly_t | result,
|  | const CanonicalForm & | f )

conversion of a factory univariate polynomials over Z/p (for word size p) to nmod_poly_t

Parameters

  [in,out] | result | a nmod_poly_t
  [in] | f | univariate poly over Z/p

Definition at line 186 of file FLINTconvert.cc.

{
bool save_sym_ff= isOn(SW_SYMMETRIC_FF);
if (save_sym_ff) Off(SW_SYMMETRIC_FF);
nmod_poly_init2(result, getCharacteristic(), degree (f)+1);
for (CFIterator i= f; i.hasTerms(); i++)
{
CanonicalForm c= i.coeff();
if (!c.isImm()) c=c.mapinto(); //c%= getCharacteristic();
if (!c.isImm())
{ //This case will never happen if the characteristic is in fact a prime
// number, since all coefficients are represented as immediates
printf("convertCF2nmod_poly_t: coefficient not immediate!, char=%d\n",
getCharacteristic());
}
else
nmod_poly_set_coeff_ui (result, i.exp(), c.intval());
}
if (save_sym_ff) On(SW_SYMMETRIC_FF);
}

## convertFacCFMatrix2Fmpz_mat_t()

void convertFacCFMatrix2Fmpz_mat_t | ( | fmpz_mat_t | M,
|  | const CFMatrix & | m )

conversion of a factory matrix over Z to a fmpz_mat_t

Parameters

  [in,out] | M | fmpz_mat_t
  [in] | m | matrix over Z

Definition at line 585 of file FLINTconvert.cc.

{
fmpz_mat_init (M, (long) m.rows(), (long) m.columns());
int i,j;
for(i=m.rows();i>0;i--)
{
for(j=m.columns();j>0;j--)
{
convertCF2initFmpz (fmpz_mat_entry (M,i-1,j-1), m(i,j)); // assumes initialized
}
}
}
m
int m
Definition cfEzgcd.cc:128
j
int j
Definition facHensel.cc:110
M
#define M
Definition sirandom.c:25

## convertFacCFMatrix2Fq_nmod_mat_t()

void convertFacCFMatrix2Fq_nmod_mat_t | ( | fq_nmod_mat_t | M,
|  | const fq_nmod_ctx_t | fq_con,
|  | const CFMatrix & | m )

conversion of a factory matrix over F_q to a fq_nmod_mat_t

Parameters

  [in,out] | M | fq_nmod_mat_t
  [in] | fq_con | Fq context
  [in] | m | matrix over Fq

Definition at line 646 of file FLINTconvert.cc.

{
fq_nmod_mat_init (M, (long) m.rows(), (long) m.columns(), fq_con);
int i,j;
for(i=m.rows();i>0;i--)
{
for(j=m.columns();j>0;j--)
{
convertFacCF2nmod_poly_t (fq_nmod_mat_entry(M, i-1, j-1), m (i,j));
}
}
}
convertFacCF2nmod_poly_t
void convertFacCF2nmod_poly_t(nmod_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Z/p (for word size p) to nmod_poly_t
Definition FLINTconvert.cc:186
fq_con
fq_nmod_ctx_t fq_con
Definition facHensel.cc:99

## convertFacCFMatrix2nmod_mat_t()

void convertFacCFMatrix2nmod_mat_t | ( | nmod_mat_t | M,
|  | const CFMatrix & | m )

conversion of a factory matrix over Z/p to a nmod_mat_t

Parameters

  [in,out] | M | nmod_mat_t
  [in] | m | matrix over Z/p

Definition at line 612 of file FLINTconvert.cc.

{
nmod_mat_init (M, (long) m.rows(), (long) m.columns(), getCharacteristic());
bool save_sym_ff= isOn (SW_SYMMETRIC_FF);
if (save_sym_ff) Off (SW_SYMMETRIC_FF);
int i,j;
for(i=m.rows();i>0;i--)
{
for(j=m.columns();j>0;j--)
{
if(!(m(i,j)).isImm()) printf("convertFacCFMatrix2FLINTmat_zz_p: not imm.\n");
nmod_mat_entry (M,i-1,j-1)= (m(i,j)).intval();
}
}
if (save_sym_ff) On (SW_SYMMETRIC_FF);
}

## convertFLINTfmpz_poly_factor2FacCFFList()

CFFList convertFLINTfmpz_poly_factor2FacCFFList | ( | const fmpz_poly_factor_t | fac,
|  | const Variable & | x )

conversion of a FLINT factorization over Z to a CFFList

Parameters

  [in] | fac | a fmpz_poly_factor_t
  [in] | x | variable the result should have

## convertFLINTFq_nmod_poly_factor2FacCFFList()

CFFList convertFLINTFq_nmod_poly_factor2FacCFFList | ( | const fq_nmod_poly_factor_t | fac,
|  | const Variable & | x,
|  | const Variable & | alpha,
|  | const fq_nmod_ctx_t | fq_con )

conversion of a FLINT factorization over Fq (for word size p) to a CFFList

Parameters

  [in] | fac | fq_nmod_poly_factor_t
  [in] | x | polynomial variable
  [in] | alpha | algebraic variable
  [in] | fq_con | Fq context

Definition at line 379 of file FLINTconvert.cc.

{
CFFList result;
long i;
for (i = 0; i < fac->num; i++)
result.append (CFFactor (convertFq_nmod_poly_t2FacCF (
(fq_nmod_poly_t &)fac->poly[i], x, alpha, fq_con),
fac->exp[i]));
return result;
}
convertFq_nmod_poly_t2FacCF
CanonicalForm convertFq_nmod_poly_t2FacCF(const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variabl...
Definition FLINTconvert.cc:564
CFFList
List< CFFactor > CFFList
Definition canonicalform.h:393
CFFactor
Factor< CanonicalForm > CFFactor
Definition canonicalform.h:392
x
Variable x
Definition cfModGcd.cc:4090
alpha
Variable alpha
Definition facAbsBiFact.cc:52

## convertFLINTnmod_poly_factor2FacCFFList()

CFFList convertFLINTnmod_poly_factor2FacCFFList | ( | const nmod_poly_factor_t | fac,
|  | const mp_limb_t | leadingCoeff,
|  | const Variable & | x )

conversion of a FLINT factorization over Z/p (for word size p) to a CFFList

Parameters

  [in] | fac | a nmod_poly_factor_t
  [in] | leadingCoeff | leading coefficient
  [in] | x | variable the result should have

Definition at line 337 of file FLINTconvert.cc.

{
CFFList result;
if (leadingCoeff != 1)
result.insert (CFFactor (CanonicalForm ((long) leadingCoeff), 1));
long i;
for (i = 0; i < fac->num; i++)
result.append (CFFactor (convertnmod_poly_t2FacCF (
(nmod_poly_t &)fac->p[i],x),
fac->exp[i]));
return result;
}
convertnmod_poly_t2FacCF
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
Definition FLINTconvert.cc:208

## convertFmpq2CF()

CanonicalForm convertFmpq2CF | ( | const fmpq_t | q | ) |

conversion of a FLINT rational to CanonicalForm

Definition at line 260 of file FLINTconvert.cc.

{
bool isRat= isOn (SW_RATIONAL);
if (!isRat) On (SW_RATIONAL);
CanonicalForm result;
if (fmpz_is_one(fmpq_denref(q)))
{
if (fmpz_fits_si(fmpq_numref(q)))
{
long i=fmpz_get_si(fmpq_numref(q));
if (!isRat) Off (SW_RATIONAL);
return CanonicalForm(i);
}
mpz_t nnum;
mpz_init (nnum);
fmpz_get_mpz (nnum, fmpq_numref (q));
result= CanonicalForm( CFFactory::basic(nnum));
if (!isRat) Off (SW_RATIONAL);
return result;
}
CanonicalForm num, den;
mpz_t nnum, nden;
mpz_init (nnum);
mpz_init (nden);
fmpz_get_mpz (nnum, fmpq_numref (q));
fmpz_get_mpz (nden, fmpq_denref (q));
result= CanonicalForm( CFFactory::rational( nnum, nden, false));
if (!isRat) Off (SW_RATIONAL);
return result;
}
num
CanonicalForm num(const CanonicalForm &f)
Definition canonicalform.h:337
CFFactory::basic
static InternalCF * basic(int value)
Definition cf_factory.cc:61
CFFactory::rational
static InternalCF * rational(long num, long den)
Definition cf_factory.cc:268

## convertFmpq_poly_t2FacCF()

CanonicalForm convertFmpq_poly_t2FacCF | ( | const fmpq_poly_t | p,
|  | const Variable & | x )

conversion of a FLINT poly over Q to CanonicalForm

Parameters

  [in] | p | an fmpq_poly_t
  [in] | x | variable the result should have

Definition at line 294 of file FLINTconvert.cc.

{
CanonicalForm result= 0;
fmpq_t coeff;
long n= p->length;
for (long i= 0; i < n; i++)
{
fmpq_init (coeff);
fmpq_poly_get_coeff_fmpq (coeff, p, i);
if (fmpq_is_zero (coeff))
{
fmpq_clear (coeff);
continue;
}
result += convertFmpq2CF (coeff)*power (x, i);
fmpq_clear (coeff);
}
return result;
}
convertFmpq2CF
CanonicalForm convertFmpq2CF(const fmpq_t q)
conversion of a FLINT rational to CanonicalForm
Definition FLINTconvert.cc:260
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition canonicalform.cc:1896

## convertFmpz2CF()

CanonicalForm convertFmpz2CF | ( | const fmpz_t | coefficient | ) |

conversion of a FLINT integer to CanonicalForm

Parameters

  [in] | coefficient | a FLINT integer

Definition at line 154 of file FLINTconvert.cc.

{
if(!COEFF_IS_MPZ(*coefficient))
{
long coeff= fmpz_get_si(coefficient);
return CanonicalForm(coeff);
}
else
{
mpz_t gmp_val;
mpz_init(gmp_val);
fmpz_get_mpz(gmp_val, coefficient);
CanonicalForm result= CanonicalForm(CFFactory::basic (gmp_val));
return result;
}
}

## convertFmpz_mat_t2FacCFMatrix()

CFMatrix * convertFmpz_mat_t2FacCFMatrix | ( | const fmpz_mat_t | m | ) |

conversion of a FLINT matrix over Z to a factory matrix

Parameters

  [in] | m | fmpz_mat_t

Definition at line 598 of file FLINTconvert.cc.

{
CFMatrix *res=new CFMatrix(fmpz_mat_nrows (m),fmpz_mat_ncols (m));
int i,j;
for(i=res->rows();i>0;i--)
{
for(j=res->columns();j>0;j--)
{
(*res)(i,j)=convertFmpz2CF(fmpz_mat_entry (m,i-1,j-1));
}
}
return res;
}
convertFmpz2CF
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
Definition FLINTconvert.cc:154
CFMatrix
Matrix< CanonicalForm > CFMatrix
Definition canonicalform.h:398

## convertFmpz_mod_poly_t2FacCF()

CanonicalForm convertFmpz_mod_poly_t2FacCF | ( | const fmpz_mod_poly_t | poly,
|  | const Variable & | x,
|  | const modpk & | b )

conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z

Parameters

  [in] | poly | fmpz_mod_poly_t
  [in] | x | variable the result should have
  [in] | b | coeff bound to map coeffs in (-p/2,p/2)

Definition at line 419 of file FLINTconvert.cc.

{
fmpz_poly_t buf;
fmpz_poly_init (buf);
#if (__FLINT_RELEASE >= 20700)
fmpz_t FLINTp;
fmpz_init (FLINTp);
convertCF2initFmpz (FLINTp, b.getpk()); // assumes initialized
fmpz_mod_ctx_t ctx;
fmpz_mod_ctx_init(ctx,FLINTp);
fmpz_clear(FLINTp);
fmpz_mod_poly_get_fmpz_poly (buf, poly, ctx);
#else
fmpz_mod_poly_get_fmpz_poly (buf, poly);
#endif
CanonicalForm result= convertFmpz_poly_t2FacCF (buf, x);
fmpz_poly_clear (buf);
return b (result);
}
convertFmpz_poly_t2FacCF
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
Definition FLINTconvert.cc:172
b
CanonicalForm b
Definition cfModGcd.cc:4111

## convertFmpz_poly_t2FacCF()

CanonicalForm convertFmpz_poly_t2FacCF | ( | const fmpz_poly_t | poly,
|  | const Variable & | x )

conversion of a FLINT poly over Z to CanonicalForm

Parameters

  [in] | poly | an fmpz_poly_t
  [in] | x | variable the result should have

Definition at line 172 of file FLINTconvert.cc.

{
CanonicalForm result= 0;
fmpz* coeff;
for (int i= 0; i < fmpz_poly_length (poly); i++)
{
coeff= fmpz_poly_get_coeff_ptr(poly, i);
if (!fmpz_is_zero(coeff))
result += convertFmpz2CF(coeff)*power (x,i);
}
return result;
}

## convertFq_nmod_mat_t2FacCFMatrix()

CFMatrix * convertFq_nmod_mat_t2FacCFMatrix | ( | const fq_nmod_mat_t | m,
|  | const fq_nmod_ctx_t & | fq_con,
|  | const Variable & | alpha )

conversion of a FLINT matrix over F_q to a factory matrix

Parameters

  [in] | m | fq_nmod_mat_t
  [in] | fq_con | Fq context
  [in] | alpha | algebraic variable

Definition at line 661 of file FLINTconvert.cc.

{
CFMatrix *res=new CFMatrix(fq_nmod_mat_nrows (m, fq_con),
fq_nmod_mat_ncols (m, fq_con));
int i,j;
for(i=res->rows();i>0;i--)
{
for(j=res->columns();j>0;j--)
{
(*res)(i,j)=convertFq_nmod_t2FacCF (fq_nmod_mat_entry (m, i-1, j-1),
alpha, fq_con);
}
}
return res;
}
convertFq_nmod_t2FacCF
CanonicalForm convertFq_nmod_t2FacCF(const fq_nmod_t poly, const Variable &alpha, const fq_nmod_ctx_t)
conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha
Definition FLINTconvert.cc:479

## convertFq_nmod_poly_t2FacCF()

CanonicalForm convertFq_nmod_poly_t2FacCF | ( | const fq_nmod_poly_t | p,
|  | const Variable & | x,
|  | const Variable & | alpha,
|  | const fq_nmod_ctx_t | ctx )

conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variable x

Parameters

  [in] | p | fq_nmod_poly_t
  [in] | x | polynomial var.
  [in] | alpha | algebraic var.
  [in] | ctx | Fq context

Definition at line 564 of file FLINTconvert.cc.

{
CanonicalForm result= 0;
fq_nmod_t coeff;
long n= fq_nmod_poly_length (p, ctx);
fq_nmod_init2 (coeff, ctx);
for (long i= 0; i < n; i++)
{
fq_nmod_poly_get_coeff (coeff, p, i, ctx);
if (fq_nmod_is_zero (coeff, ctx))
continue;
result += convertFq_nmod_t2FacCF (coeff, alpha, ctx)*power (x, i);
fq_nmod_zero (coeff, ctx);
}
fq_nmod_clear (coeff, ctx);
return result;
}

## convertFq_nmod_t2FacCF()

CanonicalForm convertFq_nmod_t2FacCF | ( | const fq_nmod_t | poly,
|  | const Variable & | alpha,
|  | const fq_nmod_ctx_t | ctx )

conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha

Parameters

  [in] | poly | fq_nmod_t
  [in] | alpha | algebraic variable
  [in] | ctx | context

Definition at line 479 of file FLINTconvert.cc.

{
return convertnmod_poly_t2FacCF (poly, alpha);
}

## convertFq_poly_t2FacCF()

CanonicalForm convertFq_poly_t2FacCF | ( | const fq_poly_t | p,
|  | const Variable & | x,
|  | const Variable & | alpha,
|  | const fq_ctx_t | ctx )

conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg. variable alpha and polynomial variable x

Parameters

  [in] | p | fq_poly_t
  [in] | x | polynomial variable
  [in] | alpha | algebraic variable
  [in] | ctx | Fq context

Definition at line 543 of file FLINTconvert.cc.

{
CanonicalForm result= 0;
fq_t coeff;
long n= fq_poly_length (p, ctx);
fq_init2 (coeff, ctx);
for (long i= 0; i < n; i++)
{
fq_poly_get_coeff (coeff, p, i, ctx);
if (fq_is_zero (coeff, ctx))
continue;
result += convertFq_t2FacCF (coeff, alpha)*power (x, i);
fq_zero (coeff, ctx);
}
fq_clear (coeff, ctx);
return result;
}
convertFq_t2FacCF
CanonicalForm convertFq_t2FacCF(const fq_t poly, const Variable &alpha)
conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg....
Definition FLINTconvert.cc:503

## convertFq_t2FacCF()

CanonicalForm convertFq_t2FacCF | ( | const fq_t | poly,
|  | const Variable & | alpha )

conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg. variable alpha

Parameters

  [in] | poly | fq_t
  [in] | alpha | algebraic variable

Definition at line 503 of file FLINTconvert.cc.

{
return convertFmpz_poly_t2FacCF (poly, alpha);
}

## convertNmod_mat_t2FacCFMatrix()

CFMatrix * convertNmod_mat_t2FacCFMatrix | ( | const nmod_mat_t | m | ) |

conversion of a FLINT matrix over Z/p to a factory matrix

Parameters

  [in] | m | nmod_mat_t

Definition at line 630 of file FLINTconvert.cc.

{
CFMatrix *res=new CFMatrix(nmod_mat_nrows (m), nmod_mat_ncols (m));
int i,j;
for(i=res->rows();i>0;i--)
{
for(j=res->columns();j>0;j--)
{
(*res)(i,j)=CanonicalForm((long) nmod_mat_entry (m, i-1, j-1));
}
}
return res;
}

## convertnmod_poly_t2FacCF()

CanonicalForm convertnmod_poly_t2FacCF | ( | const nmod_poly_t | poly,
|  | const Variable & | x )

conversion of a FLINT poly over Z/p to CanonicalForm

Parameters

  [in] | poly | a nmod_poly_t
  [in] | x | variable the result should have

Definition at line 208 of file FLINTconvert.cc.

{
CanonicalForm result= 0;
for (int i= 0; i < nmod_poly_length(poly); i++)
{
ulong coeff= nmod_poly_get_coeff_ui(poly, i);
if (coeff != 0)
result += CanonicalForm ((long)coeff)*power (x,i);
}
return result;
}

## Variable Documentation

## FLINTrandom

EXTERN_VAR flint_rand_t FLINTrandom

Definition at line 57 of file FLINTconvert.h.