1 | initial version |
You could define two homomorphisms into the free module of rank len(v1)+len(v2)
:
sage: v1 = vector([1,2])
sage: v2 = vector([3,4])
sage: R = v1.parent(); R
Ambient free module of rank 2 over the principal ideal domain Integer Ring
sage: F = FreeModule(ZZ,4)
sage: F.gens()
((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))
sage: phi1 = R.hom(F.gens()[0:2]); phi1
Free module morphism defined by the matrix
[1 0 0 0]
[0 1 0 0]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 4 over the principal ideal domain ...
sage: phi2 = R.hom(F.gens()[2:4]); phi2
Free module morphism defined by the matrix
[0 0 1 0]
[0 0 0 1]
Domain: Ambient free module of rank 2 over the principal ideal domain ...
Codomain: Ambient free module of rank 4 over the principal ideal domain ...
sage: phi1(v1) + phi2(v2)
(1, 2, 3, 4)
Note that this may have some aesthetic appeal, but your vector(v1.list() + v2.list())
is much more direct :)