Skip to content

Commit

Permalink
New function NewOrientedMatroid
Browse files Browse the repository at this point in the history
  • Loading branch information
lizzyflight committed Jul 31, 2023
1 parent 90c0229 commit 54e148c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
16 changes: 4 additions & 12 deletions oriented_matroids/abstract_oriented_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,24 +725,16 @@ def covectors(self):
raise NotImplementedError("Covectors not implemented")


def change_type(self, new_type=None):
def NewOrientedMatroid(self, new_type=None):
'''
Returns an oriented matroid of type specified.
'''
from oriented_matroids import OrientedMatroid
if new_type == None:
pass
elif new_type == 'circuit':
return OrientedMatroid(self.circuits(),
key='circuit',
groundset=self.groundset())
elif new_type == 'vector':
return OrientedMatroid(self.vectors(),
key='vector',
groundset=self.groundset())
elif new_type == 'covector':
return OrientedMatroid(self.covectors(),
key='covector',
elif new_type in AbstractOrientedMatroid.keys:
return OrientedMatroid(getattr(self, new_type + 's'),
key=new_type,
groundset=self.groundset())
else:
raise NotImplementedError("Type not implemented")
Expand Down
34 changes: 17 additions & 17 deletions oriented_matroids/vector_oriented_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@ def _repr_(self):
rep = "Vector oriented matroid"
return rep

def circuits(self):
"""
Return the circuits.
Given a vector oriented matroid, the set of circuits is the set
`Min(V)` which denotes the set of inclusion-minimal (nonempty) signed
subsets.
"""
from sage.combinat.posets.posets import Poset
from oriented_matroids import OrientedMatroid
# remove 0
vecs = [v for v in self.vectors() if not v.is_zero()]
P = Poset([vecs, lambda x,y: x.is_restriction_of(y)])
return P.minimal_elements()

def matroid(self):
r"""
Returns the underlying matroid.
Expand All @@ -216,20 +231,5 @@ def matroid(self):
Matroid of rank 1 on 2 elements with 2 bases
"""
circOM = self.to_circuit()
return circOM.matroid()

def circuits(self):
"""
Return the circuits.
Given a vector oriented matroid, the set of circuits is the set
`Min(V)` which denotes the set of inclusion-minimal (nonempty) signed
subsets.
"""
from sage.combinat.posets.posets import Poset
from oriented_matroids import OrientedMatroid
# remove 0
vecs = [v for v in self.vectors() if not v.is_zero()]
P = Poset([vecs, lambda x,y: x.is_restriction_of(y)])
return P.minimal_elements()
circOM = self.NewOrientedMatroid(new_type='circuit')
return circOM.matroid()

0 comments on commit 54e148c

Please sign in to comment.