Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

9 Technical Details
 9.1 The Category Cat
 9.2 Tools

  9.2-1 FunctionWithNamedArguments

  9.2-2 CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING

  9.2-3 CAP_INTERNAL_GET_DATA_TYPES_FROM_STRINGS

  9.2-4 CAP_INTERNAL_REPLACED_STRING_WITH_FILTER

  9.2-5 CAP_INTERNAL_REPLACED_STRINGS_WITH_FILTERS

  9.2-6 CAP_INTERNAL_MERGE_FILTER_LISTS

  9.2-7 CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT

  9.2-8 CAP_INTERNAL_FIND_APPEARANCE_OF_SYMBOL_IN_FUNCTION

  9.2-9 CAP_INTERNAL_MERGE_PRECONDITIONS_LIST

  9.2-10 CAP_INTERNAL_ASSERT_VALUE_IS_OF_TYPE_GETTER

  9.2-11 CAP_INTERNAL_ASSERT_IS_CELL_OF_CATEGORY

  9.2-12 CAP_INTERNAL_ASSERT_IS_OBJECT_OF_CATEGORY

  9.2-13 CAP_INTERNAL_ASSERT_IS_MORPHISM_OF_CATEGORY

  9.2-14 CAP_INTERNAL_ASSERT_IS_TWO_CELL_OF_CATEGORY

  9.2-15 CachingStatistic

  9.2-16 BrowseCachingStatistic

  9.2-17 InstallDeprecatedAlias

  9.2-18 IsSpecializationOfFilter

  9.2-19 IsSpecializationOfFilterList

  9.2-20 InstallMethodForCompilerForCAP

  9.2-21 InstallOtherMethodForCompilerForCAP

  9.2-22 CapJitAddKnownMethod

  9.2-23 CapJitAddTypeSignature

  9.2-24 CapJitAddTypeSignatureDeferred

  9.2-25 CapJitDataTypeOfListOf

  9.2-26 CapJitDataTypeOfNTupleOf

  9.2-27 CapJitDataTypeOfCategory

  9.2-28 CapJitTypedExpression

  9.2-29 CapFixpoint

  9.2-30 Iterated

  9.2-31 Iterated

  9.2-32 TransitivelyNeededOtherPackages

  9.2-33 PackageOfCAPOperation

  9.2-34 SafePosition

  9.2-35 SafeUniquePosition

  9.2-36 SafePositionProperty

  9.2-37 SafeUniquePositionProperty

  9.2-38 SafeFirst

  9.2-39 SafeUniqueEntry

  9.2-40 NTuple

  9.2-41 Pair

  9.2-42 Triple

  9.2-43 TransposedMatWithGivenDimensions

  9.2-44 HandlePrecompiledTowers

  9.2-45 CAP_JIT_INCOMPLETE_LOGIC

  9.2-46 CAP_JIT_EXPR_CASE_WRAPPER

  9.2-47 ListWithKeys

  9.2-48 SumWithKeys

  9.2-49 ProductWithKeys

  9.2-50 ForAllWithKeys

  9.2-51 ForAnyWithKeys

  9.2-52 NumberWithKeys

  9.2-53 FilteredWithKeys

  9.2-54 FirstWithKeys

  9.2-55 LastWithKeys

9 Technical Details

9.1 The Category Cat

9.1-1 ObjectCache
‣ ObjectCache( functor )( attribute )

Returns: IsCachingObject

Retuns the caching object which stores the results of the functor functor applied to objects.

9.1-2 MorphismCache
‣ MorphismCache( functor )( attribute )

Returns: IsCachingObject

Retuns the caching object which stores the results of the functor functor applied to morphisms.

9.2 Tools

9.2-1 FunctionWithNamedArguments
‣ FunctionWithNamedArguments( specification, func )( function )

Returns: a function

Simulates named arguments in GAP as follows:

When calling the returned function, the arguments are passed on to func. To simulate named arguments, any GAP options appearing in specification are consumed and put into the record CAP_NAMED_ARGUMENTS.

9.2-2 CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING
‣ CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING( filter_string[, category] )( function )

Returns: a record

The function takes one of the strings listed under filter_list in 7.3 as input and returns the corresponding data type (see CapJitInferredDataTypes (CompilerForCAP: CapJitInferredDataTypes) for details). If no category is given, data types with generic filters (IsCapCategoryObject, IsCapCategoryMorphism etc.) are returned. However, those cannot be used in the context of CompilerForCAP because the component category cannot be set in this case.

9.2-3 CAP_INTERNAL_GET_DATA_TYPES_FROM_STRINGS
‣ CAP_INTERNAL_GET_DATA_TYPES_FROM_STRINGS( list_of_strings[, category] )( function )

Returns: a list

Applies CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING (9.2-2) to all elements of list and returns the result.

9.2-4 CAP_INTERNAL_REPLACED_STRING_WITH_FILTER
‣ CAP_INTERNAL_REPLACED_STRING_WITH_FILTER( filter_string[, category] )( function )

Returns: a filter

The function takes one of the strings listed under filter_list in 7.3 as input. The corresponding filter of the category category is returned. If no category is given, generic filters (IsCapCategoryObject, IsCapCategoryMorphism etc.) are used.

9.2-5 CAP_INTERNAL_REPLACED_STRINGS_WITH_FILTERS
‣ CAP_INTERNAL_REPLACED_STRINGS_WITH_FILTERS( list[, category] )( function )

Returns: Replaced list

Applies CAP_INTERNAL_REPLACED_STRING_WITH_FILTER (9.2-4) to all elements of list and returns the result.

9.2-6 CAP_INTERNAL_MERGE_FILTER_LISTS
‣ CAP_INTERNAL_MERGE_FILTER_LISTS( list, additional, list )( function )

Returns: merged lists

The first argument should be a dense list with filters, the second a sparse list containing filters not longer then the first one. The filters of the second list are then appended (via and) to the filters in the first list at the corresponding position, and the resulting list is returned.

9.2-7 CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT
‣ CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT( string, value )( function )

Returns: option value

Returns the value of the option with name string, or, if this value is fail, the object value.

9.2-8 CAP_INTERNAL_FIND_APPEARANCE_OF_SYMBOL_IN_FUNCTION
‣ CAP_INTERNAL_FIND_APPEARANCE_OF_SYMBOL_IN_FUNCTION( function, symbol_list, loop_multiple, replacement_record )( function )

Returns: a list of symbols with multiples

The function searches for the appearance of the strings in symbol list on the function function and returns a list of pairs, containing the name of the symbol and the number of appearance. If the symbol appears in a loop, the number of appearance is counted times the loop multiple. Moreover, if appearances of found strings should be replaced by collections of other strings, then these can be specified in the replacement record.

9.2-9 CAP_INTERNAL_MERGE_PRECONDITIONS_LIST
‣ CAP_INTERNAL_MERGE_PRECONDITIONS_LIST( list1, list2 )( function )

Returns: merge list

The function takes two lists containing pairs of symbols (strings) and multiples. The lists are merged that pairs where the string only appears in one list is then added to the return list, if a pair with a string appears in both lists, the resulting lists only contains this pair once, with the higher multiple from both lists.

9.2-10 CAP_INTERNAL_ASSERT_VALUE_IS_OF_TYPE_GETTER
‣ CAP_INTERNAL_ASSERT_VALUE_IS_OF_TYPE_GETTER( data_type, human_readable_identifier_list )( function )

Returns a unary function which throws an error if its argument is not of type data_type. human_readable_identifier_list is a list of arguments passed to Error to refer to the argument of the unary function in the error message.

9.2-11 CAP_INTERNAL_ASSERT_IS_CELL_OF_CATEGORY
‣ CAP_INTERNAL_ASSERT_IS_CELL_OF_CATEGORY( cell, category, human_readable_identifier_list )( function )

The function throws an error if cell is not a cell of category. If category is the boolean false, only general checks not specific to a concrete category are performed. human_readable_identifier_list is a list of arguments passed to Error to refer to cell in the error message.

9.2-12 CAP_INTERNAL_ASSERT_IS_OBJECT_OF_CATEGORY
‣ CAP_INTERNAL_ASSERT_IS_OBJECT_OF_CATEGORY( object, category, human_readable_identifier_list )( function )

The function throws an error if object is not an object of category. If category is the boolean false, only general checks not specific to a concrete category are performed. human_readable_identifier_list is a list of arguments passed to Error to refer to object in the error message.

9.2-13 CAP_INTERNAL_ASSERT_IS_MORPHISM_OF_CATEGORY
‣ CAP_INTERNAL_ASSERT_IS_MORPHISM_OF_CATEGORY( morphism, category, human_readable_identifier_list )( function )

The function throws an error if morphism is not a morphism of category. If category is the boolean false, only general checks not specific to a concrete category are performed. human_readable_identifier_list is a list of arguments passed to Error to refer to morphism in the error message.

9.2-14 CAP_INTERNAL_ASSERT_IS_TWO_CELL_OF_CATEGORY
‣ CAP_INTERNAL_ASSERT_IS_TWO_CELL_OF_CATEGORY( two_cell, category, human_readable_identifier_list )( function )

The function throws an error if two_cell is not a 2-cell of category. If category is the boolean false, only general checks not specific to a concrete category are performed. human_readable_identifier_list is a list of arguments passed to Error to refer to two_cell in the error message.

9.2-15 CachingStatistic
‣ CachingStatistic( category[, operation] )( function )

Prints statistics for all caches in category. If operation is given (as a string), only statistics for the given operation cache is stored.

9.2-16 BrowseCachingStatistic
‣ BrowseCachingStatistic( category )( function )

Displays statistics for all caches in category. in a Browse window. Here "status" indicates if the cache is weak, strong, or inactive, "hits" is the number of successful cache accesses, "misses" the number of unsuccessful cache accesses, and "stored" the number of objects currently stored in the cache.

9.2-17 InstallDeprecatedAlias
‣ InstallDeprecatedAlias( alias_name, function_name, deprecation_date )( function )

Makes the function given by function_name available under the alias alias_name with a deprecation warning including the date deprecation_date.

9.2-18 IsSpecializationOfFilter
‣ IsSpecializationOfFilter( filter1, filter2 )( function )

Checks if filter2 is more special than filter1, i.e. if filter2 implies filter1. filter1 and/or filter2 can also be one of the strings listed under filter_list in 7.3 and in this case are replaced by the corresponding filters (e.g. IsCapCategory, IsCapCategoryObject, IsCapCategoryMorphism, ...).

9.2-19 IsSpecializationOfFilterList
‣ IsSpecializationOfFilterList( filter_list1, filter_list2 )( function )

Checks if filter_list2 is more special than filter_list1, i.e. if both lists have the same length and any element of filter_list2 is more special than the corresponding element of filter_list1 in the sense of IsSpecializationOfFilter (9.2-18). filter_list1 and filter_list2 can also be the string "any", respresenting a most general filter list of any length.

9.2-20 InstallMethodForCompilerForCAP
‣ InstallMethodForCompilerForCAP( same, as, for, InstallMethod )( function )

Installs a method via InstallMethod and adds it to the list of methods known to the compiler. See CapJitAddKnownMethod (9.2-22) for requirements.

9.2-21 InstallOtherMethodForCompilerForCAP
‣ InstallOtherMethodForCompilerForCAP( same, as, for, InstallOtherMethod )( function )

Installs a method via InstallOtherMethod and adds it to the list of methods known to the compiler. See CapJitAddKnownMethod (9.2-22) for requirements.

9.2-22 CapJitAddKnownMethod
‣ CapJitAddKnownMethod( operation, filters, method )( function )

Adds a method to the list of methods known to the compiler. If the first filter implies IsCapCategory, method selection only takes the number of arguments and the first filter into account. This allows to resolve operations even in the case that the syntax tree cannot fully be typed. If the first filter does not imply IsCapCategory, method selection takes all filters into account. To strictly distinguish between the two cases, IsCapCategory must not imply the first filter (except if the first filter is equal to IsCapCategory). Method selection is strict in the sense that two different methods for the same operation must not be comparable. That is, they must have a different number of filters or the filters at at least one position must not be related via implication. In particular, adding two methods with a CAP category as first argument (or a convenience method for a CAP operation) with the same number of arguments and one category filter implying the other is not supported.

9.2-23 CapJitAddTypeSignature
‣ CapJitAddTypeSignature( name, input_filters, output_data_type )( function )

(experimental) Adds a type signature for the global function or operation given by name to the compiler. input_filters must be a list of filters, or the string '"any"' representing a most general filter list of any length. output_data_type must be a filter, a data type, or a function. If it is a function with one argument, it must accept a list of input types and return the corresponding data type of the output. If it is a function with two arguments, it must accept the arguments of a function call of name (as syntax trees) and the function stack and return a record with components args (the possibly modified arguments) and output_type (the data type of the output). See CapJitInferredDataTypes (CompilerForCAP: CapJitInferredDataTypes) for more details on data types.

9.2-24 CapJitAddTypeSignatureDeferred
‣ CapJitAddTypeSignatureDeferred( package_name, name, input_filters, output_data_type )( function )

(experimental) Same as CapJitAddTypeSignature (9.2-23), but the filters and the output data type must be given as strings which will be evaluated once package_name is loaded. This should be used with care because errors will only be detected at runtime.

9.2-25 CapJitDataTypeOfListOf
‣ CapJitDataTypeOfListOf( element_type )( function )

(experimental) Returns the data type of a list whose elements are of type element_type. element_type must be a filter or a data type.

9.2-26 CapJitDataTypeOfNTupleOf
‣ CapJitDataTypeOfNTupleOf( n, element_types... )( function )

(experimental) Returns the data type of an n-tuple whose entries are of types corresponding to element_types. element_types... must be filters or data types.

9.2-27 CapJitDataTypeOfCategory
‣ CapJitDataTypeOfCategory( category )( function )
‣ CapJitDataTypeOfObjectOfCategory( category )( function )
‣ CapJitDataTypeOfMorphismOfCategory( category )( function )
‣ CapJitDataTypeOfTwoCellOfCategory( category )( function )

(experimental) Returns the data type of the category (or objects, morphisms, or two cells in the category) category.

9.2-28 CapJitTypedExpression
‣ CapJitTypedExpression( value, data_type_getter )( function )

(experimental) Simply returns value, but allows to specify the data type of value for CompilerForCAP. data_type_getter must be a literal function or a global variable pointing to a function. The function must accept no arguments or a single argument, and return a valid data type. If the function accepts a single argument, it must be inside a CAP operation or method known to CompilerForCAP (for example, see InstallMethodForCompilerForCAP (9.2-20)), and the current category (i.e. the first argument of the CAP operation or method known to CompilerForCAP) will be passed to the function. IMPORTANT: If data_type_getter is a literal function, it must not contain references to variables in its context. Otherwise the code might access random memory locations. See CapJitInferredDataTypes (CompilerForCAP: CapJitInferredDataTypes) for more details on data types.

9.2-29 CapFixpoint
‣ CapFixpoint( predicate, func, initial_value )( function )

Computes a fixpoint of func with regard to equality given by predicate, starting with initial_value. If no such fixpoint exists, the execution does not terminate.

9.2-30 Iterated
‣ Iterated( list, func, initial_value )( operation )

Shorthand for Iterated( Concatenation( [ initial_value ], list ), func ).

9.2-31 Iterated
‣ Iterated( list, func, initial_value, terminal_value )( operation )

Shorthand for Iterated( Concatenation( [ initial_value ], list, [ terminal_value ] ), func ).

9.2-32 TransitivelyNeededOtherPackages
‣ TransitivelyNeededOtherPackages( package_name )( function )

Returns a list of package names which are transitively needed other packages of the package package_name.

9.2-33 PackageOfCAPOperation
‣ PackageOfCAPOperation( operation_name )( function )

Returns the name of the package to which the CAP operation given by operation_name belongs or fail if the package is not known.

9.2-34 SafePosition
‣ SafePosition( list, obj )( operation )

Returns: an integer

Returns Position( list, obj ) while asserting that this value is not fail.

9.2-35 SafeUniquePosition
‣ SafeUniquePosition( list, obj )( operation )

Returns: an integer

Returns Position( list, obj ) while asserting that this value is not fail and the position is unique.

9.2-36 SafePositionProperty
‣ SafePositionProperty( list, func )( operation )

Returns: an integer

Returns PositionProperty( list, func ) while asserting that this value is not fail.

9.2-37 SafeUniquePositionProperty
‣ SafeUniquePositionProperty( list, func )( operation )

Returns: an integer

Returns a position in list for which func returns true when applied to the corresponding entry while asserting that there exists exactly one such position.

9.2-38 SafeFirst
‣ SafeFirst( list, func )( operation )

Returns: an element of the list

Returns First( list, func ) while asserting that this value is not fail.

9.2-39 SafeUniqueEntry
‣ SafeUniqueEntry( list, func )( operation )

Returns: an element of the list

Returns a value in list for which func returns true while asserting that there exists exactly one such entry.

9.2-40 NTuple
‣ NTuple( n, args... )( function )

Returns: a list

Returns args while asserting that its length is n.

9.2-41 Pair
‣ Pair( first, second )( function )

Returns: a list

Alias for NTuple( 2, first, second ).

9.2-42 Triple
‣ Triple( first, second, third )( function )

Returns: a list

Alias for NTuple( 3, first, second, third ).

9.2-43 TransposedMatWithGivenDimensions
‣ TransposedMatWithGivenDimensions( nr_rows, nr_cols, listlist )( function )

Returns: a list (of lists)

The arguments are two integers nr_rows, nr_cols and a list of lists listlist such that nr_rows = Length(listlist) and nr_cols = Length(listlist[i]) for i=1 to nr_rows. The output is the transpose of listlist as a list consisting of nr_cols rows and nr_rows columns.

9.2-44 HandlePrecompiledTowers
‣ HandlePrecompiledTowers( category, underlying_category, constructor_name )( function )

Handles the information stored in underlying_category!.compiler_hints.precompiled_towers (if bound) which is a list of records with components:

If constructor_name is the only entry of remaining_constructors_in_tower, precompiled_functions_adder is applied to category (except if the option no_precompiled_code is set to true) and should add precompiled code. Else, if constructor_name is the first entry of remaining_constructors_in_tower, the information is attached to category!.compiler_hints.precompiled_towers after removing constructor_name from remaining_constructors_in_tower. Note: Currently, there is no logic for finding the "optimal" code to install if constructor_name is the only entry of remaining_constructors_in_tower of multiple entries.

9.2-45 CAP_JIT_INCOMPLETE_LOGIC
‣ CAP_JIT_INCOMPLETE_LOGIC( value )( function )

Simply returns value. Used to signify that the argument is not fully run through all logic functions/templates by CompilerForCAP.

9.2-46 CAP_JIT_EXPR_CASE_WRAPPER
‣ CAP_JIT_EXPR_CASE_WRAPPER( func )( function )

Simply returns func, which must be a literal function without arguments only containing an if-elif-else statement with each branch consisting of a single return statement. Used to write expressions of the form function() if-elif-else end() as CAP_JIT_EXPR_CASE_WRAPPER(function() if-elif-else end)() because the former is not valid in Julia.

9.2-47 ListWithKeys
‣ ListWithKeys( list, func )( function )

Returns: a list

Same as List( list, func ) but func gets both the key i and list[i] as arguments.

9.2-48 SumWithKeys
‣ SumWithKeys( list, func )( function )

Returns: a list

Same as Sum( list, func ) but func gets both the key i and list[i] as arguments.

9.2-49 ProductWithKeys
‣ ProductWithKeys( list, func )( function )

Returns: a list

Same as Product( list, func ) but func gets both the key i and list[i] as arguments.

9.2-50 ForAllWithKeys
‣ ForAllWithKeys( list, func )( function )

Returns: a list

Same as ForAll( list, func ) but func gets both the key i and list[i] as arguments.

9.2-51 ForAnyWithKeys
‣ ForAnyWithKeys( list, func )( function )

Returns: a list

Same as ForAny( list, func ) but func gets both the key i and list[i] as arguments.

9.2-52 NumberWithKeys
‣ NumberWithKeys( list, func )( function )

Returns: a list

Same as Number( list, func ) but func gets both the key i and list[i] as arguments.

9.2-53 FilteredWithKeys
‣ FilteredWithKeys( list, func )( function )

Returns: a list

Same as Filtered( list, func ) but func gets both the key i and list[i] as arguments.

9.2-54 FirstWithKeys
‣ FirstWithKeys( list, func )( function )

Returns: a list

Same as First( list, func ) but func gets both the key i and list[i] as arguments.

9.2-55 LastWithKeys
‣ LastWithKeys( list, func )( function )

Returns: a list

Same as Last( list, func ) but func gets both the key i and list[i] as arguments.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Ind

generated by GAPDoc2HTML