We illustrate how user attributes may be defined and used in an interactive
session. This situation would arise rarely -- more commonly, attributes
would be used within packages.
We illustrate how user attributes may be used in packages.
This is the most common usage of such attributes. We first
give some (rather naive) Magma code to compute and store
a permutation representation of a matrix group. Suppose
the following code is stored in the file
permrep.m.
declare attributes GrpMat: PermRep, PermRepMap;
intrinsic PermutationRepresentation(G::GrpMat) -> GrpPerm
{A permutation group representation P of G, with homomorphism f: G -> P};
// Only compute rep if not already stored.
if not assigned G`PermRep then
G`PermRepMap, G`PermRep := CosetAction(G, sub<G|>);
end if;
return G`PermRep, G`PermRepMap;
end intrinsic;
Note that the information stored will be reused in subsequent calls of
the intrinsic.
Then the package can be attached within a Magma session and the
intrinsic
PermutationRepresentation called like in the
following code (assumed to be run in the same directory).
> Attach("permrep.m");
> G := GL(2, 2);
> P, f := PermutationRepresentation(G);
> P;
Permutation group P acting on a set of cardinality 6
(1, 2)(3, 5)(4, 6)
(1, 3)(2, 4)(5, 6)
> f;
Mapping from: GrpMat: G to GrpPerm: P
Suppose the following line were also in the package file:
declare verbose MyAlgorithm, 3;
Then there would be a new verbose flag
MyAlgorithm for
use anywhere within Magma, with the maximum 3 for the level.
[Next][Prev] [Right] [Left] [Up] [Index] [Root]