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

◆ isWellFormed()

bool MonomialIdeal::isWellFormed ( ) const
private

Definition at line 578 of file monideal.cpp.

579{
580 if (mi == nullptr) return true; // nothing else to check.
581
582 Nmi_node* p = mi;
583 while (p != nullptr)
584 {
585 // check the current node
586 if (p->left == nullptr) throw exc::engine_error("left node link is null");
587 if (p->right == nullptr) throw exc::engine_error("right node link is null");
588 if (p->header == nullptr) throw exc::engine_error("header node link is null");
589 if (p->tag == Nmi_node::node and p != mi and p->val.down == nullptr) throw exc::engine_error("down node link is null");
590
591 // now go to the next node
592 // if this is a leaf, go right.
593 // if this is a header, go down (up), and one left
594 // if this is an internal node, go down (to subtree).
595 if (p->tag == Nmi_node::node and p->header != p)
596 p = p->val.down;
597 else if (p->tag == Nmi_node::node and p->header == p)
598 {
599 // this is a header node (head of the double linked list at this level)
600 // Let's check all of the elements in the double ring at this level.
601 for (Nmi_node* q = p->right; q != p; q = q->right)
602 {
603 if (p->var != q->var) throw exc::engine_error("variable index is not consistent");
604 if (q->left->right != q) throw exc::engine_error("the double link list is inconsistent");
605 if (q->left != p and q->left->exp >= q->exp) throw exc::engine_error("exponents are not increasing going to the right");
606 }
607
608 // Now we continue
609 p = p->val.down;
610 if (p != nullptr)
611 p = p->right;
612 }
613 else if (p->tag == Nmi_node::leaf)
614 {
615 p = p->right;
616 }
617 }
618
619 return true;
620}
Nmi_node * mi
Definition monideal.hpp:138
int p

References Nmi_node::leaf, mi, Nmi_node::node, and p.