% This file was created automatically from algebra.msk.
% DO NOT EDIT!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%A  algebra.msk                  GAP documentation            Willem de Graaf
%%
%A  @(#)$Id: algebra.msk,v 1.33.2.1 2004/01/19 10:01:15 gap Exp $
%%
%Y  (C) 1998 School Math and Comp. Sci., University of St.  Andrews, Scotland
%Y  Copyright (C) 2002 The GAP Group
%%
\Chapter{Algebras}

An algebra is a vector space equipped with a bilinear map (multiplication).
This chapter describes the functions in {\GAP} that deal with 
general algebras and associative algebras. 

Algebras in {\GAP} are vector spaces in a natural way. So all the
functionality for vector spaces (see Chapter "ref:vector spaces") is also 
applicable to algebras.



\>`InfoAlgebra' V

is the info class for the functions dealing with algebras
(see~"Info Functions").



%%  The algebra functionality was designed and implemented by Thomas Breuer and
%%  Willem de Graaf.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Constructing Algebras by Generators}

% AlgebraByGenerators( <F>, <gens>, <zero> ) Left out...

\>Algebra( <F>, <gens> ) F
\>Algebra( <F>, <gens>, <zero> ) F
\>Algebra( <F>, <gens>, "basis" ) F
\>Algebra( <F>, <gens>, <zero>, "basis" ) F

`Algebra( <F>, <gens> )' is the algebra over the division ring
<F>, generated by the vectors in the list <gens>.

If there are three arguments, a division ring <F> and a list <gens>
and an element <zero>,
then `Algebra( <F>, <gens>, <zero> )' is the <F>-algebra
generated by <gens>, with zero element <zero>.

If the last argument is the string `\"basis\"' then the vectors in
<gens> are known to form a basis of the algebra (as an <F>-vector space).



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3], [ 0, 0, 0 ] ];;
gap> A:= Algebra( Rationals, [ m ] );
<algebra over Rationals, with 1 generators>
gap> Dimension( A );
2
\endexample

%  AlgebraWithOneByGenerators( <F>, <gens>, <zero> ) Left out...

\>AlgebraWithOne( <F>, <gens> ) F
\>AlgebraWithOne( <F>, <gens>, <zero> ) F
\>AlgebraWithOne( <F>, <gens>, "basis" ) F
\>AlgebraWithOne( <F>, <gens>, <zero>, "basis" ) F

`AlgebraWithOne( <F>, <gens> )' is the algebra-with-one over the division
ring <F>, generated by the vectors in the list <gens>.

If there are three arguments, a division ring <F> and a list <gens>
and an element <zero>,
then `AlgebraWithOne( <F>, <gens>, <zero> )' is the <F>-algebra-with-one
generated by <gens>, with zero element <zero>.

If the last argument is the string `\"basis\"' then the vectors in
<gens> are known to form a basis of the algebra (as an <F>-vector space).



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3], [ 0, 0, 0 ] ];;
gap> A:= AlgebraWithOne( Rationals, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
gap> Dimension( A );
3
gap> One(A);
[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
\endexample


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Constructing Algebras as Free Algebras}

\>FreeAlgebra( <R>, <rank> ) F
\>FreeAlgebra( <R>, <rank>, <name> ) F
\>FreeAlgebra( <R>, <name1>, <name2>, ... ) F

is a free (nonassociative) algebra of rank <rank> over the ring <R>.
Here <name>, and <name1>, <name2>,... are optional strings that can be used
to provide names for the generators.



\beginexample
gap> A:= FreeAlgebra( Rationals, "a", "b" );
<algebra over Rationals, with 2 generators>
gap> g:= GeneratorsOfAlgebra( A );
[ (1)*a, (1)*b ]
gap> (g[1]*g[2])*((g[2]*g[1])*g[1]);
(1)*((a*b)*((b*a)*a))
\endexample

\>FreeAlgebraWithOne( <R>, <rank> ) F
\>FreeAlgebraWithOne( <R>, <rank>, <name> ) F
\>FreeAlgebraWithOne( <R>, <name1>, <name2>, ... ) F

is a free (nonassociative) algebra-with-one of rank <rank> over the ring
<R>.
Here <name>, and <name1>, <name2>,... are optional strings that can be used
to provide names for the generators.



\beginexample
gap> A:= FreeAlgebraWithOne( Rationals, 4, "q" );
<algebra-with-one over Rationals, with 4 generators>
gap> GeneratorsOfAlgebra( A );
[ (1)*<identity ...>, (1)*q.1, (1)*q.2, (1)*q.3, (1)*q.4 ]
gap> One( A );
(1)*<identity ...>
\endexample

\>FreeAssociativeAlgebra( <R>, <rank> ) F
\>FreeAssociativeAlgebra( <R>, <rank>, <name> ) F
\>FreeAssociativeAlgebra( <R>, <name1>, <name2>, ... ) F

is a free associative algebra of rank <rank> over the ring <R>.
Here <name>, and <name1>, <name2>,... are optional strings that can be used
to provide names for the generators.



\beginexample
gap> A:= FreeAssociativeAlgebra( GF( 5 ), 4, "a" );
<algebra over GF(5), with 4 generators>
\endexample

\>FreeAssociativeAlgebraWithOne( <R>, <rank> ) F
\>FreeAssociativeAlgebraWithOne( <R>, <rank>, <name> ) F
\>FreeAssociativeAlgebraWithOne( <R>, <name1>, <name2>, ... ) F

is a free associative algebra-with-one of rank <rank> over the ring <R>.
Here <name>, and <name1>, <name2>,... are optional strings that can be used
to provide names for the generators.



\beginexample
gap> A:= FreeAssociativeAlgebraWithOne( Rationals, "a", "b", "c" );
<algebra-with-one over Rationals, with 3 generators>
gap> GeneratorsOfAlgebra( A );
[ (1)*<identity ...>, (1)*a, (1)*b, (1)*c ]
gap> One( A );
(1)*<identity ...>
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Constructing Algebras by Structure Constants}

For an introduction into structure constants and how they are handled
by {\GAP}, we refer to Section "tut:Algebras" of the user's tutorial.


\>EmptySCTable( <dim>, <zero> ) F
\>EmptySCTable( <dim>, <zero>, \"symmetric\" ) F
\>EmptySCTable( <dim>, <zero>, \"antisymmetric\" ) F

`EmptySCTable' returns a structure constants table for an algebra of
dimension <dim>, describing trivial multiplication.
<zero> must be the zero of the coefficients domain.
If the multiplication is known to be (anti)commutative then
this can be indicated by the optional third argument.

For filling up the structure constants table, see "SetEntrySCTable".



\beginexample
gap> EmptySCTable( 2, Zero( GF(5) ), "antisymmetric" );
[ [ [ [  ], [  ] ], [ [  ], [  ] ] ], [ [ [  ], [  ] ], [ [  ], [  ] ] ], -1, 
  0*Z(5) ]
\endexample

\>SetEntrySCTable( <T>, <i>, <j>, <list> ) F

sets the entry of the structure constants table <T> that describes the
product of the <i>-th basis element with the <j>-th basis element to the
value given by the list <list>.

If <T> is known to be antisymmetric or symmetric then also the value
`<T>[<j>][<i>]' is set.

<list> must be of the form
$[ c_{ij}^{k_1}, k_1, c_{ij}^{k_2}, k_2, \ldots ]$.

The entries at the odd positions of <list> must be compatible with the
zero element stored in <T>.
For convenience, these entries may also be rational numbers that are
automatically replaced by the corresponding elements in the appropriate
prime field in finite characteristic if necessary.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [ 1/2, 1, 2/3, 2 ] );
gap> T;
[ [ [ [ 1, 2 ], [ 1/2, 2/3 ] ], [ [  ], [  ] ] ], 
  [ [ [  ], [  ] ], [ [  ], [  ] ] ], 0, 0 ]
\endexample

\>GapInputSCTable( <T>, <varname> ) F

is a string that describes the structure constants table <T> in terms of
`EmptySCTable' and `SetEntrySCTable'.
The assignments are made to the variable <varname>.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 2, [ 1, 2 ] );
gap> SetEntrySCTable( T, 2, 1, [ 1, 2 ] );
gap> GapInputSCTable( T, "T" );
"T:= EmptySCTable( 2, 0 );\nSetEntrySCTable( T, 1, 2, [1,2] );\nSetEntrySCTabl\
e( T, 2, 1, [1,2] );\n"
\endexample

\>TestJacobi( <T> ) F

tests whether the structure constants table <T> satisfies the Jacobi
identity
$v_i*(v_j*v_k)+v_j*(v_k*v_i)+v_k*(v_i*v_j)=0$
for all basis vectors $v_i$ of the underlying algebra,
where $i \leq j \leq k$.
(Thus antisymmetry is assumed.)

The function returns `true' if the Jacobi identity is satisfied,
and a failing triple `[ i, j, k ]' otherwise.



\beginexample
gap> T:= EmptySCTable( 2, 0, "antisymmetric" );;
gap> SetEntrySCTable( T, 1, 2, [ 1, 2 ] );;
gap> TestJacobi( T );
true
\endexample



\>AlgebraByStructureConstants( <R>, <sctable> ) F
\>AlgebraByStructureConstants( <R>, <sctable>, <name> ) F
\>AlgebraByStructureConstants( <R>, <sctable>, <names> ) F
\>AlgebraByStructureConstants( <R>, <sctable>, <name1>, <name2>, ... ) F

returns a free left module $A$ over the ring <R>,
with multiplication defined by the structure constants table <sctable>.
Here <name> and <name1>, <name2>, `...' are optional strings
that can be used to provide names for the elements of the canonical basis
of $A$.
<names> is a list of strings that can be entered instead of the specific
names <name1>, <name2>, `...'.
The vectors of the canonical basis of $A$ correspond to the vectors of
the basis given by <sctable>.

%  The algebra generators of $A$ are linearly independent
%  abstract vector space generators
%  $x_1, x_2, \ldots, x_n$ which are multiplied according to the formula
%  $ x_i x_j = \sum_{k=1}^n c_{ijk} x_k$
%  where `$c_{ijk}$ = <sctable>[i][j][1][i_k]'
%  and `<sctable>[i][j][2][i_k] = k'.

It is *not* checked whether the coefficients in <sctable> are really
elements in <R>.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [ 1/2, 1, 2/3, 2 ] );
gap> A:= AlgebraByStructureConstants( Rationals, T );
<algebra of dimension 2 over Rationals>
gap> b:= BasisVectors( Basis( A ) );;
gap> b[1]^2;
(1/2)*v.1+(2/3)*v.2
gap> b[1]*b[2];
0*v.1
\endexample

\>IdentityFromSCTable( <T> ) F

Let <T> be a structure constants table of an algebra $A$ of dimension $n$.
`IdentityFromSCTable( <T> )' is either `fail' or the vector of length
$n$ that contains the coefficients of the multiplicative identity of $A$
with respect to the basis that belongs to <T>.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [ 1, 1 ] );;
gap> SetEntrySCTable( T, 1, 2, [ 1, 2 ] );;
gap> SetEntrySCTable( T, 2, 1, [ 1, 2 ] );;
gap> IdentityFromSCTable( T );
[ 1, 0 ]
\endexample

\>QuotientFromSCTable( <T>, <num>, <den> ) F

Let <T> be a structure constants table of an algebra $A$ of dimension $n$.
`QuotientFromSCTable( <T> )' is either `fail' or the vector of length
$n$ that contains the coefficients of the quotient of <num> and <den>
with respect to the basis that belongs to <T>.

We solve the equation system $<num> = x <den>$.
If no solution exists, `fail' is returned.

In terms of the basis $B$ with vectors $b_1, \ldots, b_n$ this means
for $<num> = \sum_{i=1}^n a_i b_i$,
    $<den> = \sum_{i=1}^n c_i b_i$,
    $x     = \sum_{i=1}^n x_i b_i$ that
$a_k = \sum_{i,j} c_i x_j c_{ijk}$ for all $k$.
Here $c_{ijk}$ denotes the structure constants with respect to $B$.
This means that (as a vector) $a=xM$ with
$M_{jk} = \sum_{i=1}^n c_{ijk} c_i$.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [ 1, 1 ] );;
gap> SetEntrySCTable( T, 2, 1, [ 1, 2 ] );;
gap> SetEntrySCTable( T, 1, 2, [ 1, 2 ] );;
gap> QuotientFromSCTable( T, [0,1], [1,0] );
[ 0, 1 ]
\endexample



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Some Special Algebras}

\>QuaternionAlgebra( <F> ) F
\>QuaternionAlgebra( <F>, <a>, <b> ) F

is a quaternion algebra over the field <F> with parameters <a> and <b> in
<F>, i.e., a four-dimensional associative <F>-algebra with basis
$(e,i,j,k)$ and multiplication defined by
$e e = e$, $e i = i e = i$, $e j = j e = j$, $e k = k e = k$,
$i i = <a> e$, $i j = - j i = k$, $i k = - k i = <a> j$,
$j j = <b> e$, $j k = - k j = <b> i$,
$k k = - <a> <b> e$.
The default value for both <a> and <b> is $-1 \in <F>$.

The `GeneratorsOfAlgebra' (see~"GeneratorsOfAlgebra") and
`CanonicalBasis' (see~"CanonicalBasis") value of an algebra constructed
with `QuaternionAlgebra' is the list $[ e, i, j, k ]$.

The embedding of the field `GaussianRationals' into a quaternion algebra
$A$ over `Rationals' is not uniquely determined.
One can specify one as a vector space homomorphism that maps `1' to the
first algebra generator of $A$, and `E(4)' to one of the others.



\beginexample
gap> QuaternionAlgebra( Rationals );
<algebra-with-one of dimension 4 over Rationals>
\endexample

\>ComplexificationQuat( <vector> ) F
\>ComplexificationQuat( <matrix> ) F

Let $A = e F \oplus i F \oplus j F \oplus k F$ be a quaternion algebra
over the field $F$ of cyclotomics, with basis $(e,i,j,k)$.

If $v = v_1 + v_2 j$ is a row vector over $A$ with $v_1 = e w_1 + i w_2$
and $v_2 = e w_3 + i w_4$ then `ComplexificationQuat( $v$ )' is the
concatenation of $w_1 + `E(4)' w_2$ and $w_3 + `E(4)' w_4$.

If $M = M_1 + M_2 j$ is a matrix over $A$ with $M_1 = e N_1 + i N_2$
and $M_2 = e N_3 + i N_4$ then `ComplexificationQuat( <M> )' is the
block matrix $A$ over $e F \oplus i F$ such that $A(1,1)=N_1 + `E(4)' N_2$,
$A(2,2)=N_1 - `E(4)' N_2$, $A(1,2)=N_3 + `E(4)' N_4$ and $A(2,1)=
 - N_3 + `E(4)' N_4$.
%  \[ \left( \begin{array}{rr}
%                  N_1 + `E(4)' N_2 & N_3 + `E(4)' N_4           \\
%                - N_3 + `E(4)' N_4 & N_1 - `E(4)' N_2
%            \end{array} \right) \]

Then `ComplexificationQuat(<v>)*ComplexificationQuat(<M>)=
      ComplexificationQuat(<v>*<M>)', since
$$
v M = v_1 M_1 + v_2 j M_1 + v_1 M_2 j + v_2 j M_2 j
    =   ( v_1 M_1 - v_2 \overline{M_2} ) %
      + ( v_1 M_2 + v_2 \overline{M_1} ) j\.
$$
           


\>OctaveAlgebra( <F> ) F

The algebra of octonions over <F>.



\beginexample
gap> OctaveAlgebra( Rationals );
<algebra of dimension 8 over Rationals>
\endexample

\>FullMatrixAlgebra( <R>, <n> ) F
\>MatrixAlgebra( <R>, <n> ) F
\>MatAlgebra( <R>, <n> ) F

is the full matrix algebra $<R>^{<n>\times <n>}$, for a ring <R> and a 
nonnegative integer <n>.



\beginexample
gap> A:=FullMatrixAlgebra( Rationals, 20 );
( Rationals^[ 20, 20 ] )
gap> Dimension( A );
400
\endexample

\>NullAlgebra( <R> ) A

The zero-dimensional algebra over <R>.



\beginexample
gap> A:= NullAlgebra( Rationals );
<algebra over Rationals>
gap> Dimension( A );
0
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Subalgebras}

\>Subalgebra( <A>, <gens> ) F
\>Subalgebra( <A>, <gens>, "basis" ) F

is the $F$-algebra generated by <gens>, with parent algebra <A>, where
$F$ is the left acting domain of <A>.

*Note* that being a subalgebra of <A> means to be an algebra, to be
contained in <A>, *and* to have the same left acting domain as <A>.

An optional argument `\"basis\"' may be added if it is known that
the generators already form a basis of the algebra.
Then it is *not* checked whether <gens> really are linearly independent
and whether all elements in <gens> lie in <A>.



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3], [ 0, 0, 0 ] ];;
gap> A:= Algebra( Rationals, [ m ] );
<algebra over Rationals, with 1 generators>
gap> B:= Subalgebra( A, [ m^2 ] );
<algebra over Rationals, with 1 generators>
\endexample

\>SubalgebraNC( <A>, <gens> ) F
\>SubalgebraNC( <A>, <gens>, "basis" ) F

`SubalgebraNC' constructs the subalgebra generated by <gens>, only it 
does not check whether all elements in <gens> lie in <A>.



\beginexample
gap> m:= RandomMat( 3, 3 );;
gap> A:= Algebra( Rationals, [ m ] );
<algebra over Rationals, with 1 generators>
gap> SubalgebraNC( A, [ IdentityMat( 3, 3 ) ], "basis" );
<algebra of dimension 1 over Rationals>
\endexample

\>SubalgebraWithOne( <A>, <gens> ) F
\>SubalgebraWithOne( <A>, <gens>, "basis" ) F

is the algebra-with-one generated by <gens>, with parent algebra <A>.

The optional third argument `\"basis\"' may be added if it is
known that the elements from <gens> are linearly independent.
Then it is *not* checked whether <gens> really are linearly independent
and whether all elements in <gens> lie in <A>.



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3], [ 0, 0, 0 ] ];;
gap> A:= AlgebraWithOne( Rationals, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
gap> B1:= SubalgebraWithOne( A, [ m ] );;
gap> B2:= Subalgebra( A, [ m ] );;
gap> Dimension( B1 );
3
gap> Dimension( B2 );
2
\endexample

\>SubalgebraWithOneNC( <A>, <gens> ) F
\>SubalgebraWithOneNC( <A>, <gens>, "basis" ) F

`SubalgebraWithOneNC' does not check whether all elements in <gens> lie
in <A>.



\beginexample
gap> m:= RandomMat( 3, 3 );; A:= Algebra( Rationals, [ m ] );;
gap> SubalgebraWithOneNC( A, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
\endexample

\>TrivialSubalgebra( <A> ) A

The zero dimensional subalgebra of the algebra <A>.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> B:= TrivialSubalgebra( A );
<algebra over Rationals>
gap> Dimension( B );
0
\endexample


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Ideals}

For constructing and working with ideals in algebras the same functions
are available as for ideals in rings. So for the precise description of
these functions we refer to Chapter "Rings". Here we give examples
demonstrating the use of ideals in algebras. For an introduction into
the concstruction of quotient algebras we refer to Chapter "tut:algebras"
of the user's tutorial.

\beginexample
gap> m:= [ [ 0, 2, 3 ], [ 0, 0, 4 ], [ 0, 0, 0] ];;
gap> A:= AlgebraWithOne( Rationals, [ m ] );;
gap> I:= Ideal( A, [ m ] );  # i.e., the two-sided ideal of `A' generated by `m'.
<two-sided ideal in <algebra-with-one of dimension 3 over Rationals>, 
  (1 generators)>
gap> Dimension( I );
2
gap> GeneratorsOfIdeal( I );
[ [ [ 0, 2, 3 ], [ 0, 0, 4 ], [ 0, 0, 0 ] ] ]
gap> BasisVectors( Basis( I ) );
[ [ [ 0, 1, 3/2 ], [ 0, 0, 2 ], [ 0, 0, 0 ] ], 
  [ [ 0, 0, 1 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] ]
\endexample

\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 4 );;
gap> m:= NullMat( 4, 4 );; m[1][4]:=1;;
gap> I:= LeftIdeal( A, [ m ] );
<left ideal in ( Rationals^[ 4, 4 ] ), (1 generators)>
gap> Dimension( I );
4
gap> GeneratorsOfLeftIdeal( I );
[ [ [ 0, 0, 0, 1 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ] ]
\endexample

\beginexample
gap> mats:= [ [[1,0],[0,0]], [[0,1],[0,0]], [[0,0],[0,1]] ];;
gap> A:= Algebra( Rationals, mats );;
gap> # Form the two-sided ideal for which `mats[2]' is known to be
gap> # the unique basis element.
gap> I:= Ideal( A, [ mats[2] ], "basis" );
<two-sided ideal in <algebra of dimension 3 over Rationals>, (dimension 1)>
\endexample


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Categories and Properties of Algebras}

\>IsFLMLOR( <obj> ) C

A FLMLOR (``free left module left operator ring'') in {\GAP} is a ring
that is also a free left module.

Note that this means that being a FLMLOR is not a property a
ring can get,
since a ring is usually not represented as an external left set.

Examples are magma rings (e.g. over the integers) or algebras.



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 2 );;
gap> IsFLMLOR ( A );
true
\endexample

\>IsFLMLORWithOne( <obj> ) C

A FLMLOR-with-one in {\GAP} is a ring-with-one that is also a free left
module.

Note that this means that being a FLMLOR-with-one is not a property a
ring-with-one can get,
since a ring-with-one is usually not represented as an external left set.

Examples are magma rings-with-one or algebras-with-one (but also over the
integers).



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 2 );;
gap> IsFLMLORWithOne ( A );
true
\endexample


\>IsAlgebra( <obj> ) C

An algebra in {\GAP} is a ring that is also a left vector space.
Note that this means that being an algebra is not a property a ring can
get, since a ring is usually not represented as an external left set.



\beginexample
gap> A:= MatAlgebra( Rationals, 3 );;
gap> IsAlgebra( A );
true
\endexample

\>IsAlgebraWithOne( <obj> ) C

An algebra-with-one in {\GAP} is a ring-with-one that is also
a left vector space.
Note that this means that being an algebra-with-one is not a property a
ring-with-one can get,
since a ring-with-one is usually not represented as an external left set.



\beginexample
gap> A:= MatAlgebra( Rationals, 3 );;
gap> IsAlgebraWithOne( A );
true
\endexample

\>IsLieAlgebra( <A> ) P

An algebra <A> is called Lie algebra if $a * a = 0$ for all $a$ in <A>
and $( a * ( b * c ) ) + ( b * ( c * a ) ) + ( c * ( a * b ) ) = 0$
for all $a, b, c$ in <A> (Jacobi identity).



\beginexample
gap> A:= FullMatrixLieAlgebra( Rationals, 3 );;
gap> IsLieAlgebra( A );
true
\endexample

\>IsSimpleAlgebra( <A> ) P

is `true' if the algebra <A> is simple, and `false' otherwise. This 
function is only implemented for the cases where <A> is an associative or
a Lie algebra. And for Lie algebras it is only implemented fot the
case where the ground field is of characteristic $0$.



\beginexample
gap> A:= FullMatrixLieAlgebra( Rationals, 3 );;
gap> IsSimpleAlgebra( A );
false
gap> A:= MatAlgebra( Rationals, 3 );;
gap> IsSimpleAlgebra( A );
true
\endexample

% IsMatrixFLMLOR left out...

% \ Declaration{IsFiniteDimensional}
\>IsFiniteDimensional(<matalg>)!{for matrix algebras} O

returns `true' (always) for a matrix algebra <matalg>, since
matrix algebras are always finite dimensional.

\beginexample
gap> A:= MatAlgebra( Rationals, 3 );;
gap> IsFiniteDimensional( A );
true
\endexample

\>IsQuaternion( <obj> ) C
\>IsQuaternionCollection( <obj> ) C
\>IsQuaternionCollColl( <obj> ) C

`IsQuaternion' is the category of elements in an algebra constructed by 
`QuaternionAlgebra'. A collection of quaternions lies in the category
`IsQuaternionCollection'. Finally, a collection of quaternion collections
(e.g., a matrix of quaternions) lies in the category
`IsQuaternionCollColl'.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> b:= BasisVectors( Basis( A ) );
[ e, i, j, k ]
gap> IsQuaternion( b[1] );
true
gap> IsQuaternionCollColl( [ [ b[1], b[2] ], [ b[3], b[4] ] ] );
true
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Attributes and Operations for Algebras}

% GeneratorsOfLeftOperatorRing left out....

% GeneratorsOfLeftOperatorRingWithOne left out....

\>GeneratorsOfAlgebra( <A> ) A

returns a list of elements that generate <A> as an algebra.



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3 ], [ 0, 0, 0 ] ];;
gap> A:= AlgebraWithOne( Rationals, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
gap> GeneratorsOfAlgebra( A );
[ [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ], 
  [ [ 0, 1, 2 ], [ 0, 0, 3 ], [ 0, 0, 0 ] ] ]
\endexample

\>GeneratorsOfAlgebraWithOne( <A> ) A

returns a list of elements of <A> that generate <A> as an algebra with
one. 



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3 ], [ 0, 0, 0 ] ];;
gap> A:= AlgebraWithOne( Rationals, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
gap> GeneratorsOfAlgebraWithOne( A );
[ [ [ 0, 1, 2 ], [ 0, 0, 3 ], [ 0, 0, 0 ] ] ]
\endexample

\>ProductSpace( <U>, <V> ) O

is the vector space $\langle u * v ; u \in U, v \in V \rangle$,
where $U$ and $V$ are subspaces of the same algebra.

If $<U> = <V>$ is known to be an algebra then the product space is also
an algebra, moreover it is an ideal in <U>.
If <U> and <V> are known to be ideals in an algebra $A$
then the product space is known to be an algebra and an ideal in $A$.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> b:= BasisVectors( Basis( A ) );;
gap> B:= Subalgebra( A, [ b[4] ] );
<algebra over Rationals, with 1 generators>
gap> ProductSpace( A, B );
<vector space of dimension 4 over Rationals>
\endexample

\>PowerSubalgebraSeries( <A> ) A

returns a list of subalgebras of <A>, the first term of which is <A>;
and every next term is the product space of the previous term with itself.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );
<algebra-with-one of dimension 4 over Rationals>
gap> PowerSubalgebraSeries( A );
[ <algebra-with-one of dimension 4 over Rationals> ]
\endexample

\>AdjointBasis( <B> ) A

Let $x$ be an element of an algebra $A$. Then the adjoint map
of $x$ is the left multiplication by $x$. It is a linear map of $A$.
For the basis <B> of an algebra $A$, this function returns a
particular basis $C$ of the matrix space generated by $ad A$,
(the matrix spaces spanned by the matrices of the left multiplication);
namely a basis consisting of elements of the form $ad x_i$,
where $x_i$ is a basis element of <B>.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> AdjointBasis( Basis( A ) );
Basis( <vector space over Rationals, with 4 generators>, 
[ [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ], 
  [ [ 0, -1, 0, 0 ], [ 1, 0, 0, 0 ], [ 0, 0, 0, -1 ], [ 0, 0, 1, 0 ] ], 
  [ [ 0, 0, -1, 0 ], [ 0, 0, 0, 1 ], [ 1, 0, 0, 0 ], [ 0, -1, 0, 0 ] ], 
  [ [ 0, 0, 0, -1 ], [ 0, 0, -1, 0 ], [ 0, 1, 0, 0 ], [ 1, 0, 0, 0 ] ] ] )
\endexample

\>IndicesOfAdjointBasis( <B> ) A

 Let <A> be an algebra and let <B>
 be the basis that is output by `AdjointBasis( Basis( <A> ) )'. 
 This function 
 returns a list of indices. If $i$ is an index belonging to this
 list, then $ad x_{i}$ is a basis vector of the matrix space spanned
 by $ad A$, where $x_{i}$ is the $i$-th basis vector of the basis <B>.



\beginexample
gap> L:= FullMatrixLieAlgebra( Rationals, 3 );;
gap> B:= AdjointBasis( Basis( L ) );;
gap> IndicesOfAdjointBasis( B );
[ 1, 2, 3, 4, 5, 6, 7, 8 ]
\endexample

\>AsAlgebra( <F>, <A> ) O

Returns the algebra over <F> generated by <A>.



\beginexample
gap> V:= VectorSpace( Rationals, [ IdentityMat( 2 ) ] );;
gap> AsAlgebra( Rationals, V );
<algebra of dimension 1 over Rationals>
\endexample

\>AsAlgebraWithOne( <F>, <A> ) O

If the algebra <A> has an identity, then it can be viewed as an
algebra with one over <F>. This function returns this algebra with one.



\beginexample
gap> V:= VectorSpace( Rationals, [ IdentityMat( 2 ) ] );;
gap> A:= AsAlgebra( Rationals, V );;
gap> AsAlgebraWithOne( Rationals, A );
<algebra-with-one over Rationals, with 1 generators>
\endexample

\>AsSubalgebra( <A>, <B> ) O

If all elements of the algebra <B> happen to be contained in the
algebra <A>, then <B> can be viewed as a subalgebra of <A>. This 
function returns this subalgebra.



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 2 );;
gap> V:= VectorSpace( Rationals, [ IdentityMat( 2 ) ] );;
gap> B:= AsAlgebra( Rationals, V );;
gap> BA:= AsSubalgebra( A, B );
<algebra of dimension 1 over Rationals>
\endexample


\>AsSubalgebraWithOne( <A>, <B> ) O

If <B> is an algebra with one, all elements of which happen to be
contained in the algebra with one <A>, then <B> can be viewed as a
subalgebra with one of <A>. This function returns this subalgebra
with one.



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 2 );;
gap> V:= VectorSpace( Rationals, [ IdentityMat( 2 ) ] );;
gap> B:= AsAlgebra( Rationals, V );;
gap> C:= AsAlgebraWithOne( Rationals, B );;
gap> AC:= AsSubalgebraWithOne( A, C );
<algebra-with-one over Rationals, with 1 generators>
\endexample

\>MutableBasisOfClosureUnderAction( <F>, <Agens>, <from>, <init>, <opr>, %
 <zero>, <maxdim> ) F

Let <F> be a ring, <Agens> a list of generators for an <F>-algebra $A$,
and <from> one of `"left"', `"right"', `"both"'; (this means that elements
of $A$ act via multiplication from the respective side(s).)
<init> must be a list of initial generating vectors,
and <opr> the operation (a function of two arguments).

`MutableBasisOfClosureUnderAction' returns a mutable basis of the
<F>-free left module generated by the vectors in <init>
and their images under the action of <Agens> from the respective side(s).

<zero> is the zero element of the desired module.
<maxdim> is an upper bound for the dimension of the closure; if no such
upper bound is known then the value of <maxdim> must be `infinity'.

`MutableBasisOfClosureUnderAction' can be used to compute a basis of an
*associative* algebra generated by the elements in <Agens>. In this 
case <from> may be `"left"' or `"right"', <opr> is the multiplication `\*',
and <init> is a list containing either the identity of the algebra or a
list of algebra generators.
(Note that if the algebra has an identity then it is in general not
sufficient to take algebra-with-one generators as <init>,
whereas of course <Agens> need not contain the identity.)

(Note that bases of *not* necessarily associative algebras can be
computed using `MutableBasisOfNonassociativeAlgebra'.)

Other applications of `MutableBasisOfClosureUnderAction' are the
computations of bases for (left/ right/ two-sided) ideals $I$ in an
*associative* algebra $A$ from ideal generators of $I$;
in these cases <Agens> is a list of algebra generators of $A$,
<from> denotes the appropriate side(s),
<init> is a list of ideal generators of $I$, and <opr> is again `\*'.

(Note that bases of ideals in *not* necessarily associative algebras can
be computed using `MutableBasisOfIdealInNonassociativeAlgebra'.)

Finally, bases of right $A$-modules also can be computed using
`MutableBasisOfClosureUnderAction'.
The only difference to the ideal case is that <init> is now a list of
right module generators, and <opr> is the operation of the module.




\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> g:= GeneratorsOfAlgebra( A );;
gap> B:= MutableBasisOfClosureUnderAction( Rationals, g, "left", [ g[1] ], \*, Zero(A), 4 );
<mutable basis over Rationals, 4 vectors>
gap> BasisVectors( B );
[ e, i, j, k ]
\endexample

\>MutableBasisOfNonassociativeAlgebra( <F>, <Agens>, <zero>, <maxdim> ) F

is a mutable basis of the (not necessarily associative) <F>-algebra that
is generated by <Agens>, has zero element <zero>, and has dimension at
most <maxdim>.
If no finite bound for the dimension is known then `infinity' must be
the value of <maxdim>.

The difference to `MutableBasisOfClosureUnderAction' is that in general
it is not sufficient to multiply just with algebra generators.
(For special cases of nonassociative algebras, especially for Lie
algebras, multiplying with algebra generators suffices.)



\beginexample
gap> L:= FullMatrixLieAlgebra( Rationals, 4 );;
gap> m1:= Random( L );;
gap> m2:= Random( L );;
gap> MutableBasisOfNonassociativeAlgebra( Rationals, [ m1, m2 ], Zero( L ),
> 16 );
<mutable basis over Rationals, 16 vectors>
\endexample

\>MutableBasisOfIdealInNonassociativeAlgebra( <F>, <Vgens>, <Igens>, %
 <zero>, <from>, <maxdim> ) F

is a mutable basis of the ideal generated by <Igens> under the action of
the (not necessarily associative) <F>-algebra with vector space
generators <Vgens>.
The zero element of the ideal is <zero>,
<from> is one of `"left"', `"right"', `"both"' (with the same meaning as
in `MutableBasisOfClosureUnderAction'),
and <maxdim> is a known upper bound on the dimension of the ideal;
if no finite bound for the dimension is known then `infinity' must be
the value of <maxdim>.

The difference to `MutableBasisOfClosureUnderAction' is that in general
it is not sufficient to multiply just with algebra generators.
(For special cases of nonassociative algebras, especially for Lie
algebras, multiplying with algebra generators suffices.)



\beginexample
gap> mats:= [  [[ 1, 0 ], [ 0, -1 ]], [[0,1],[0,0]] ];;
gap> A:= Algebra( Rationals, mats );;
gap> basA:= BasisVectors( Basis( A ) );;
gap> B:= MutableBasisOfIdealInNonassociativeAlgebra( Rationals, basA,
> [ mats[2] ], 0*mats[1], "both", infinity );
<mutable basis over Rationals, 1 vectors>
gap> BasisVectors( B );
[ [ [ 0, 1 ], [ 0, 0 ] ] ]
\endexample

\>DirectSumOfAlgebras( <A1>, <A2> ) O
\>DirectSumOfAlgebras( <list> ) O

is the direct sum of the two algebras <A1> and <A2> respectively of the 
algebras in the list <list>.

If all involved algebras are associative algebras then the result is also
known to be associative.
If all involved algebras are Lie algebras then the result is also known
to be a Lie algebra.

All involved algebras must have the same left acting domain.

The default case is that the result is a structure constants algebra.
If all involved algebras are matrix algebras, and either both are Lie
algebras or both are associative then the result is again a
matrix algebra of the appropriate type.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> DirectSumOfAlgebras( [A, A, A] );
<algebra of dimension 12 over Rationals>
\endexample

\>FullMatrixAlgebraCentralizer( <F>, <lst> ) F

Compute the centralizer of the list of matrices in the list <lst> in the 
full matrix algebra over the ring <F>. 



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> mats:= List(BasisVectors(Basis( A ) ), x -> AdjointMatrix(Basis(A), x ));;
gap> FullMatrixAlgebraCentralizer( Rationals, mats );
<algebra-with-one of dimension 4 over Rationals>
\endexample

\>RadicalOfAlgebra( <A> ) A

is the maximal nilpotent ideal of <A>, where <A> is an associative 
algebra.



\beginexample
gap> m:= [ [ 0, 1, 2 ], [ 0, 0, 3 ], [ 0, 0, 0 ] ];;
gap> A:= AlgebraWithOneByGenerators( Rationals, [ m ] );
<algebra-with-one over Rationals, with 1 generators>
gap> RadicalOfAlgebra( A );
<algebra of dimension 2 over Rationals>
\endexample

\>CentralIdempotentsOfAlgebra( <A> ) A

For an associative algebra <A>, this function returns
a list of central primitive idempotents such that their sum is
the identity element of <A>. Therefore <A> is required to have an
identity.

(This is a synonym of `CentralIdempotentsOfSemiring'.)



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> B:= DirectSumOfAlgebras( [A, A, A] );
<algebra of dimension 12 over Rationals>
gap> CentralIdempotentsOfAlgebra( B );
[ v.9, v.5, v.1 ]
\endexample

\>DirectSumDecomposition( <L> ) A

This function calculates a list of ideals of the algebra <L> such
that <L> is equal to their direct sum. Currently this is only implemented
for semisimple associative algebras, and Lie algebras (semisimple or not).



\beginexample
gap> G:= SymmetricGroup( 4 );;
gap> A:= GroupRing( Rationals, G );
<algebra-with-one over Rationals, with 2 generators>
gap> dd:= DirectSumDecomposition( A );
[ <two-sided ideal in <algebra-with-one of dimension 24 over Rationals>, 
      (1 generators)>, 
  <two-sided ideal in <algebra-with-one of dimension 24 over Rationals>, 
      (1 generators)>, 
  <two-sided ideal in <algebra-with-one of dimension 24 over Rationals>, 
      (1 generators)>, 
  <two-sided ideal in <algebra-with-one of dimension 24 over Rationals>, 
      (1 generators)>, 
  <two-sided ideal in <algebra-with-one of dimension 24 over Rationals>, 
      (1 generators)> ]
gap> List( dd, Dimension );
[ 1, 1, 4, 9, 9 ]
\endexample

\>LeviMalcevDecomposition( <L> ) A

A Levi-Malcev subalgebra of the algebra <L> is a semisimple subalgebra
complementary to the radical of <L>. This function returns
a list with two components. The first component is a Levi-Malcev 
subalgebra, the second the radical. This function is implemented for 
associative and Lie algebras. 



\beginexample
gap> m:= [ [ 1, 2, 0 ], [ 0, 1, 3 ], [ 0, 0, 1] ];;
gap> A:= Algebra( Rationals, [ m ] );;
gap> LeviMalcevDecomposition( A );
[ <algebra of dimension 1 over Rationals>, 
  <algebra of dimension 2 over Rationals> ]
\endexample

\>Grading( <A> ) A

Let $G$ be an Abelian group and $A$ an algebra. Then $A$ is said to 
be graded over $G$ if for every $g \in G$ there is a subspace $A_g$
of $A$ such that $A_g \cdot A_h \subset A_{g+h}$ for $g, h \in G$. 
In \GAP~4 a *grading* of an algebra is a record containing the following
components: 
\beginitems
`source'&
  the Abelian group over which the algebra is graded.
`hom_components'&
  a function assigning to each element from the
  source a subspace of the algebra.
`min_degree'&
  in the case where the algebra is graded over the integers
  this is the minimum number for which `hom_components' returns a nonzero
  subspace.
`max_degree'&
  is analogous to `min_degree'.
\enditems
We note that there are no methods to compute a grading of an 
arbitrary algebra; however some algebras get a natural grading when
they are constructed (see "ref:JenningsLieAlgebra", 
"ref:NilpotentQuotientOfFpLieAlgebra").

We note also that these components may be not enough to handle 
the grading efficiently, and another record component may be needed.
For instance in a Lie algebra $L$ constructed by 
`JenningsLieAlgebra', the length of the of the range
`[ Grading(L)!.min_degree .. Grading(L)!.max_degree ]' may be 
non-polynomial in the dimension of $L$.
To handle efficiently this situation, an optional component can be 
used:
\beginitems
`non_zero_hom_components'&
  the subset of `source' for which `hom_components' returns a nonzero
  subspace.
\enditems



\beginexample
gap> G:= SmallGroup(3^6, 100 );
<pc group of size 729 with 6 generators>
gap> L:= JenningsLieAlgebra( G );
<Lie algebra of dimension 6 over GF(3)>
gap> g:= Grading( L );
rec( min_degree := 1, max_degree := 9, source := Integers, 
  hom_components := function( d ) ... end )
gap> g.hom_components( 3 );
<vector space over GF(3), with 1 generators>
gap> g.hom_components( 14 );
<vector space over GF(3), with 0 generators>
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Homomorphisms of Algebras}

Algebra homomorphisms are vector space homomorphisms that preserve the
multiplication.
So the default methods for vector space homomorphisms work,
and in fact there is not much use of the fact that source and range are
algebras, except that preimages and images are algebras (or even ideals)
in certain cases.



\>AlgebraGeneralMappingByImages( <A>, <B>, <gens>, <imgs> ) O

is a general mapping from the $F$-algebra <A> to the $F$-algebra <B>.
This general mapping is defined by mapping the entries in the list <gens>
(elements of <A>) to the entries in the list <imgs> (elements of <B>),
and taking the $F$-linear and multiplicative closure.

<gens> need not generate <A> as an $F$-algebra, and if the
specification does not define a linear and multiplicative mapping then
the result will be multivalued.
Hence, in general it is not a mapping.
For constructing a linear map that is not
necessarily multiplicative, we refer to `LeftModuleHomomorphismByImages'
("ref:leftmodulehomomorphismbyimages").



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> B:= FullMatrixAlgebra( Rationals, 2 );;
gap> bA:= BasisVectors( Basis( A ) );; bB:= BasisVectors( Basis( B ) );;
gap> f:= AlgebraGeneralMappingByImages( A, B, bA, bB );
[ e, i, j, k ] -> [ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 0, 1 ], [ 0, 0 ] ], 
  [ [ 0, 0 ], [ 1, 0 ] ], [ [ 0, 0 ], [ 0, 1 ] ] ]
gap> Images( f, bA[1] );
<add. coset of <algebra over Rationals, with 60 generators>>
\endexample


\>AlgebraHomomorphismByImages( <A>, <B>, <gens>, <imgs> ) F

`AlgebraHomomorphismByImages' returns the algebra homomorphism with
source <A> and range <B> that is defined by mapping the list <gens> of
generators of <A> to the list <imgs> of images in <B>.

If <gens> does not generate <A> or if the homomorphism does not exist
(i.e., if mapping the generators describes only a multi-valued mapping)
then `fail' is returned.

One can avoid the checks by calling `AlgebraHomomorphismByImagesNC',
and one can construct multi-valued mappings with
`AlgebraGeneralMappingByImages'.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [1,1] ); SetEntrySCTable( T, 2, 2, [1,2] );
gap> A:= AlgebraByStructureConstants( Rationals, T );;
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> B:= AlgebraByGenerators( Rationals, [ m1, m2 ] );;
gap> bA:= BasisVectors( Basis( A ) );; bB:= BasisVectors( Basis( B ) );;
gap> f:= AlgebraHomomorphismByImages( A, B, bA, bB );
[ v.1, v.2 ] -> [ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 1 ] ] ]
gap> Image( f, bA[1]+bA[2] );
[ [ 1, 0 ], [ 0, 1 ] ]
\endexample


\>AlgebraHomomorphismByImagesNC( <A>, <B>, <gens>, <imgs> ) O

`AlgebraHomomorphismByImagesNC' is the operation that is called by the
function `AlgebraHomomorphismByImages'.
Its methods may assume that <gens> generates <A> and that the mapping of
<gens> to <imgs> defines an algebra homomorphism.
Results are unpredictable if these conditions do not hold.

For creating a possibly multi-valued mapping from <A> to <B> that
respects addition, multiplication, and scalar multiplication,
`AlgebraGeneralMappingByImages' can be used.





For the definitions of the algebras `A' and `B' in the next example we refer
to the previous example.

\beginexample
gap> f:= AlgebraHomomorphismByImagesNC( A, B, bA, bB );
[ v.1, v.2 ] -> [ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 1 ] ] ]
\endexample



\>AlgebraWithOneGeneralMappingByImages( <A>, <B>, <gens>, <imgs> ) O

This function is analogous to "AlgebraGeneralMappingByImages";
the only difference being that the identity of <A> is automatically
mapped to the identity of <B>.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );;
gap> B:= FullMatrixAlgebra( Rationals, 2 );;
gap> bA:= BasisVectors( Basis( A ) );; bB:= BasisVectors( Basis( B ) );;
gap> f:= AlgebraWithOneGeneralMappingByImages(A,B,bA{[2,3,4]},bB{[1,2,3]});
[ i, j, k, e ] -> [ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 0, 1 ], [ 0, 0 ] ], 
  [ [ 0, 0 ], [ 1, 0 ] ], [ [ 1, 0 ], [ 0, 1 ] ] ]
\endexample


\>AlgebraWithOneHomomorphismByImages( <A>, <B>, <gens>, <imgs> ) F

`AlgebraWithOneHomomorphismByImages' returns the algebra-with-one
homomorphism with source <A> and range <B> that is defined by mapping the
list <gens> of generators of <A> to the list <imgs> of images in <B>.

The difference between an algebra homomorphism and an algebra-with-one
homomorphism is that in the latter case,
it is assumed that the identity of <A> is mapped to the identity of <B>,
and therefore <gens> needs to generate <A> only as an
algebra-with-one.

If <gens> does not generate <A> or if the homomorphism does not exist
(i.e., if mapping the generators describes only a multi-valued mapping)
then `fail' is returned.

One can avoid the checks by calling
`AlgebraWithOneHomomorphismByImagesNC',
and one can construct multi-valued mappings with
`AlgebraWithOneGeneralMappingByImages'.



\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:=1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:=1;;
gap> A:= AlgebraByGenerators( Rationals, [m1,m2] );;
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [1,1] );
gap> SetEntrySCTable( T, 2, 2, [1,2] );
gap> B:= AlgebraByStructureConstants(Rationals, T);;
gap> bA:= BasisVectors( Basis( A ) );; bB:= BasisVectors( Basis( B ) );;
gap> f:= AlgebraWithOneHomomorphismByImages( A, B, bA{[1]}, bB{[1]} );
[ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 1, 0 ], [ 0, 1 ] ] ] -> [ v.1, v.1+v.2 ]
\endexample


\>AlgebraWithOneHomomorphismByImagesNC( <A>, <B>, <gens>, <imgs> ) O

`AlgebraWithOneHomomorphismByImagesNC' is the operation that is called by
the function `AlgebraWithOneHomomorphismByImages'.
Its methods may assume that <gens> generates <A> and that the mapping of
<gens> to <imgs> defines an algebra-with-one homomorphism.
Results are unpredictable if these conditions do not hold.

For creating a possibly multi-valued mapping from <A> to <B> that
respects addition, multiplication, identity, and scalar multiplication,
`AlgebraWithOneGeneralMappingByImages' can be used.




\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:=1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:=1;;
gap> A:= AlgebraByGenerators( Rationals, [m1,m2] );;
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [1,1] );
gap> SetEntrySCTable( T, 2, 2, [1,2] );
gap> B:= AlgebraByStructureConstants( Rationals, T);;
gap> bA:= BasisVectors( Basis( A ) );; bB:= BasisVectors( Basis( B ) );;
gap> f:= AlgebraWithOneHomomorphismByImagesNC( A, B, bA{[1]}, bB{[1]} );
[ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 1, 0 ], [ 0, 1 ] ] ] -> [ v.1, v.1+v.2 ]
\endexample

\>NaturalHomomorphismByIdeal( <A>, <I> ) O

is the homomorphism of algebras provided by the natural
projection map of <A> onto the quotient algebra <A>/<I>.
This map can be used to take pre-images in the original algebra from
elements in the quotient.



\beginexample
gap> L:= FullMatrixLieAlgebra( Rationals, 3 );;
gap> C:= LieCentre( L );
<two-sided ideal in <Lie algebra of dimension 9 over Rationals>, (dimension 1
 )>
gap> hom:= NaturalHomomorphismByIdeal( L, C );
<linear mapping by matrix, <Lie algebra of dimension 
9 over Rationals> -> <Lie algebra of dimension 8 over Rationals>>
gap> ImagesSource( hom );
<Lie algebra of dimension 8 over Rationals>
\endexample

\>OperationAlgebraHomomorphism( <A>, <B>[, <opr>] ) O
\>OperationAlgebraHomomorphism( <A>, <V>[, <opr>] ) O

`OperationAlgebraHomomorphism' returns an algebra homomorphism from the
$F$-algebra <A> into a matrix algebra over $F$ that describes the
$F$-linear action of <A> on the basis <B> of a free left module
respectively on the free left module <V> (in which case some basis of <V>
is chosen), via the operation <opr>.

The homomorphism need not be surjective.
The default value for <opr> is `OnRight'.

If <A> is an algebra-with-one then the operation homomorphism is an
algebra-with-one homomorphism because the identity of <A> must act
as the identity.




\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> B:= AlgebraByGenerators( Rationals, [ m1, m2 ] );;
gap> V:= FullRowSpace( Rationals, 2 );
( Rationals^2 )
gap> f:=OperationAlgebraHomomorphism( B, Basis( V ), OnRight );
<op. hom. Algebra( Rationals, 
[ [ [ 1, 0 ], [ 0, 0 ] ], [ [ 0, 0 ], [ 0, 1 ] ] ] ) -> matrices of dim. 2>
gap> Image( f, m1 );
[ [ 1, 0 ], [ 0, 0 ] ]
\endexample

\>IsomorphismFpAlgebra( <A> ) A

isomorphism from the algebra <A> onto a finitely presented algebra. Currently this
is only implemented for associative algebras with one.



\beginexample
gap> A:= QuaternionAlgebra( Rationals );
<algebra-with-one of dimension 4 over Rationals>
gap> f:= IsomorphismFpAlgebra( A );
[ e, i, j, k, e ] -> [ [(1)*x.1], [(1)*x.2], [(1)*x.3], [(1)*x.4], 
  [(1)*<identity ...>] ]
\endexample

\>IsomorphismMatrixAlgebra( <A> ) A

isomorphism from the algebra <A> onto a matrix algebra. Currently this
is only implemented for associative algebras with one.



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> SetEntrySCTable( T, 1, 1, [1,1] ); SetEntrySCTable( T, 2, 2, [1,2] );
gap> A:= AlgebraByStructureConstants( Rationals, T );;
gap> A:= AsAlgebraWithOne( Rationals, A );;
gap> f:=IsomorphismMatrixAlgebra( A );
<op. hom. AlgebraWithOne( Rationals, ... ) -> matrices of dim. 2>
gap> Image( f, BasisVectors( Basis( A ) )[1] );
[ [ 1, 0 ], [ 0, 0 ] ]
\endexample

\>IsomorphismSCAlgebra( <B> ) A
\>IsomorphismSCAlgebra( <A> ) A

For a basis <B> of an algebra $A$, say, `IsomorphismSCAlgebra' returns an
algebra isomorphism from $A$ to an algebra $S$ given by structure
constants (see~"Constructing Algebras by Structure Constants"),
such that the canonical basis of $S$ is the image of <B>.

For an algebra <A>, `IsomorphismSCAlgebra' chooses a basis of <A> and
returns the `IsomorphismSCAlgebra' value for that basis.



\beginexample
gap> IsomorphismSCAlgebra( GF(8) );
CanonicalBasis( GF(2^3) ) -> CanonicalBasis( <algebra of dimension 3 over GF(
2)> )
gap> IsomorphismSCAlgebra( GF(2)^[2,2] );
CanonicalBasis( ( GF(2)^[ 2, 2 ] ) ) -> CanonicalBasis( <algebra of dimension 
4 over GF(2)> )
\endexample


\>RepresentativeLinearOperation( <A>, <v>, <w>, <opr> ) O

is an element of the algebra <A> that maps the vector <v>
to the vector <w> under the linear operation described by the function
<opr>. If no such element exists then `fail' is returned.




\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> B:= AlgebraByGenerators( Rationals, [ m1, m2 ] );;
gap> RepresentativeLinearOperation( B, [1,0], [1,0], OnRight );
[ [ 1, 0 ], [ 0, 0 ] ]
gap> RepresentativeLinearOperation( B, [1,0], [0,1], OnRight );
fail
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Representations of Algebras}

An algebra module is a vector space together with an action of an
algebra. So a module over an algebra is constructed by giving generators
of a vector space, and a function for calculating the action of
algebra elements on elements of the vector space. When creating an
algebra module, the generators of the vector space are wrapped up and
given the category `IsLeftAlgebraModuleElement' or
`IsRightModuleElement' if the algebra acts from the left, or right
respectively. (So in the case of a bi-module the elements get
both categories.) Most linear algebra computations are delegated to
the original vector space.

The transition between the original vector space and the corresponding
algebra module is handled by `ExtRepOfObj' and `ObjByExtRep'.
For an element `v' of the algebra module, `ExtRepOfObj( v )' returns
the underlying element of the original vector space. Furthermore, if `vec'
is an element of the original vector space, and `fam' the elements
family of the corresponding algebra module, then `ObjByExtRep( fam, vec )'
returns the corresponding element of the algebra module. Below is an
example of this.

The action of the algebra on elements of the algebra module is constructed
by using the operator `^'. If `x' is an element of an algebra `A', and
`v' an element of a left `A'-module, then `x^v' calculates the result
of the action of `x' on `v'. Similarly, if `v' is an element of
a right `A'-module, then `v^x' calculates the action of `x' on `v'.



\>LeftAlgebraModuleByGenerators( <A>, <op>, <gens> ) O

Constructs the left algebra module over <A> generated by the list of
vectors
<gens>. The action of <A> is described by the function <op>. This must
be a function of two arguments; the first argument is the algebra element,
and the second argument is a vector; it outputs the result of applying
the algebra element to the vector.


\>RightAlgebraModuleByGenerators( <A>, <op>, <gens> ) O

Constructs the right algebra module over <A> generated by the list of
vectors
<gens>. The action of <A> is described by the function <op>. This must
be a function of two arguments; the first argument is a vector, and the
second argument is the algebra element; it outputs the result of applying
the algebra element to the vector.


\>BiAlgebraModuleByGenerators( <A>, <B>, <opl>, <opr>, <gens> ) O

Constructs the algebra bi-module over <A> and <B> generated by the list of
vectors
<gens>. The left action of <A> is described by the function <opl>,
and the right action of <B> by the function <opr>. <opl> must be a
function of two arguments; the first argument is the algebra element,
and the second argument is a vector; it outputs the result of applying
the algebra element on the left to the vector. <opr> must
be a function of two arguments; the first argument is a vector, and the
second argument is the algebra element; it outputs the result of applying
the algebra element on the right to the vector.



\beginexample
gap> A:= Rationals^[3,3];
( Rationals^[ 3, 3 ] )
gap> V:= LeftAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );
<left-module over ( Rationals^[ 3, 3 ] )>
gap> W:= RightAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );
<right-module over ( Rationals^[ 3, 3 ] )>
gap> M:= BiAlgebraModuleByGenerators( A, A, \*, \*, [ [ 1, 0, 0 ] ] );
<bi-module over ( Rationals^[ 3, 3 ] ) (left) and ( Rationals^
[ 3, 3 ] ) (right)>
\endexample

In the above examples, the modules `V', `W', and `M' are $3$-dimensional
vector spaces over the rationals.
The algebra `A' acts from the left on `V', from the right on `W',
and from the left and from the right on `M'.


\>LeftAlgebraModule( <A>, <op>, <V> ) O

Constructs the left algebra module over <A> with underlying space <V>.
The action of <A> is described by the function <op>. This must
be a function of two arguments; the first argument is the algebra element,
and the second argument is a vector from <V>; it outputs the result of 
applying the algebra element to the vector.


\>RightAlgebraModule( <A>, <op>, <V> ) O

Constructs the right algebra module over <A> with underlying space <V>.
The action of <A> is described by the function <op>. This must
be a function of two arguments; the first argument is a vector, from <V>
and the
second argument is the algebra element; it outputs the result of applying
the algebra element to the vector.


\>BiAlgebraModule( <A>, <B>, <opl>, <opr>, <V> ) O

Constructs the algebra bi-module over <A> and <B> with underlying space 
<V>. The left action of <A> is described by the function <opl>,
and the right action of <B> by the function <opr>. <opl> must be a
function of two arguments; the first argument is the algebra element,
and the second argument is a vector from <V>; it outputs the result of 
applying
the algebra element on the left to the vector. <opr> must
be a function of two arguments; the first argument is a vector from <V>, 
and the
second argument is the algebra element; it outputs the result of applying
the algebra element on the right to the vector.



\beginexample
gap> A:= Rationals^[3,3];;
gap> V:= Rationals^3;
( Rationals^3 )
gap> V:= Rationals^3;;
gap> M:= BiAlgebraModule( A, A, \*, \*, V );
<bi-module over ( Rationals^[ 3, 3 ] ) (left) and ( Rationals^
[ 3, 3 ] ) (right)>
gap> Dimension( M );
3
\endexample


\>GeneratorsOfAlgebraModule( <M> ) A

A list of elements of <M> that generate <M> as an algebra module.



\beginexample
gap> A:= Rationals^[3,3];;
gap> V:= LeftAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );;
gap> GeneratorsOfAlgebraModule( V );
[ [ 1, 0, 0 ] ]
\endexample

\>IsAlgebraModuleElement( <obj> ) C
\>IsAlgebraModuleElementCollection( <obj> ) C
\>IsAlgebraModuleElementFamily( <fam> ) C

Category of algebra module elements. If an object has
`IsAlgebraModuleElementCollection', then it is an algebra module.
If a family has `IsAlgebraModuleElementFamily', then it is a family
of algebra module elements (every algebra module has its own elements
family).


\>IsLeftAlgebraModuleElement( <obj> ) C
\>IsLeftAlgebraModuleElementCollection( <obj> ) C

Category of left algebra module elements. If an object has
`IsLeftAlgebraModuleElementCollection', then it is a left-algebra module.


\>IsRightAlgebraModuleElement( <obj> ) C
\>IsRightAlgebraModuleElementCollection( <obj> ) C

Category of right algebra module elements. If an object has
`IsRightAlgebraModuleElementCollection', then it is a right-algebra module.



\beginexample
gap> A:= Rationals^[3,3];
( Rationals^[ 3, 3 ] )
gap> M:= BiAlgebraModuleByGenerators( A, A, \*, \*, [ [ 1, 0, 0 ] ] );
<bi-module over ( Rationals^[ 3, 3 ] ) (left) and ( Rationals^
[ 3, 3 ] ) (right)>
gap> vv:= BasisVectors( Basis( M ) );
[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
gap> IsLeftAlgebraModuleElement( vv[1] );
true
gap> IsRightAlgebraModuleElement( vv[1] );
true
gap> vv[1] = [ 1, 0, 0 ];
false
gap> ExtRepOfObj( vv[1] ) = [ 1, 0, 0 ];
true
gap> ObjByExtRep( ElementsFamily( FamilyObj( M ) ), [ 1, 0, 0 ] ) in M;
true
gap> xx:= BasisVectors( Basis( A ) );;
gap> xx[4]^vv[1];  # left action
[ 0, 1, 0 ]
gap> vv[1]^xx[2];  # right action
[ 0, 1, 0 ]
\endexample

\>LeftActingAlgebra( <V> ) A

Here <V> is a left-algebra module; this function returns the algebra
that acts from the left on <V>.


\>RightActingAlgebra( <V> ) A

Here <V> is a right-algebra module; this function returns the algebra
that acts from the right on <V>.


\>ActingAlgebra( <V> ) O

Here <V> is an algebra module; this function returns the algebra
that acts on <V> (this is the same as `LeftActingAlgebra( <V> )' if <V> is
a left module, and `RightActingAlgebra( <V> )' if <V> is a right module;
it will signal an error if <V> is a bi-module).



\beginexample
gap> A:= Rationals^[3,3];;
gap> M:= BiAlgebraModuleByGenerators( A, A, \*, \*, [ [ 1, 0, 0 ] ] );;
gap> LeftActingAlgebra( M );
( Rationals^[ 3, 3 ] )
gap> RightActingAlgebra( M );
( Rationals^[ 3, 3 ] )
gap> V:= RightAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );;
gap> ActingAlgebra( V );
( Rationals^[ 3, 3 ] )
\endexample

\>IsBasisOfAlgebraModuleElementSpace( <B> ) C

If a basis <B> lies in the category `IsBasisOfAlgebraModuleElementSpace',
then
<B> is a basis of a subspace of an algebra module. This means that
<B> has the record field `<B>!.delegateBasis' set. This last object
is a basis of the corresponding subspace of the vector space underlying
the algebra module (i.e., the vector
space spanned by all `ExtRepOfObj( v )' for `v' in
the algebra module).



\beginexample
gap> A:= Rationals^[3,3];;
gap> M:= BiAlgebraModuleByGenerators( A, A, \*, \*, [ [ 1, 0, 0 ] ] );;
gap> B:= Basis( M );
Basis( <3-dimensional bi-module over ( Rationals^
[ 3, 3 ] ) (left) and ( Rationals^[ 3, 3 ] ) (right)>, 
[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ] )
gap> IsBasisOfAlgebraModuleElementSpace( B );
true
gap> B!.delegateBasis;
SemiEchelonBasis( <vector space of dimension 3 over Rationals>, 
[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ] )
\endexample

\>MatrixOfAction( <B>, <x> ) O
\>MatrixOfAction( <B>, <x>, <side> ) O

Here <B> is a basis of an algebra module and <x> is an element
of the algebra that acts on this module. This function returns
the matrix of the action of <x> with respect to <B>. If <x> acts
from the left, then the coefficients of the images of the basis
elements of <B> (under the action of <x>) are the columns of the output.
If <x> acts from the
right, then they are the rows of the output.

If the module is a bi-module, then the third parameter <side> must
be specified. This is the string `left', or `right' depending whether
<x> acts from the left or the right.



\beginexample
gap> M:= LeftAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );;
gap> x:= Basis(A)[3];
[ [ 0, 0, 1 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ]
gap> MatrixOfAction( Basis( M ), x );
[ [ 0, 0, 1 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ]
\endexample

\>SubAlgebraModule( <M>, <gens> [, <"basis">] ) O

is the sub-module of the algebra module <M>, generated by the vectors
in <gens>. If as an optional argument the string `basis' is added, then
it is
assumed that the vectors in <gens> form a basis of the submodule.



\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> A:= Algebra( Rationals, [ m1, m2 ] );;
gap> M:= LeftAlgebraModuleByGenerators( A, \*, [ [ 1, 0 ], [ 0, 1 ] ] );
<left-module over <algebra over Rationals, with 2 generators>>
gap> bb:= BasisVectors( Basis( M ) );
[ [ 1, 0 ], [ 0, 1 ] ]
gap> V:= SubAlgebraModule( M, [ bb[1] ] );
<left-module over <algebra over Rationals, with 2 generators>>
gap> Dimension( V );
1
\endexample

\>LeftModuleByHomomorphismToMatAlg( <A>, <hom> ) O

Here <A> is an algebra and <hom> a homomorphism from <A> into a matrix
algebra. This function returns the left <A>-module defined by the
homomorphism <hom>.


\>RightModuleByHomomorphismToMatAlg( <A>, <hom> ) O

Here <A> is an algebra and <hom> a homomorphism from <A> into a matrix
algebra. This function returns the right <A>-module defined by the
homomorphism <hom>.



First we produce a structure constants algebra with basis elements
$x$, $y$, $z$ such that $x^2 = x$, $y^2 = y$, $xz = z$, $zy = z$
and all other products are zero.

\beginexample
gap> T:= EmptySCTable( 3, 0 );;
gap> SetEntrySCTable( T, 1, 1, [ 1, 1 ]);
gap> SetEntrySCTable( T, 2, 2, [ 1, 2 ]);
gap> SetEntrySCTable( T, 1, 3, [ 1, 3 ]);
gap> SetEntrySCTable( T, 3, 2, [ 1, 3 ]);
gap> A:= AlgebraByStructureConstants( Rationals, T );
<algebra of dimension 3 over Rationals>
\endexample

Now we construct an isomorphic matrix algebra.

\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> m3:= NullMat( 2, 2 );; m3[1][2]:= 1;;
gap> B:= Algebra( Rationals, [ m1, m2, m3 ] );
<algebra over Rationals, with 3 generators>
\endexample

Finally we construct the homomorphism and the corresponding right module.

\beginexample
gap> f:= AlgebraHomomorphismByImages( A, B, Basis(A), [ m1, m2, m3 ] );;
gap> RightModuleByHomomorphismToMatAlg( A, f );
<right-module over <algebra of dimension 3 over Rationals>>
\endexample

\>AdjointModule( <A> ) A

returns the <A>-module defined by the left action of <A> on itself.



\beginexample
gap> m1:= NullMat( 2, 2 );; m1[1][1]:= 1;;
gap> m2:= NullMat( 2, 2 );; m2[2][2]:= 1;;
gap> m3:= NullMat( 2, 2 );; m3[1][2]:= 1;;
gap> A:= Algebra( Rationals, [ m1, m2, m3 ] );
<algebra over Rationals, with 3 generators>
gap> V:= AdjointModule( A );
<3-dimensional left-module over <algebra of dimension 3 over Rationals>>
gap> v:= Basis( V )[3];
[ [ 0, 1 ], [ 0, 0 ] ]
gap> W:= SubAlgebraModule( V, [ v ] );
<left-module over <algebra of dimension 3 over Rationals>>
gap> Dimension( W );
1
\endexample

% One would be tempted to call `W' a left ideal in `V',
% but in the current implementation, neither `V' nor `W' are themselves
% algebras; note that the element `v', although looking like a matrix,
% cannot be multiplied with itself.

\>FaithfulModule( <A> ) A

returns a faithful finite-dimensional left-module over the algebra <A>.
This is only implemented for associative algebras, and for Lie algebras
of characteristic $0$. (It may also work for certain Lie algebras
of characteristic $p>0$.)



\beginexample
gap> T:= EmptySCTable( 2, 0 );;
gap> A:= AlgebraByStructureConstants( Rationals, T );
<algebra of dimension 2 over Rationals>
\endexample

`A' is a $2$-dimensional algebra where all products are zero.

\beginexample
gap> V:= FaithfulModule( A );
<left-module over <algebra of dimension 2 over Rationals>>
gap> vv:= BasisVectors( Basis( V ) );
[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]
gap> xx:= BasisVectors( Basis( A ) );
[ v.1, v.2 ]
gap> xx[1]^vv[3];
[ 1, 0, 0 ]
\endexample


\>ModuleByRestriction( <V>, <sub> ) O
\>ModuleByRestriction( <V>, <subl>, <subr> ) O

Here <V> is an algebra module and <sub> is a subalgebra
of the acting algebra of <V>. This function returns the
module that is the restriction of <V> to <sub>. So it has the
same underlying vector space as <V>, but the acting algebra is
<sub>.  If two subalgebras are given then <V> is assumed to be a
bi-module, and <subl> a subalgebra of the algebra acting on the left,
and <subr> a subalgebra of the algebra acting on the right.



\beginexample
gap> A:= Rationals^[3,3];;
gap> V:= LeftAlgebraModuleByGenerators( A, \*, [ [ 1, 0, 0 ] ] );;
gap> B:= Subalgebra( A, [ Basis(A)[1] ] );
<algebra over Rationals, with 1 generators>
gap> W:= ModuleByRestriction( V, B );
<left-module over <algebra over Rationals, with 1 generators>>
\endexample


\>NaturalHomomorphismBySubAlgebraModule( <V>, <W> ) O

Here <V> must be a sub-algebra module of <V>. This function returns
the projection from <V> onto `<V>/<W>'. It is a linear map, that is
also a module homomorphism. As usual images can be formed with
`Image( f, v )' and pre-images with `PreImagesRepresentative( f, u )'.

The quotient module can also be formed
by entering `<V>/<W>'.





\beginexample
gap> A:= Rationals^[3,3];;
gap> B:= DirectSumOfAlgebras( A, A );
<algebra over Rationals, with 6 generators>
gap> T:= StructureConstantsTable( Basis( B ) );;
gap> C:= AlgebraByStructureConstants( Rationals, T );
<algebra of dimension 18 over Rationals>
gap> V:= AdjointModule( C );
<left-module over <algebra of dimension 18 over Rationals>>
gap> W:= SubAlgebraModule( V, [ Basis(V)[1] ] );
<left-module over <algebra of dimension 18 over Rationals>>
gap> f:= NaturalHomomorphismBySubAlgebraModule( V, W );
<linear mapping by matrix, <
18-dimensional left-module over <algebra of dimension 18 over Rationals>> -> <
9-dimensional left-module over <algebra of dimension 18 over Rationals>>>
gap> quo:= ImagesSource( f );  # i.e., the quotient module
<9-dimensional left-module over <algebra of dimension 18 over Rationals>>
gap> v:= Basis( quo )[1];
[ 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
gap> PreImagesRepresentative( f, v );
v.4
gap> Basis( C )[4]^v;
[ 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
\endexample


\>DirectSumOfAlgebraModules( <list> ) O
\>DirectSumOfAlgebraModules( <V>, <W> ) O

Here <list> must be a list of algebra modules. This function returns the
direct sum of the elements in the list (as an algebra module).
The modules must be defined over the same algebras.

In the second form is short for `DirectSumOfAlgebraModules( [ <V>, <W> ] )'



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 3 );;
gap> V:= BiAlgebraModuleByGenerators( A, A, \*, \*, [ [1,0,0] ] );;
gap> W:= DirectSumOfAlgebraModules( V, V );
<6-dimensional left-module over ( Rationals^[ 3, 3 ] )>
gap> BasisVectors( Basis( W ) );
[ ( [ 1, 0, 0 ] )(+)( [ 0, 0, 0 ] ), ( [ 0, 1, 0 ] )(+)( [ 0, 0, 0 ] ), 
  ( [ 0, 0, 1 ] )(+)( [ 0, 0, 0 ] ), ( [ 0, 0, 0 ] )(+)( [ 1, 0, 0 ] ), 
  ( [ 0, 0, 0 ] )(+)( [ 0, 1, 0 ] ), ( [ 0, 0, 0 ] )(+)( [ 0, 0, 1 ] ) ]
\endexample


\>TranslatorSubalgebra( <M>, <U>, <W> ) O

 Here <M> is an algebra module, and <U> and <W> are two subspaces of <M>. 
 Let <A> be the algebra acting on <M>. This function returns the subspace
 of elements of <A> that map <U> into <W>. If <W> is a sub-algebra-module
 (i.e., closed under the action of <A>), then this space is a subalgebra
 of <A>. 

 This function works for left, or right modules over a
 finite-dimensional algebra. We
 stress that it is not checked whether <U> and <W> are indeed subspaces
 of <M>. If this is not the case nothing is guaranteed about the behaviour
 of the function.



\beginexample
gap> A:= FullMatrixAlgebra( Rationals, 3 );
( Rationals^[ 3, 3 ] )
gap> V:= Rationals^[3,2];
( Rationals^[ 3, 2 ] )
gap> M:= LeftAlgebraModule( A, \*, V );
<left-module over ( Rationals^[ 3, 3 ] )>
gap> bm:= Basis(M);;
gap> U:= SubAlgebraModule( M, [ bm[1] ] );   
<left-module over ( Rationals^[ 3, 3 ] )>
gap> TranslatorSubalgebra( M, U, M );
<algebra of dimension 9 over Rationals>
gap> W:= SubAlgebraModule( M, [ bm[4] ] );
<left-module over ( Rationals^[ 3, 3 ] )>
gap> T:=TranslatorSubalgebra( M, U, W );
<algebra of dimension 0 over Rationals>
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%E

