File: algebra.tex

package info (click to toggle)
gap 4r4p12-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 29,584 kB
  • ctags: 7,113
  • sloc: ansic: 98,786; sh: 3,299; perl: 2,263; makefile: 498; asm: 63; awk: 6
file content (2050 lines) | stat: -rw-r--r-- 66,428 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
% 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.2 2007/08/28 12:58:50 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>[, <a>, <b>] ) F

Let <F> be a field or a list of field elements,
let $F$ be the field generated by <F>,
and let <a> and <b> two elements in $F$.
`QuaternionAlgebra' returns a quaternion algebra over
$F$, with parameters <a> and <b>,
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 ]$.

Two quaternion algebras with the same parameters <a>, <b>
lie in the same family, so it makes sense to consider their intersection
or to ask whether they are contained in each other.
(This is due to the fact that the results of
`QuaternionAlgebra' are cached,
in the global variable `QuaternionAlgebraData'.

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 construction 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 for 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

Let <lst>  be a nonempty list of square matrices of the same
dimension $n$, say, with entries in the field <F>.
`FullMatrixAlgebraCentralizer' returns
the centralizer of all matrices in <lst>, inside
the full matrix algebra of $n \times n$ matrices over <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