Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563636 views
1
/*Written by Paul Smith*/
2
3
#include "src/compiled.h" /* the GAP headers */
4
#include <stdlib.h> /* for abs */
5
6
7
/***************** The new GAP kernel functions ***************/
8
9
/**
10
GAP kernel C function to calculate ane return the absolute value of an integer.
11
This is assumed to be a GAP small integer (i.e. less than 2^28-1 or 2^60-1
12
depending on whether the machine is 32- or 64-bit).
13
@param self The standard GAP first parameter
14
@param n The standard GAP first parameter
15
@return The maximum small integer (according to this kernel module).
16
**/
17
Obj FuncABSINT_HAP(Obj self, Obj n)
18
{
19
Int Cn;
20
Cn = INT_INTOBJ(n); /* Convert the GAP object n into a C integer */
21
Cn = abs(Cn); /* Get the absolute value of this integer */
22
return INTOBJ_INT(Cn); /* Convert it back to a GAP object and return it */
23
}
24
25
26
/******************** The interface to GAP ***************/
27
28
/**
29
Details of the functions to make available to GAP.
30
This is used in InitKernel() and InitLibrary()
31
*/
32
static StructGVarFunc GVarFuncs[] =
33
{
34
{"AbsInt_HAP", /* The function name in GAP */
35
1, /* The number of parameters */
36
"n", /* The names of the parameters */
37
FuncABSINT_HAP, /* The C function to call */
38
"absint.c:FuncABSINT_HAP" /* A user-friendly description of where
39
this function is */
40
},
41
42
{ 0 } /* Finish with an empty entry */
43
};
44
45
46
47
/**
48
The first function to be called when the library is loaded by the kernel.
49
**/
50
static Int InitKernel(StructInitInfo* module)
51
{
52
/* init filters and functions */
53
InitHdlrFuncsFromTable( GVarFuncs );
54
55
/* return success */
56
return 0;
57
}
58
59
60
/**
61
The second function to be called when the library is loaded by the kernel.
62
**/
63
static Int InitLibrary(StructInitInfo* module)
64
{
65
/* init filters and functions */
66
InitGVarFuncsFromTable( GVarFuncs );
67
68
/* return success */
69
return 0;
70
}
71
72
73
/**
74
Information about this library, returned when the library is loaded,
75
for example by Init__Dynamic(). This contains details of the library name,
76
and the further initialisation functions to call.
77
**/
78
static StructInitInfo module = {
79
#ifdef STATICMODULE
80
/* type = */ MODULE_STATIC,
81
#else
82
/* type = */ MODULE_DYNAMIC,
83
#endif
84
/* name = */ "absolute value of an integer",
85
/* revision_c = */ 0,
86
/* revision_h = */ 0,
87
/* version = */ 0,
88
/* crc = */ 0,
89
/* initKernel = */ InitKernel,
90
/* initLibrary = */ InitLibrary,
91
/* checkInit = */ 0,
92
/* preSave = */ 0,
93
/* postSave = */ 0,
94
/* postRestore = */ 0
95
};
96
97
98
#ifndef STATICGAP
99
/**
100
Function called by GAP as soon as the library is dynamically loaded.
101
This returns the StructInitInfo data for this library
102
**/
103
StructInitInfo * Init__Dynamic (void)
104
{
105
return &module;
106
}
107
#endif
108
StructInitInfo * Init__linbox(void)
109
{
110
return &module;
111
}
112
113
114