Macaulay2 Engine
Loading...
Searching...
No Matches

◆ ann()

ring_elem PolyRingQuotient::ann ( const ring_elem a,
const ring_elem b ) const
protected

Definition at line 319 of file polyquotient.cpp.

322{
323 MatrixConstructor mata(make_FreeModule(1), 1);
324 mata.set_entry(0, 0, a);
325 Matrix *ma = mata.to_matrix(); // {a}
326
327 GBComputation *G = make_gb(b);
328
329 const Matrix *mrem, *mquot;
330 G->matrix_lift(ma, &mrem, &mquot);
331 // if (M2_gbTrace >= 2)
332 // {
333 // emit("ann a=");
334 // dringelem(this, a);
335 // emit(" b=");
336 // dringelem(this, b);
337 // emit_line("----------");
338 // emit_line(" G->get_gb is ");
339 // dmatrix(G->get_gb());
340 // emit_line(" G ->get_change()");
341 // dmatrix(G->get_change());
342 // emit_line("----------");
343 // emit_line(" mrem is ");
344 // dmatrix(mrem);
345 // emit_line(" mquot is ");
346 // dmatrix(mquot);
347 // emit_line("---------------");
348 // emit_line("-- gb(b): -----");
349 // G->show();
350 // emit_line("---------------");
351 // }
352 if (mquot->n_cols() == 0 || !mrem->is_zero())
353 {
354 // We have just determined that a/b does not exist.
355 // So b is not a unit in this ring.
356 set_non_unit(b);
357 return from_long(0);
358 }
359 ring_elem answer = mquot->elem(0,0); // possibly off by a scalar?
360 ring_elem a1 = mult (answer, b);
361 if (not is_equal(a1, a))
362 {
363 // so answer * b == a1,
364 // and a1 * c == a. Check this?
365 // so (answer * c) * b == a
366
367 // emit("a1=");
368 // dringelem(this, a1);
369 // emit_line("");
370 ring_elem c = divide(a, a1);
371 if (not is_equal(mult(a1, c), a))
372 {
373 set_non_unit(b);
374 return from_long(0);
375 }
376 answer = mult(c, answer);
377 }
378 return answer;
379}
ring_elem elem(int i, int j) const
Definition matrix.cpp:307
bool is_zero() const
Definition matrix.cpp:325
int n_cols() const
Definition matrix.hpp:147
virtual ring_elem divide(const ring_elem f, const ring_elem g) const
virtual ring_elem from_long(long n) const
virtual bool is_equal(const ring_elem f, const ring_elem g) const
GBComputation * make_gb(const ring_elem g) const
virtual ring_elem mult(const ring_elem f, const ring_elem g) const
void set_non_unit(ring_elem zero_div) const
Definition ring.cpp:88
virtual FreeModule * make_FreeModule() const
Definition ring.cpp:53
#define Matrix
Definition factory.cpp:14
tbb::flow::graph G

References divide(), Matrix::elem(), from_long(), G, RingMap::is_equal(), Matrix::is_zero(), Ring::make_FreeModule(), make_gb(), Matrix, mult(), Matrix::n_cols(), MatrixConstructor::set_entry(), Ring::set_non_unit(), and MatrixConstructor::to_matrix().

Referenced by divide(), and invert().