/usr/lib/python2.7/dist-packages/brial/intersect.py is in python-brial 1.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #
# intersect.py
# PolyBoRi
#
# Created by Michael Brickenstein on 2008-09-24.
# Copyright 2008 The PolyBoRi Team
#
from .gbcore import groebner_basis
from .statistics import used_vars_set
from itertools import chain
def intersect(i, j, **gb_opts):
"""
This functions intersects two ideals. The first ring variable is used as helper variable for this
intersection. It is assumed, that it doesn't occur in the ideals, and that we have an elimination ordering
for this variables. Both assumptions are checked.
>>> from brial.frontend import declare_ring
>>> from brial import Block
>>> r=declare_ring(Block("x", 1000), globals())
>>> x = r.variable
>>> intersect([x(1),x(2)+1],[x(1),x(2)])
[x(1)]
"""
if not i or not j:
return []
uv = used_vars_set(i) * used_vars_set(j)
t = iter(i).next().ring().variable(0)
if uv.reducible_by(t):
raise ValueError("First ring variable has to be reserved as helper variable t")
if not t > uv:
raise ValueError("need elimination ordering for first ring variable")
gb = groebner_basis(list(chain((t * p for p in i), ((1 + t) * p for p in j
))), **gb_opts)
return [p for p in gb if p.navigation().value() > t.index()]
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
|