| 1 | initial version |
I am posting this as what I'm using in the meanwhile, but ideally it would be a method attribute of the class. The fibers() method is quite helpful here. It gives a dictionary of preimages of each element. Since we have singletons we just pop() and we know it's the inverse element.
Obviously we would want to check for bijectivity here...
> def inverse(func):
> dic = func.fibers()
> for i in func.codomain():
> dic[i] = set(dic[i]).pop()
> return FiniteSetMaps(func.codomain(),func.domain()).from_dict(dic)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.