### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »

# Unital algebras

class `sage.categories.unital_algebras.``UnitalAlgebras`(base_category)

  Bases: `sage.categories.category_with_axiom.CategoryWithAxiom_over_base_ring`

  The category of non-associative algebras over a given base ring.

  A non-associative algebra over a ring \(R\) is a module over \(R\) which s also a unital magma.

  Warning

  Until trac ticket #15043 is implemented, `Algebras` is the category of associative unital algebras; thus, unlike the name suggests, `UnitalAlgebras` is not a subcategory of `Algebras` but of `MagmaticAlgebras`.

  EXAMPLES:

      sage: from sage.categories.unital_algebras import UnitalAlgebras
      sage: C = UnitalAlgebras(ZZ); C
      Category of unital algebras over Integer Ring

  TESTS:

      sage: from sage.categories.magmatic_algebras import MagmaticAlgebras
      sage: C is MagmaticAlgebras(ZZ).Unital()
      True
      sage: TestSuite(C).run()

  class `ElementMethods`

    `Magmas.Element.__mul__` is preferable to `Modules.Element.__mul__` since the later does not handle products of two elements of `self`.

    TESTS:

        sage: A = AlgebrasWithBasis(QQ).example()
        sage: a = A.an_element()
        sage: a
        2*B[word: ] + 2*B[word: a] + 3*B[word: b]
        sage: a.__mul__(a)
        4*B[word: ] + 8*B[word: a] + 4*B[word: aa] + 6*B[word: ab] + 12*B[word: b] + 6*B[word: ba] + 9*B[word: bb]

  class `UnitalAlgebras.``ParentMethods`
    `from_base_ring`(r)

      Return the canonical embedding of `r` into `self`.

      INPUT:

      - `r` – an element of `self.base_ring()`

      EXAMPLES:

          sage: A = AlgebrasWithBasis(QQ).example(); A
          An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
          sage: A.from_base_ring(1)
          B[word: ]

  class `UnitalAlgebras.``WithBasis`(base_category)

    Bases: `sage.categories.category_with_axiom.CategoryWithAxiom_over_base_ring`

    TESTS:

        sage: C = Modules(ZZ).FiniteDimensional(); C
        Category of finite dimensional modules over Integer Ring
        sage: type(C)
        <class 'sage.categories.modules.Modules.FiniteDimensional_with_category'>
        sage: type(C).__base__.__base__
        <class 'sage.categories.category_with_axiom.CategoryWithAxiom_over_base_ring'>

        sage: TestSuite(C).run()

    class `ParentMethods`
      `from_base_ring`()

        TESTS:

            sage: A = AlgebrasWithBasis(QQ).example()
            sage: A.from_base_ring(3)
            3*B[word: ]

      `from_base_ring_from_one_basis`(r)

        Implement the canonical embeding from the ground ring.

        INPUT:

        - `r` – an element of the coefficient ring

        EXAMPLES:

            sage: A = AlgebrasWithBasis(QQ).example()
            sage: A.from_base_ring_from_one_basis(3)
            3*B[word: ]
            sage: A.from_base_ring(3)
            3*B[word: ]
            sage: A(3)
            3*B[word: ]

      `one`()

        Return the multiplicative unit element.

        EXAMPLES:

            sage: A = AlgebrasWithBasis(QQ).example()
            sage: A.one_basis()
            word:
            sage: A.one()
            B[word: ]

      `one_basis`()

        When the one of an algebra with basis is an element of this basis, this optional method can return the index of this element. This is used to provide a default implementation of `one()`, and an optimized default implementation of `from_base_ring()`.

        EXAMPLES:

            sage: A = AlgebrasWithBasis(QQ).example()
            sage: A.one_basis()
            word:
            sage: A.one()
            B[word: ]
            sage: A.from_base_ring(4)
            4*B[word: ]

      `one_from_one_basis`()

        > Return the one of the algebra, as per `Monoids.ParentMethods.one()`

        > By default, this is implemented from `one_basis()`, if available.

        > EXAMPLES:

        >     sage: A = AlgebrasWithBasis(QQ).example()
        >     sage: A.one_basis()
        >     word:
        >     sage: A.one_from_one_basis()
        >     B[word: ]
        >     sage: A.one()
        >     B[word: ]

        > TESTS:

        > Try to check that trac ticket #5843 Heisenbug is fixed:

        >     sage: A = AlgebrasWithBasis(QQ).example()
        >     sage: B = AlgebrasWithBasis(QQ).example(('a', 'c'))
        >     sage: A == B
        >     False
        >     sage: Aone = A.one_from_one_basis
        >     sage: Bone = B.one_from_one_basis
        >     sage: Aone is Bone
        >     False

        Even if called in the wrong order, they should returns their respective one:

            sage: Bone().parent() is B
            True
            sage: Aone().parent() is A
            True

### Navigation

- index
- modules |
- next |
- previous |
- Category Theory »