Ask Your Question

vit_tucek's profile - activity

2022-07-12 21:36:48 +0200 received badge  Popular Question (source)
2022-05-17 14:29:29 +0200 asked a question Sage not listed in Jupyter kernels

Sage not listed in Jupyter kernels I just tried compiling and installing sage from source and ./sage -n runs a Jupyter i

2017-04-08 00:54:30 +0200 commented answer how to define morphism of free modules without matrices

But this workaround works. Thanks again.

2017-04-07 13:55:07 +0200 commented answer how to define morphism of free modules without matrices

Thank you, but the error happens when I try to actually construct the morphism.

2017-04-07 02:19:50 +0200 asked a question how to define morphism of free modules without matrices

I want to use sage to get some complicated mapping between free modules as a matrix. Consider the following code:

test_basis = [((0, 0, 0), (0, 0, 0)), ((0, 0, 1), (0, 0, 0)), ((0, 1, 0), (0, 0, 0)), ((1, 0, 0), (0, 0, 0))]
Domain = CombinatorialFreeModule(QQ, test_basis, prefix='D')
codomain_basis = [((0, 0, 0), (0, 0, 0)), ((0, 0, 1), (0, 0, 0)), ((0, 1, 0), (0, 0, 0)), ((1, 0, 0), (0, 0, 0))]
Codomain = CombinatorialFreeModule(QQ, codomain_basis, prefix='C')
Cb = Codomain.basis()
images = [Cb[((1, 0, 0), (0, 0, 0))]]
h = Domain.hom(images, codomain=Codomain)

I expected to obtain the homohorphism h and then just ask for the matrix, but instead I got this error:

Error in lines 7-7
Traceback (most recent call last):
  File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 982, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/structure/parent.pyx", line 1444, in sage.structure.parent.Parent.hom (/projects/sage/sage-7.5/src/build/cythonized/sage/structure/parent.c:13257)
    return self.Hom(codomain)(im_gens)
  File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/sage/categories/homset.py", line 908, in __call__
    raise TypeError("Unable to coerce x (=%s) to a morphism in %s"%(x,self))
TypeError: Unable to coerce x (=[C[((1, 0, 0), (0, 0, 0))]]) to a morphism in Set of Morphisms from Free module generated by {((0, 0, 0), (0, 0, 0)), ((0, 0, 1), (0, 0, 0)), ((0, 1, 0), (0, 0, 0)), ((1, 0, 0), (0, 0, 0))} over Rational Field to Free module generated by {((0, 0, 0), (0, 0, 0)), ((0, 0, 1), (0, 0, 0)), ((0, 1, 0), (0, 0, 0)), ((1, 0, 0), (0, 0, 0))} over Rational Field in Category of finite dimensional vector spaces with basis over Rational Field

By the way, the documentation of Free Modules is seriously lacking. For example, I have no idea what the prefix is for.