Macaulay2 Engine
Loading...
Searching...
No Matches
cra.hpp
Go to the documentation of this file.
1// Copyright 2011 Michael E. Stillman
2
3#ifndef _cra_hpp_
4#define _cra_hpp_
5
34
35#include <M2/math-include.h>
36
37#include "ringelem.hpp" // for ring_elem, vec
38
39class Matrix;
40class PolyRing;
41class RingElement;
42
43// !!!! we need the balanced residue class in chinese remainder !!!
44
49{
50 public:
51 static void CRA0(mpz_srcptr a,
52 mpz_srcptr b,
53 mpz_srcptr um,
54 mpz_srcptr vn,
55 mpz_srcptr mn,
56 mpz_t result);
57 // computes using precomputed multipliers, the unique integer 'result' < m*n
58 // s.t.
59 // result == a mod m, and == b mod n.
60 // 1 = u*m + v*n, and um = u*m, vn = v*n, mn = m*n
61
62 static bool computeMultipliers(mpz_srcptr m,
63 mpz_srcptr n,
64 mpz_t result_um,
65 mpz_t result_vn,
66 mpz_t result_mn);
67 // computes the multipliers um, vn, mn used in CRA0
68
69 static ring_elem CRA(const PolyRing *R,
70 const ring_elem f,
71 const ring_elem g,
72 mpz_srcptr um,
73 mpz_srcptr vn,
74 mpz_srcptr mn);
75 // does the vector combination without error checking and with precomputed
76 // multipliers
77
78 static vec CRA(const PolyRing *R, vec f, vec g, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn);
79 // does the vector combination without error checking and with precomputed
80 // multipliers
81
82 static Matrix *CRA(const Matrix *f,
83 const Matrix *g,
84 mpz_srcptr um,
85 mpz_srcptr vn,
86 mpz_srcptr mn);
87 // does the matrix combination without error checking and with precomputed
88 // multipliers
89
90 static RingElement *CRA(const RingElement *f,
91 const RingElement *g,
92 mpz_srcptr um,
93 mpz_srcptr vn,
94 mpz_srcptr mn);
95 // does the ring element combination without error checking and with
96 // precomputed multipliers
97
98 static bool ratConversion(mpz_srcptr a, mpz_srcptr m, mpq_t result);
99 // computes a rational number "result" that reduces to a mod m
100 // if the numerator and denominator can be chosen to smaller than
101 // 1/2*sqrt(m) then "true" is returned.
102
103 static ring_elem ratConversion(const ring_elem f,
104 mpz_srcptr m,
105 const PolyRing *RQ);
106 // computes a polynomial with rational coefficients that reduces
107 // to f mod m; f should be in a polynomial ring ZZ[M] and RQ=QQ[M]
108
109 static vec ratConversion(vec f, mpz_srcptr m, const PolyRing *RQ);
110 // computes a polynomial with rational coefficients that reduces
111 // to f mod m; f should be in a polynomial ring ZZ[M] and RQ=QQ[M]
112
113 static ring_elem CRA(const PolyRing *R,
114 ring_elem f,
115 ring_elem g,
116 mpz_srcptr m,
117 mpz_srcptr n);
118 // Assumption: f and g are in a poly ring whose coeff ring is ZZ
119};
120
121#endif
122
123// Local Variables:
124// indent-tabs-mode: nil
125// End:
static RingElement * CRA(const RingElement *f, const RingElement *g, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn)
static bool computeMultipliers(mpz_srcptr m, mpz_srcptr n, mpz_t result_um, mpz_t result_vn, mpz_t result_mn)
Definition cra.cpp:36
static bool ratConversion(mpz_srcptr a, mpz_srcptr m, mpq_t result)
Definition cra.cpp:300
static ring_elem CRA(const PolyRing *R, const ring_elem f, const ring_elem g, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn)
Definition cra.cpp:53
static void CRA0(mpz_srcptr a, mpz_srcptr b, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn, mpz_t result)
Definition cra.cpp:15
Concrete PolyRingFlat subclass implementing ordinary commutative polynomial rings K[x_1,...
Definition poly.hpp:64
Front-end-visible "ring element" value: an engine ring_elem paired with the Ring* that gives it meani...
Definition relem.hpp:67
#define Matrix
Definition factory.cpp:14
VALGRIND_MAKE_MEM_DEFINED & result(result)
ring_elem — the universal value type carried by every Ring* in the engine.