User-defined Verbose Flags

Verbose flags may be defined by users within packages.

Contents

declare verbose F, m;
Given a verbose flag name F (without quotes), and a literal integer m, create the verbose flag F, with the maximal allowable level for the flag set to m. This directive may only be used within package files.

Examples

In this subsection we give examples which illustrate all of the above features.

Example Func_SystemAttributes (H2E14)

We illustrate how the predefined system attributes may be used. Note that the valid arguments for AssertAttribute and HasAttribute documented elsewhere now also work as system attributes so see the documentation for these functions for details as to the valid system attribute field names.
> // Create group G.
> G := PSL(3, 2);
> // Check whether order known.
> assigned G`Order;
false
> // Attempt to access order -- error since not assigned.
> G`Order;
>> G`Order;
    ^
Runtime error in `: Attribute 'Order' for this structure
is valid but not assigned
> // Force computation of order by intrinsic Order.
> Order(G);
168
> // Check Order field again.
> assigned G`Order;
true
> G`Order;
168
> G""Order"; // String form for field
168
> o := "Order";
> G"o;
168
> // Create code C and set its minimum weight.
> C := QRCode(GF(2), 31);
> C`MinimumWeight := 7;
> C;
[31, 16, 7] Quadratic Residue code over GF(2)
...

Example Func_InteractiveUserAttributes (H2E15)

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.
> // Add attribute field MyStuff for matrix groups.
> AddAttribute(GrpMat, "MyStuff");
> // Create group G.
> G := GL(2, 3);
> // Try illegal field.
> G`silly;
>> G`silly;
    ^
Runtime error in `: Invalid attribute 'silly' for this structure
> // Try legal but unassigned field.
> G`MyStuff;
>> G`MyStuff;
    ^
Runtime error in `: Attribute 'MyStuff' for this structure is valid but not
assigned
> // Assign field and notice value.
> G`MyStuff := [1, 2];
> G`MyStuff;
[ 1, 2 ]

Example Func_PackageUserAttributes (H2E16)

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.
V2.28, 13 July 2023