(a: Expression)
| 544 | if (!isCommutative) return xs; |
| 545 | |
| 546 | if (def.operator.commutativeOrder) |
| 547 | return [...xs].sort(def.operator.commutativeOrder); |
| 548 | |
| 549 | return [...xs].sort(order); |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Sort the terms of a polynomial expression (`Add` expression) according |
| 554 | * to the deglex polynomial ordering |
| 555 | * |
| 556 | */ |
| 557 | export function polynomialOrder(expr: Expression): Expression { |
| 558 | // Empirically, the Total Degree Reverse Lexicographic Order (grevlex) |
| 559 | // is often the fastest to calculate Gröbner basis. We use it as the |
| 560 | // default ordering for polynomials. |
| 561 | return degreeReverseLexicographicOrder(expr, expr.unknowns); |
| 562 | } |
| 563 | |
| 564 | export function lexicographicOrder( |
| 565 | expr: Expression, |
| 566 | vars?: ReadonlyArray<string> |
| 567 | ): Expression { |
| 568 | // This ordering is not implemented yet; preserve the input expression. |
| 569 | const _vars = vars ?? expr.unknowns; |
| 570 | return expr; |
| 571 | } |
| 572 | |
| 573 | export function degreeLexicographicOrder( |
no test coverage detected