Esempio n. 1
0
const Ring /* or null */ *IM2_Ring_localization(const Ring *R, Computation *C)
{
  try
    {
      const PolyRing *PR = R->cast_to_PolyRing(); // FIXME should this get a PolyRing or Ring?
      GBComputation *P = C->cast_to_GBComputation();
      if (PR == nullptr)
        {
          ERROR("expected a polynomial ring");
          return nullptr;
        }
      if (P == nullptr)
        {
          ERROR("expected a Grobner basis computation");
          return nullptr;
        }
      if (P->get_ring() != PR)
        {
          ERROR("expected matrix to be over the same ring");
          return nullptr;
        }
      return LocalRing::create(PR, P);
  } catch (exc::engine_error e)
    {
      ERROR(e.what());
      return NULL;
  }
}
Esempio n. 2
0
extern "C" void remove_gb(void *p, void *cd)
{
  GBComputation *G = static_cast<GBComputation *>(p);
  AO_t nremoved = AO_fetch_and_add1(&gbs_nremoved);
  if (M2_gbTrace >= 3)
    fprintf(stderr, "\n --removing gb %zd at %p\n", nremoved, G);
  G->remove_gb();
}
Esempio n. 3
0
const Matrix /* or null */ *
rawGBGetParallelLeadTerms(Computation *C, M2_arrayint w)
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->get_parallel_lead_terms(w);
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 4
0
const Matrix /* or null */ *
rawGBGetLeadTerms(Computation *C, int nparts)
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->get_initial(nparts);
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 5
0
int
IM2_GB_contains(Computation *C,
                const Matrix *m)
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->contains(m);
          ERROR("computation type unknown or not implemented");
          return -2;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return -2;
     }
}
Esempio n. 6
0
const Matrix /* or null */ *
rawGBMatrixRemainder(Computation *C,
                     const Matrix *m)
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->matrix_remainder(m);
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 7
0
const Matrix /* or null */ *rawGBGetMatrix(Computation *C)
  /* Get the minimal, auto-reduced GB of a GB computation.
     Each call to this will produce a different raw matrix */
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
               return G->get_gb();
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 8
0
M2_bool IM2_GB_matrix_lift(Computation *C,
                        const Matrix *m,
                        const Matrix /* or null */ **result_remainder,
                        const Matrix /* or null */ **result_quotient
                        )
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->matrix_lift(m, result_remainder, result_quotient);
          else ERROR("computation type unknown or not implemented");
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
     }
     return false;
}
Esempio n. 9
0
const Matrix /* or null */ *rawGBMinimalGenerators(Computation *C)
  /* Yields a matrix whose columns form a minimal generating set
     for the ideal or submodule, as computed so far.  In the
     inhomogeneous case, this yields a generating set which is
     sometimes smaller than the entire Groebner basis. */
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->get_mingens();
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 10
0
const Matrix /* or null */ *rawGBSyzygies(Computation *C)
  /* Yields a matrix containing the syzygies computed so far
     via the GB computation C, assuming that 'collect_syz' was
     set when the computation was created.  If 'n_rows_to_keep' was
     set to a non-negative integer, then only that many rows of each
     syzygy are kept. */
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->get_syzygies();
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 11
0
const Matrix /* or null */ *rawGBChangeOfBasis(Computation *C)
  /* Yields the change of basis matrix from the Groebner basis to
     the original generators, at least if n_rows_to_keep was set
     when creating the GB computation.  This matrix, after the
     computation has run to completion, should satisfy:
     (original matrix) = (GB matrix) * (change of basis matrix). */
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G != 0)
            return G->get_change();
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 12
0
Computation /* or null */ *
IM2_GB_set_hilbert_function(Computation *C,
                            const RingElement *h)
{
     try {
          clear_emit_size();
          GBComputation *G = C->cast_to_GBComputation();
          if (G->get_ring()->get_degree_ring() != h->get_ring())
            {
              ERROR("expected Hilbert function hint to be in correct degree ring");
              return 0;
            }
          if (G != 0)
            return G->set_hilbert_function(h);
          ERROR("computation type unknown or not implemented");
          return 0;
     }
     catch (exc::engine_error e) {
          ERROR(e.what());
          return NULL;
     }
}
Esempio n. 13
0
 virtual void text_out(buffer &o) const { G->text_out(o); }
Esempio n. 14
0
 virtual void show() const { G->show(); }
Esempio n. 15
0
 virtual M2_bool matrix_lift(const Matrix *m,
                          const Matrix /* or null */ **result_remainder,
                          const Matrix /* or null */ **result_quotient) {
   return G->matrix_lift(m,result_remainder,result_quotient);
 }
Esempio n. 16
0
 virtual int contains(const Matrix *m) { return G->contains(m); }
Esempio n. 17
0
 virtual const Matrix /* or null */ *get_parallel_lead_terms(M2_arrayint w) { return G->get_parallel_lead_terms(w); }
Esempio n. 18
0
 virtual const Matrix /* or null */ *matrix_remainder(const Matrix *m) {
   return G->matrix_remainder(m);
 }
Esempio n. 19
0
 virtual const Matrix /* or null */ *get_syzygies() { return G->get_syzygies(); }
Esempio n. 20
0
 virtual Computation /* or null */ *set_hilbert_function(const RingElement *h)
 { return G->set_hilbert_function(h); }
Esempio n. 21
0
 virtual const Matrix /* or null */ *get_mingens() { return G->get_mingens(); }
Esempio n. 22
0
 virtual const Matrix /* or null */ *get_change() { return G->get_change(); }
Esempio n. 23
0
 ////////////////////////////////
 // Results of the computation //
 ////////////////////////////////
 virtual const Matrix /* or null */ *get_gb() { return G->get_gb(); }
Esempio n. 24
0
 virtual int complete_thru_degree() const { return G->complete_thru_degree(); }
Esempio n. 25
0
 GBComputation *replace_GB(GBComputation *G0) {
   GBComputation *result = G;
   set_status(G->status());
   G = G0;
   return result;
 }
Esempio n. 26
0
 virtual bool stop_conditions_ok() {
   G->stop_ = stop_;
   return G->stop_conditions_ok(); }
Esempio n. 27
0
 virtual const Matrix /* or null */ *get_initial(int nparts) { return G->get_initial(nparts); }
Esempio n. 28
0
 virtual void start_computation() { G->start_computation(); set_status(G->status()); }
Esempio n. 29
0
 virtual const Ring * get_ring() const { return G->get_ring(); }