sign_vectors.partial_sign_vectors¶
Auxiliary class for functions¶
There are several ways to define partial sign vectors:
sage: from sign_vectors.partial_sign_vectors import *
sage: from sign_vectors import *
sage: partial_sign_vector("+/-+p0n")
(+/-+p0n)
sage: partial_sign_vector([[1], [0, 1], [-1, 0, 1], [1]])
(+p*+)
sage: v = vector([5, 2/5, -1, 0])
sage: v = sign_vector(v)
sage: partial_sign_vector(v)
(++-0)
We construct the zero partial sign vector of a given length:
sage: PartialSignVector.zero(6)
(000000)
We construct the star partial sign vector of a given length:
sage: PartialSignVector.star(6)
(******)
There are different notions of support:
sage: X = partial_sign_vector("+/**pn0--")
sage: X.zero_support()
[2, 3, 4, 5, 6]
sage: X.positive_support()
[0, 1, 2, 3, 4]
sage: X.negative_support()
[1, 2, 3, 5, 7, 8]
There are different notions of determined support:
sage: X = partial_sign_vector("+/**pn0--")
sage: X.determined_support()
[0, 6, 7, 8]
sage: X.determined_zero_support()
[6]
sage: X.determined_positive_support()
[0]
sage: X.determined_negative_support()
[7, 8]
There is the also the undetermined support:
sage: X.undetermined_support()
[2, 3]
Next, we define two sign vectors and compose them:
sage: X = partial_sign_vector("-0pn0")
sage: Y = partial_sign_vector("0n/+0")
sage: X.compose(Y)
(-n//0)
sage: Y.compose(X)
(-n/+0)
The issubset function is a partial order on a set of partial sign vectors:
sage: X = partial_sign_vector("-+00+")
sage: Y = partial_sign_vector("-/p0+")
sage: Z = partial_sign_vector("-+**0")
sage: X.issubset(Y)
True
sage: Y.issubset(Z)
False
sage: X < Y
True
sage: X <= Z
False
Functions
|
Create a partial sign vector from a list, vector or string. |
|
Remove all partial sign vectors that are subsets of other partial sign vectors in the iterable. |
Classes
|
Utility class for sign vectors with extra functionality. |
|
A sign vector. |
- class sign_vectors.partial_sign_vectors.ExtendedSignVector(positive_support: FrozenBitset, negative_support: FrozenBitset)¶
Utility class for sign vectors with extra functionality.
- category(self)¶
File: sage/structure/sage_object.pyx (starting at line 484)
- closure() PartialSignVector¶
Return the closure of the sign vector.
EXAMPLES:
sage: from sign_vectors import * sage: X = ExtendedSignVector.from_sign_vector(sign_vector("+-00+-")) sage: X.closure() (pn**pn)
- compose(other: SignVector) SignVector¶
Return the composition of two sign vectors.
INPUT:
other– a sign vector
OUTPUT:
Composition of this sign vector with
other.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("+00") sage: X (+00) sage: Y = sign_vector("--0") sage: Y (--0) sage: X.compose(Y) (+-0) sage: Y.compose(X) (--0) sage: X = sign_vector("000+++---") sage: Y = sign_vector("0+-0+-0+-") sage: X.compose(Y) (0+-+++---)
- compose_harmonious(other: SignVector) SignVector¶
Return the composition of two harmonious sign vectors.
INPUT:
other– a sign vector
OUTPUT:
Composition of this sign vector with
other. Two sign vectors are harmonious if there are no separating elements.Note
This method is more efficient than
compose()but requires the sign vectors to be harmonious.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("+00") sage: X (+00) sage: Y = sign_vector("0-0") sage: Y (0-0) sage: X.compose_harmonious(Y) (+-0) sage: Y.compose_harmonious(X) (+-0)
- conforms(other: SignVector) bool¶
Conformal relation of two sign vectors.
Note
Alternatively, the operator
<=can be used. Use>=,<and>for the other relations.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-+00+") sage: X (-+00+) sage: Y = sign_vector("-++0+") sage: Y (-++0+) sage: Z = sign_vector("-++-+") sage: Z (-++-+) sage: X.conforms(Y) True sage: X.conforms(X) True sage: Y.conforms(Z) True sage: Z.conforms(Y) False sage: X.conforms(Z) True
- delete_components(indices: list[int]) SignVector¶
Delete the given components from the sign vector.
INPUT:
indices– list of indices to delete
OUTPUT:
Returns a new sign vector with the specified components removed.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("+0-") sage: X (+0-) sage: X.delete_components([1]) (+-)
sage: X = sign_vector("-+0+0") sage: X (-+0+0) sage: X.delete_components([0, 2]) (++0) sage: X.delete_components([1]) (-0+0)
- disjoint_support(other: SignVector) bool¶
Return whether these two sign vectors have disjoint support.
INPUT:
other– a sign vector or real vector
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("++00") sage: Y = sign_vector("0+0-") sage: Z = sign_vector("00--") sage: X.disjoint_support(Y) False sage: Y.disjoint_support(X) False sage: X.disjoint_support(Z) True sage: Z.disjoint_support(X) True sage: Y.disjoint_support(Z) False
- dump(self, filename, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 445)
Same as self.save(filename, compress)
- dumps(self, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 451)
Dump
selfto a strings, which can later be reconstituted asselfusingloads(s).There is an optional boolean argument
compresswhich defaults toTrue.EXAMPLES:
sage: from sage.misc.persist import comp sage: O = SageObject() sage: p_comp = O.dumps() sage: p_uncomp = O.dumps(compress=False) sage: comp.decompress(p_comp) == p_uncomp True sage: import pickletools sage: pickletools.dis(p_uncomp) 0: \x80 PROTO 2 2: c GLOBAL 'sage.structure.sage_object SageObject' 41: q BINPUT ... 43: ) EMPTY_TUPLE 44: \x81 NEWOBJ 45: q BINPUT ... 47: . STOP highest protocol among opcodes = 2
- flip_signs(indices: list[int]) SignVector¶
Flips entries of given indices.
INPUT:
indices– list of indices
OUTPUT: Returns a new sign vector. Components of
indicesare multiplied by-1.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-++0+") sage: X (-++0+) sage: X.flip_signs([0, 2, 3]) (++-0+)
sage: X = sign_vector("+-0+0") sage: X (+-0+0) sage: X.flip_signs([0, 3, 4]) (--0-0)
- classmethod from_iterable(iterable) SignVector¶
Create a sign vector from an iterable.
EXAMPLES:
sage: from sign_vectors import * sage: SignVector.from_iterable([5, 0, -1, -2]) (+0--) sage: v = vector([5, 0, -1, 0, 8]) sage: SignVector.from_iterable(v) (+0-0+)
- classmethod from_sign_vector(sign_vector: SignVector) ExtendedSignVector¶
Create an extended sign vector from a sign vector.
- classmethod from_string(s: str) SignVector¶
Create a sign vector from a string.
EXAMPLES:
sage: from sign_vectors import * sage: SignVector.from_string("+-0+0") (+-0+0)
- classmethod from_support(positive_support: list[int], negative_support: list[int], length: int) SignVector¶
Return a sign vector that is given by lists representing positive support and negative support.
INPUT:
positive_support– a list of integers.negative_support– a list of integers.length– a nonnegative integer
OUTPUT: a sign vector
Note
The list
positive_supportandnegative_supportshould be disjoint. For efficiency, this is not checked.EXAMPLES:
sage: from sign_vectors import * sage: SignVector.from_support([1, 4], [2], 6) (0+-0+0)
- is_harmonious_to(other: SignVector) bool¶
Check whether these two sign vectors are harmonious.
INPUT:
other– a sign vector or real vector
OUTPUT: Returns true if there are no separating elements. Otherwise, false is returned.
Note
Two sign vectors are harmonious if there is no component where one sign vector has
+and the other has-.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("++00-") sage: X (++00-) sage: Y = sign_vector("+-+++") sage: Y (+-+++) sage: X.is_harmonious_to(Y) False sage: sign_vector("0+00").is_harmonious_to(sign_vector("-+0+")) True sage: v = vector([1, 2/3, 0, -1, -1]) sage: X.is_harmonious_to(v) True sage: Y.is_harmonious_to(v) False
- is_orthogonal_to(other: SignVector) bool¶
Return whether two sign vectors are orthogonal.
INPUT:
other– a sign vector.
OUTPUT:
Returns
Trueif the sign vectors are orthogonal andFalseotherwise.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-+00+") sage: X (-+00+) sage: X.is_orthogonal_to(X) False sage: X.is_orthogonal_to(sign_vector("++000")) True sage: X.is_orthogonal_to(sign_vector("++00+")) True sage: X.is_orthogonal_to(sign_vector("00++0")) True
- is_vector() bool¶
Return
Falsesince sign vectors are not vectors.
- length() int¶
Return the length of the sign vector.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("0+-") sage: X (0+-) sage: X.length() 3
- list_from_positions(positions: list[int]) list[int]¶
Return a list of components that are in the list of indices
positions.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-+00+") sage: X (-+00+) sage: X.list_from_positions([0, 1, 4]) [-1, 1, 1]
- lower_closure() PartialSignVector¶
Return the lower closure of the partial sign vector.
EXAMPLES:
sage: from sign_vectors import * sage: X = ExtendedSignVector.from_sign_vector(sign_vector("+-00+-")) sage: X.lower_closure() (pn00pn)
- negative_support() list[int]¶
Return a list of indices where the sign vector is negative.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-0+-0") sage: X (-0+-0) sage: X.negative_support() [0, 3]
- orthogonal_complement(other: PartialSignVector | None = None) list[PartialSignVector]¶
Compute the orthogonal complement of the sign vector in a partial sign vector.
If no argument is given, the complete orthogonal complement of the sign vector is returned.
INPUT:
other– partial sign vector (optional)
OUTPUT: List of partial sign vectors.
Note
The partial sign vector
othershould only contain the signs-,0,+and*. For efficiency, this is not checked.EXAMPLES:
sage: from sign_vectors import * sage: from sign_vectors.partial_sign_vectors import * sage: X = ExtendedSignVector.from_sign_vector(sign_vector("++00-")) sage: X (++00-) sage: X.orthogonal_complement() [(00**0), (+-***), (+***+), (-+***), (*+**+), (-***-), (*-**-)] sage: Y = partial_sign_vector("**-+*") sage: Y (**-+*) sage: X.orthogonal_complement(Y) [(00-+0), (+--+*), (+*-++), (-+-+*), (*+-++), (-*-+-), (*--+-)] sage: Y = partial_sign_vector("****-") sage: Y (****-) sage: X.orthogonal_complement(Y) [(-***-), (*-**-)] sage: Y = partial_sign_vector("*+-+-") sage: Y (*+-+-) sage: X.orthogonal_complement(Y) [(-+-+-)]
- parent(self)¶
File: sage/structure/sage_object.pyx (starting at line 518)
Return the type of
selfto support the coercion framework.EXAMPLES:
sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t log(sqrt(2) + 1) + log(sqrt(2) - 1) sage: u = t.maxima_methods() sage: u.parent() <class 'sage.symbolic.maxima_wrapper.MaximaWrapper'>
- positive_support() list[int]¶
Return a list of indices where the sign vector is positive.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-0+-0") sage: X (-0+-0) sage: X.positive_support() [2]
- rename(self, x=None)¶
File: sage/structure/sage_object.pyx (starting at line 68)
Change self so it prints as x, where x is a string.
Note
This is only supported for Python classes that derive from SageObject.
EXAMPLES:
sage: x = PolynomialRing(QQ, 'x', sparse=True).gen() sage: g = x^3 + x - 5 sage: g x^3 + x - 5 sage: g.rename('a polynomial') sage: g a polynomial sage: g + x x^3 + 2*x - 5 sage: h = g^100 sage: str(h)[:20] 'x^300 + 100*x^298 - ' sage: h.rename('x^300 + ...') sage: h x^300 + ...
Real numbers are not Python classes, so rename is not supported:
sage: a = 3.14 sage: type(a) <... 'sage.rings.real_mpfr.RealLiteral'> sage: a.rename('pi') Traceback (most recent call last): ... NotImplementedError: object does not support renaming: 3.14000000000000
Note
The reason C-extension types are not supported by default is if they were then every single one would have to carry around an extra attribute, which would be slower and waste a lot of memory.
To support them for a specific class, add a
cdef public __custom_nameattribute.
- reset_name(self)¶
File: sage/structure/sage_object.pyx (starting at line 125)
Remove the custom name of an object.
EXAMPLES:
sage: P.<x> = QQ[] sage: P Univariate Polynomial Ring in x over Rational Field sage: P.rename('A polynomial ring') sage: P A polynomial ring sage: P.reset_name() sage: P Univariate Polynomial Ring in x over Rational Field
- save(self, filename=None, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 420)
Save self to the given filename.
EXAMPLES:
sage: f = x^3 + 5 sage: f.save(os.path.join(SAGE_TMP, 'file')) sage: load(os.path.join(SAGE_TMP, 'file.sobj')) x^3 + 5
- separating_elements(other: SignVector) list[int]¶
Compute the list of separating elements of two sign vectors.
INPUT:
other– sign vector
OUTPUT: List of elements
esuch thatself[e] == -other[e] != 0.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("++00-") sage: X (++00-) sage: Y = sign_vector("+-+++") sage: Y (+-+++) sage: X.separating_elements(Y) [1, 4]
- set_to_minus(indices: list[int]) SignVector¶
Set given entries to minus.
INPUT:
indices– list of indices
OUTPUT: Returns a new sign vector of same length. Components with indices in
indicesare set to-.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-++0+") sage: X (-++0+) sage: X.set_to_minus([0, 2, 3]) (-+--+)
sage: X = sign_vector("+-+0+0") sage: X (+-+0+0) sage: X.set_to_minus([0, 1, 4]) (--+0-0)
- set_to_plus(indices: list[int]) SignVector¶
Set given entries to plus.
INPUT:
indices– list of indices
OUTPUT: Returns a new sign vector of same length. Components with indices in
indicesare set to+.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-++0+") sage: X (-++0+) sage: X.set_to_plus([0, 2, 3]) (+++++)
sage: X = sign_vector("+-+0+0") sage: X (+-+0+0) sage: X.set_to_plus([0, 1, 4]) (+++0+0)
- set_to_zero(indices: list[int]) SignVector¶
Set given entries to zero.
INPUT:
indices– list of indices
OUTPUT: Returns a new sign vector of same length. Components with indices in
indicesare set to0.EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-++0+") sage: X (-++0+) sage: X.set_to_zero([0, 2, 3]) (0+00+)
sage: X = sign_vector("+-+0+0") sage: X (+-+0+0) sage: X.set_to_zero([0, 1, 4]) (00+000)
- support() list[int]¶
Return a list of indices where the sign vector is nonzero.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-0+-0") sage: X (-0+-0) sage: X.support() [0, 2, 3]
- to_string() str¶
Return a string representation of this sign vector (without parentheses).
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("0+-") sage: X (0+-) sage: X.to_string() '0+-'
Note that that str and to_string are different:
sage: str(X) '(0+-)'
- upper_closure() PartialSignVector¶
Return the upper closure of the sign vector.
EXAMPLES:
sage: from sign_vectors import * sage: X = ExtendedSignVector.from_sign_vector(sign_vector("+-00+-")) sage: X.upper_closure() (+-**+-)
- classmethod zero(length: int) SignVector¶
Create a zero sign vector of a given length.
EXAMPLES:
sage: from sign_vectors import * sage: SignVector.zero(5) (00000)
- zero_support() list[int]¶
Return a list of indices where the sign vector is zero.
EXAMPLES:
sage: from sign_vectors import * sage: X = sign_vector("-0+-0") sage: X (-0+-0) sage: X.zero_support() [1, 4]
- class sign_vectors.partial_sign_vectors.PartialSignVector(negative_support: FrozenBitset, zero_support: FrozenBitset, positive_support: FrozenBitset)¶
A sign vector.
- cardinality() int¶
Return the number of sign vectors packed in the partial sign vector .
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+*/") sage: X (-n+*/) sage: X.cardinality() 12 sage: len(X.unpack()) 12
- category(self)¶
File: sage/structure/sage_object.pyx (starting at line 484)
- closure() PartialSignVector¶
Return the closure of the partial sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("pn+-*/") sage: X.closure() (**pn**)
- complement() set[PartialSignVector]¶
Return the complement of this partial sign vector.
OUTPUT:
The complement of this partial sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n*0-+") sage: X (n*0-+) sage: C = X.complement() sage: C {(**/**), (+****), (***p*), (****n)} sage: CC = set().union(*(c.complement() for c in C)) sage: CC {(****+), (***-*), (n****), (**0**)}
- compose(other: SignVector | PartialSignVector) PartialSignVector¶
Return the composition of two (partial) sign vectors.
INPUT:
other– a (partial) sign vector
OUTPUT:
Composition of this partial sign vector with
other.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("p*0") sage: X (p*0) sage: Y = partial_sign_vector("--0") sage: Y (--0) sage: X.compose(Y) (//0) sage: Y.compose(X) (--0) sage: X = partial_sign_vector("0p0+++---") sage: Y = partial_sign_vector("/+-0+-0+-") sage: X.compose(Y) (/+-+++---)
- connecting_elements(other: SignVector | PartialSignVector) list[int]¶
Compute the list of connecting elements of two (partial) sign vectors.
INPUT:
other– (partial) sign vector
OUTPUT: List of elements
esuch thatself[e] == -other[e] != 0.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("+*-p-") sage: X (+*-p-) sage: Y = partial_sign_vector("+--++") sage: Y (+--++) sage: X.connecting_elements(Y) [0, 2]
- delete_components(indices: list[int]) PartialSignVector¶
Delete the given components from the partial sign vector.
INPUT:
indices– list of indices to delete
OUTPUT:
Returns a new partial sign vector with the specified components removed.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("+*0p-") sage: X (+*0p-) sage: X.delete_components([1, 3]) (+0-)
- determined_negative_support() list[int]¶
Return a list of indices where the partial sign vector is negative.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+0/") sage: X (-n+0/) sage: X.determined_negative_support() [0]
- determined_positive_support() list[int]¶
Return a list of indices where the partial sign vector is positive.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+0/") sage: X (-n+0/) sage: X.determined_positive_support() [2]
- determined_support() list[int]¶
Return a list of indices where the partial sign vector is determined.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+0/") sage: X (-n+0/) sage: X.determined_support() [0, 2, 3]
- determined_zero_support() list[int]¶
Return a list of indices where the partial sign vector is zero.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+0/") sage: X (-n+0/) sage: X.determined_zero_support() [3]
- dump(self, filename, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 445)
Same as self.save(filename, compress)
- dumps(self, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 451)
Dump
selfto a strings, which can later be reconstituted asselfusingloads(s).There is an optional boolean argument
compresswhich defaults toTrue.EXAMPLES:
sage: from sage.misc.persist import comp sage: O = SageObject() sage: p_comp = O.dumps() sage: p_uncomp = O.dumps(compress=False) sage: comp.decompress(p_comp) == p_uncomp True sage: import pickletools sage: pickletools.dis(p_uncomp) 0: \x80 PROTO 2 2: c GLOBAL 'sage.structure.sage_object SageObject' 41: q BINPUT ... 43: ) EMPTY_TUPLE 44: \x81 NEWOBJ 45: q BINPUT ... 47: . STOP highest protocol among opcodes = 2
- flip_signs(indices: list[int]) PartialSignVector¶
Flips entries of given indices.
INPUT:
indices– list of indices
OUTPUT: Returns a new sign vector. Components of
indicesare multiplied by-1.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-+p0+") sage: X (-+p0+) sage: X.flip_signs([0, 2, 3]) (++n0+)
- classmethod from_iterable(iterable) PartialSignVector¶
Create a sign vector from an iterable.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: PartialSignVector.from_iterable([[-1, 0, 1], [0], [-1], [0, 1]]) (*0-p)
- classmethod from_sign_vector(sv: SignVector) PartialSignVector¶
Return a sign vector that as partial sign vector. INPUT:
sv– a sign vector.
OUTPUT: a partial sign vector
Note
The list
positive_supportandnegative_supportshould be disjoint. For efficiency, this is not checked.EXAMPLES:
sage: from sign_vectors import * sage: from sign_vectors.partial_sign_vectors import * sage: X = SignVector.from_support([1, 4], [2], 6) sage: PartialSignVector.from_sign_vector(X) (0+-0+0)
- classmethod from_string(s: str) PartialSignVector¶
Create a sign vector from a string.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: PartialSignVector.from_string("+*0+/") (+*0+/)
- classmethod from_support(negative_support: list[int], zero_support: list[int], positive_support: list[int], length: int) PartialSignVector¶
Return a partial sign vector that is given by lists representing negative support, zero support and positive support.
INPUT:
negative_support– a list of integers.zero_support– a list of integers.positive_support– a list of integers.length– a nonnegative integer
OUTPUT: a partial sign vector
Note
Every index from 0 to length-1 should occur at least once in one of the lists
negative_support,zero_supportandpositive_support. For efficiency, this is not checked.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: PartialSignVector.from_support([1, 2, 4], [2, 3, 5], [0, 2, 5], 6) (+-*0-p)
- intersection(other: PartialSignVector | set[PartialSignVector]) PartialSignVector | None¶
Return the intersection of two or more partial sign vectors.
INPUT:
other– a partial sign vector
OUTPUT:
The intersection of this partial sign vector with
other.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n+0-+") sage: X (n+0-+) sage: Y = partial_sign_vector("-*0-+") sage: Y (-*0-+) sage: X.intersection(Y) (-+0-+)
- is_orthogonal_to(other: SignVector | PartialSignVector) bool¶
Return whether two (partial) sign vectors are orthogonal.
INPUT:
other– a (partial) sign vector.
OUTPUT:
Returns
Trueif the (partial) sign vectors are orthogonal andFalseotherwise.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n*0-+") sage: X (n*0-+) sage: X.is_orthogonal_to(X) False sage: X.is_orthogonal_to(partial_sign_vector("**0++")) True sage: X.is_orthogonal_to(partial_sign_vector("00+00")) True sage: X.is_orthogonal_to(partial_sign_vector("0*++0")) False
- is_sign_vector() bool¶
Return if the partial sign vector is a sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("pn+-") sage: X (pn+-) sage: X.is_sign_vector() False sage: X = partial_sign_vector("0++-") sage: X (0++-) sage: X.is_sign_vector() True
- is_vector() bool¶
Return
Falsesince sign vectors are not vectors.
- issubset(other: PartialSignVector) bool¶
subset relation of two partial sign vectors.
Note
Alternatively, the operator
<=can be used. Use>=,<and>for the other relations.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n*0-+") sage: X (n*0-+) sage: Y = partial_sign_vector("-+0-+") sage: Y (-+0-+) sage: Z = partial_sign_vector("-*0-+") sage: Z (-*0-+) sage: Y.issubset(X) True sage: X.issubset(X) True sage: Y.issubset(Z) True sage: Z.issubset(Y) False sage: Z.issubset(X) True
- length() int¶
Return the length of the sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("0+-") sage: X (0+-) sage: X.length() 3
- list_from_positions(positions: list[int]) list[int]¶
Return a list of components that are in the list of indices
positions.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-+0*p") sage: X (-+0*p) sage: X.list_from_positions([0, 1, 4]) [[-1], [1], [0, 1]]
- lower_closure() PartialSignVector¶
Return the lower closure of the partial sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("pn+-*/") sage: X.lower_closure() (pnpn**)
- negative_support() list[int]¶
Return a list of indices where the partial sign vector can be negative.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+*/") sage: X (-n+*/) sage: X.negative_support() [0, 1, 3, 4]
- parent(self)¶
File: sage/structure/sage_object.pyx (starting at line 518)
Return the type of
selfto support the coercion framework.EXAMPLES:
sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t log(sqrt(2) + 1) + log(sqrt(2) - 1) sage: u = t.maxima_methods() sage: u.parent() <class 'sage.symbolic.maxima_wrapper.MaximaWrapper'>
- positive_support() list[int]¶
Return a list of indices where the partial sign vector can be positive.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+*/") sage: X (-n+*/) sage: X.positive_support() [2, 3, 4]
- rename(self, x=None)¶
File: sage/structure/sage_object.pyx (starting at line 68)
Change self so it prints as x, where x is a string.
Note
This is only supported for Python classes that derive from SageObject.
EXAMPLES:
sage: x = PolynomialRing(QQ, 'x', sparse=True).gen() sage: g = x^3 + x - 5 sage: g x^3 + x - 5 sage: g.rename('a polynomial') sage: g a polynomial sage: g + x x^3 + 2*x - 5 sage: h = g^100 sage: str(h)[:20] 'x^300 + 100*x^298 - ' sage: h.rename('x^300 + ...') sage: h x^300 + ...
Real numbers are not Python classes, so rename is not supported:
sage: a = 3.14 sage: type(a) <... 'sage.rings.real_mpfr.RealLiteral'> sage: a.rename('pi') Traceback (most recent call last): ... NotImplementedError: object does not support renaming: 3.14000000000000
Note
The reason C-extension types are not supported by default is if they were then every single one would have to carry around an extra attribute, which would be slower and waste a lot of memory.
To support them for a specific class, add a
cdef public __custom_nameattribute.
- reset_name(self)¶
File: sage/structure/sage_object.pyx (starting at line 125)
Remove the custom name of an object.
EXAMPLES:
sage: P.<x> = QQ[] sage: P Univariate Polynomial Ring in x over Rational Field sage: P.rename('A polynomial ring') sage: P A polynomial ring sage: P.reset_name() sage: P Univariate Polynomial Ring in x over Rational Field
- save(self, filename=None, compress=True)¶
File: sage/structure/sage_object.pyx (starting at line 420)
Save self to the given filename.
EXAMPLES:
sage: f = x^3 + 5 sage: f.save(os.path.join(SAGE_TMP, 'file')) sage: load(os.path.join(SAGE_TMP, 'file.sobj')) x^3 + 5
- separating_elements(other: SignVector | PartialSignVector) list[int]¶
Compute the list of separating elements of two (partial) sign vectors.
INPUT:
other– (partial) sign vector
OUTPUT: List of elements
esuch thatself[e] == -other[e] != 0.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("+*-p-") sage: X (+*-p-) sage: Y = partial_sign_vector("+-+++") sage: Y (+-+++) sage: X.separating_elements(Y) [2, 4]
- set_sign(indices: list[int], sign: list[int] | str) PartialSignVector¶
Set given entries to selected sign.
INPUT:
indices– list of indicessign– sign as integer list or string
OUTPUT: Returns a new sign vector of same length. Components with indices in
indicesare set to-.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-++0+") sage: X (-++0+) sage: X.set_sign([0, 2, 3], "*") (*+**+) sage: X.set_sign([0, 2, 3], "n") (n+nn+) sage: X.set_sign([0, 2, 3], [0]) (0+00+)
- setminus(other: PartialSignVector | set[PartialSignVector]) set[PartialSignVector]¶
Return the set difference of two or more partial sign vectors.
INPUT:
other– a partial sign vector
OUTPUT:
The set difference of this partial sign vector with
other.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n+0-+") sage: X (n+0-+) sage: Y = partial_sign_vector("-*0-+") sage: Y (-*0-+) sage: Z = partial_sign_vector("*****") sage: X.setminus(Y) {(0+0-+)} sage: X.setminus(Z) set() sage: Z.setminus({X,Y}) {(+****), (pn***), (p**p*), (p***n), (p*/**), (**/**), (***p*), (****n)}
- classmethod star(length: int) PartialSignVector¶
Create a star partial sign vector of a given length.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: PartialSignVector.star(5) (*****)
- to_sign_vector(extended=False) bool¶
Convert this partial sign vector to a sign vector.
- to_string(index=None) str¶
Return a string representation of this sign vector (without parentheses).
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("0+-") sage: X (0+-) sage: X.to_string() '0+-'
Note that that str and to_string are different:
sage: str(X) '(0+-)'
- undetermined_support() list[int]¶
Return a list of indices where the partial sign vector is undetermined.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+*/") sage: X (-n+*/) sage: X.undetermined_support() [3]
- union(other: PartialSignVector) set[PartialSignVector]¶
Return the disjoint union of two partial sign vectors.
INPUT:
other– a partial sign vector
OUTPUT:
The union of this partial sign vector with
other.EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("n+0-+") sage: X (n+0-+) sage: Y = partial_sign_vector("-*0-+") sage: Y (-*0-+) sage: X.union(Y) {(-n0-+), (n+0-+)}
- unpack(indices: list[int] | None = None) set[SignVector] | set[PartialSignVector]¶
Return the partial sign vector as a set of (partial) sign vectors, where the given indices are determined.
INPUT:
indices– a list of indices, an integer or None
OUTPUT:
A set of (partial) sign vectors, where the given indices are determined.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("p*0") sage: X (p*0) sage: X.unpack([0]) {(+*0), (0*0)} sage: X.unpack([1, 2]) {(p00), (p+0), (p-0)} sage: X.unpack() {(000), (+-0), (0+0), (++0), (0-0), (+00)}
- upper_closure() PartialSignVector¶
Return the upper closure of the partial sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("pn+-*/") sage: X.upper_closure() (**+-*/)
- classmethod zero(length: int) PartialSignVector¶
Create a zero partial sign vector of a given length.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: PartialSignVector.zero(5) (00000)
- zero_support() list[int]¶
Return a list of indices where the partial sign vector can be zero.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: X = partial_sign_vector("-n+*/") sage: X (-n+*/) sage: X.zero_support() [1, 3]
- sign_vectors.partial_sign_vectors.partial_sign_vector(iterable: list[list[int]] | str | SignVector | PartialSignVector) PartialSignVector¶
Create a partial sign vector from a list, vector or string.
INPUT:
iterable– different inputs are accepted:an iterable (e.g. a list or vector) of lists containing
-1,0,1.a string consisting of
-,0,+,n,/,p,*.
OUTPUT:
Returns a partial sign vector.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: from sign_vectors import * sage: partial_sign_vector([[1], [0], [-1, 1] , [-1, 0]]) (+0/n) sage: v = vector([5, 0, -1, -2]) sage: v = sign_vector(v) sage: partial_sign_vector(v) (+0--)
We can also use a string to construct a partial sign vector:
sage: partial_sign_vector("00--") (00--) sage: partial_sign_vector("++n*-0/p") (++n*-0/p)
TESTS:
sage: partial_sign_vector(partial_sign_vector("+-+")) (+-+)
- sign_vectors.partial_sign_vectors.prune(iterable: set[PartialSignVector]) set[PartialSignVector]¶
Remove all partial sign vectors that are subsets of other partial sign vectors in the iterable.
INPUT:
iterable– an iterable of partial sign vectors
OUTPUT: Return a pruned set of partial sign vectors.
EXAMPLES:
sage: from sign_vectors.partial_sign_vectors import * sage: W = [partial_sign_vector("+**"), partial_sign_vector("-*+"), partial_sign_vector("-++"), partial_sign_vector("+-*")] sage: W [(+**), (-*+), (-++), (+-*)] sage: prune(W) {(-*+), (+**)} sage: prune([partial_sign_vector("000")]) set()