### Navigation

- index
- modules |
- next |
- previous |
- Modules »

# Space of Morphisms of Vector Spaces (Linear Transformations)

AUTHOR:

> - Rob Beezer: (2011-06-29)

A `VectorSpaceHomspace` object represents the set of all possible homomorphisms from one vector space to another. These mappings are usually known as linear transformations.

For more information on the use of linear transformations, consult the documentation for vector space morphisms at `sage.modules.vector_space_morphism`. Also, this is an extremely thin veneer on free module homspaces (`sage.modules.free_module_homspace`) and free module morphisms (`sage.modules.free_module_morphism`) - objects which might also be useful, and places where much of the documentation resides.

EXAMPLES:

Creation and basic examination is simple.

    sage: V = QQ^3
    sage: W = QQ^2
    sage: H = Hom(V, W)
    sage: H
    Set of Morphisms (Linear Transformations) from
    Vector space of dimension 3 over Rational Field to
    Vector space of dimension 2 over Rational Field
    sage: H.domain()
    Vector space of dimension 3 over Rational Field
    sage: H.codomain()
    Vector space of dimension 2 over Rational Field

Homspaces have a few useful properties. A basis is provided by a list of matrix representations, where these matrix representatives are relative to the bases of the domain and codomain.

    sage: K = Hom(GF(3)^2, GF(3)^2)
    sage: B = K.basis()
    sage: for f in B:
    ...     print f, "\n"
    Vector space morphism represented by the matrix:
    [1 0]
    [0 0]
    Domain: Vector space of dimension 2 over Finite Field of size 3
    Codomain: Vector space of dimension 2 over Finite Field of size 3
    <BLANKLINE>
    Vector space morphism represented by the matrix:
    [0 1]
    [0 0]
    Domain: Vector space of dimension 2 over Finite Field of size 3
    Codomain: Vector space of dimension 2 over Finite Field of size 3
    <BLANKLINE>
    Vector space morphism represented by the matrix:
    [0 0]
    [1 0]
    Domain: Vector space of dimension 2 over Finite Field of size 3
    Codomain: Vector space of dimension 2 over Finite Field of size 3
    <BLANKLINE>
    Vector space morphism represented by the matrix:
    [0 0]
    [0 1]
    Domain: Vector space of dimension 2 over Finite Field of size 3
    Codomain: Vector space of dimension 2 over Finite Field of size 3
    <BLANKLINE>

The zero and identity mappings are properties of the space. The identity mapping will only be available if the domain and codomain allow for endomorphisms (equal vector spaces with equal bases).

    sage: H = Hom(QQ^3, QQ^3)
    sage: g = H.zero()
    sage: g([1, 1/2, -3])
    (0, 0, 0)
    sage: f = H.identity()
    sage: f([1, 1/2, -3])
    (1, 1/2, -3)

The homspace may be used with various representations of a morphism in the space to create the morphism. We demonstrate three ways to create the same linear transformation between two two-dimensional subspaces of `QQ^3`. The `V.n` notation is a shortcut to the generators of each vector space, better known as the basis elements. Note that the matrix representations are relative to the bases, which are purposely fixed when the subspaces are created (“user bases”).

    sage: U = QQ^3
    sage: V = U.subspace_with_basis([U.0+U.1, U.1-U.2])
    sage: W = U.subspace_with_basis([U.0, U.1+U.2])
    sage: H = Hom(V, W)

First, with a matrix. Note that the matrix representation acts by matrix multiplication with the vector on the left. The input to the linear transformation, `(3, 1, 2)`, is converted to the coordinate vector `(3, -2)`, then matrix multiplication yields the vector `(-3, -2)`, which represents the vector `(-3, -2, -2)` in the codomain.

    sage: m = matrix(QQ, [[1, 2], [3, 4]])
    sage: f1 = H(m)
    sage: f1
    Vector space morphism represented by the matrix:
    [1 2]
    [3 4]
    Domain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [ 1  1  0]
    [ 0  1 -1]
    Codomain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [1 0 0]
    [0 1 1]
    sage: f1([3,1,2])
    (-3, -2, -2)

Second, with a list of images of the domain’s basis elements.

    sage: img = [1*(U.0) + 2*(U.1+U.2), 3*U.0 + 4*(U.1+U.2)]
    sage: f2 = H(img)
    sage: f2
    Vector space morphism represented by the matrix:
    [1 2]
    [3 4]
    Domain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [ 1  1  0]
    [ 0  1 -1]
    Codomain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [1 0 0]
    [0 1 1]
    sage: f2([3,1,2])
    (-3, -2, -2)

Third, with a linear function taking the domain to the codomain.

    sage: g = lambda x: vector(QQ, [-2*x[0]+3*x[1], -2*x[0]+4*x[1], -2*x[0]+4*x[1]])
    sage: f3 = H(g)
    sage: f3
    Vector space morphism represented by the matrix:
    [1 2]
    [3 4]
    Domain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [ 1  1  0]
    [ 0  1 -1]
    Codomain: Vector space of degree 3 and dimension 2 over Rational Field
    User basis matrix:
    [1 0 0]
    [0 1 1]
    sage: f3([3,1,2])
    (-3, -2, -2)

The three linear transformations look the same, and are the same.

    sage: f1 == f2
    True
    sage: f2 == f3
    True

TESTS:

    sage: V = QQ^2
    sage: W = QQ^3
    sage: H = Hom(QQ^2, QQ^3)
    sage: loads(dumps(H))
    Set of Morphisms (Linear Transformations) from
    Vector space of dimension 2 over Rational Field to
    Vector space of dimension 3 over Rational Field
    sage: loads(dumps(H)) == H
    True

class `sage.modules.vector_space_homspace.``VectorSpaceHomspace`(X, Y, category=None, check=True, base=None)

  Bases: `sage.modules.free_module_homspace.FreeModuleHomspace`

  TESTS:

      sage: X = ZZ['x']; X.rename("X")
      sage: Y = ZZ['y']; Y.rename("Y")
      sage: class MyHomset(HomsetWithBase):
      ...       def my_function(self, x):
      ...           return Y(x[0])
      ...       def _an_element_(self):
      ...           return sage.categories.morphism.SetMorphism(self, self.my_function)
      ...
      sage: import __main__; __main__.MyHomset = MyHomset # fakes MyHomset being defined in a Python module
      sage: H = MyHomset(X, Y, category=Monoids())
      sage: H
      Set of Morphisms from X to Y in Category of monoids
      sage: H.base()
      Integer Ring
      sage: TestSuite(H).run()

`sage.modules.vector_space_homspace.``is_VectorSpaceHomspace`(x)

  Return `True` if `x` is a vector space homspace.

  INPUT:

  `x` - anything

  EXAMPLES:

  To be a vector space morphism, the domain and codomain must both be vector spaces, in other words, modules over fields. If either set is just a module, then the `Hom()` constructor will build a space of free module morphisms.

      sage: H = Hom(QQ^3, QQ^2)
      sage: type(H)
      <class 'sage.modules.vector_space_homspace.VectorSpaceHomspace_with_category'>
      sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace(H)
      True

      sage: K = Hom(QQ^3, ZZ^2)
      sage: type(K)
      <class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
      sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace(K)
      False

      sage: L = Hom(ZZ^3, QQ^2)
      sage: type(L)
      <class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
      sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace(L)
      False

      sage: sage.modules.vector_space_homspace.is_VectorSpaceHomspace('junk')
      False

### Navigation

- index
- modules |
- next |
- previous |
- Modules »