Skip to content

Commit

Permalink
kernel: Semigroups can be used in GAP on julia
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Aug 30, 2024
1 parent 323f949 commit 3fa9f22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gapbind14/include/gapbind14/gapbind14.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,13 @@ namespace gapbind14 {
(Int) detail::to_string(o).c_str());
}

#ifdef GAP_ENABLE_SAVELOAD
void save(Obj o) {
SaveUInt(detail::obj_subtype(o));
}

void load(Obj o) const;
#endif

void free(Obj o) const {
_subtypes.at(detail::obj_subtype(o))->free(o);
Expand Down
12 changes: 9 additions & 3 deletions gapbind14/src/gapbind14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "gapbind14/gap_include.hpp" // for Obj etc

#define GVAR_ENTRY(srcfile, name, nparam, params) \
{ #name, nparam, params, (GVarFunc) name, srcfile ":Func" #name }
{#name, nparam, params, (GVarFunc) name, srcfile ":Func" #name}

namespace gapbind14 {
UInt T_GAPBIND14_OBJ = 0;
Expand Down Expand Up @@ -129,11 +129,13 @@ namespace gapbind14 {
}
return it->second;
}
#ifdef GAP_ENABLE_SAVELOAD
void Module::load(Obj o) const {
gapbind14_subtype sbtyp = LoadUInt();
ADDR_OBJ(o)[0] = reinterpret_cast<Obj>(sbtyp);
ADDR_OBJ(o)[1] = static_cast<Obj>(nullptr);
}
#endif

void Module::finalize() {
for (auto &x : _mem_funcs) {
Expand All @@ -158,13 +160,15 @@ namespace gapbind14 {
module().print(o);
}

#ifdef GAP_ENABLE_SAVELOAD
void TGapBind14ObjSaveFunc(Obj o) {
module().save(o);
}

void TGapBind14ObjLoadFunc(Obj o) {
module().load(o);
}
#endif

Obj TGapBind14ObjCopyFunc(Obj o, Int mut) {
return o;
Expand Down Expand Up @@ -254,8 +258,10 @@ namespace gapbind14 {
PKG_TNUM = RegisterPackageTNUM("TGapBind14", TGapBind14ObjTypeFunc);

PrintObjFuncs[PKG_TNUM] = TGapBind14ObjPrintFunc;
SaveObjFuncs[PKG_TNUM] = TGapBind14ObjSaveFunc;
LoadObjFuncs[PKG_TNUM] = TGapBind14ObjLoadFunc;
#ifdef GAP_ENABLE_SAVELOAD
SaveObjFuncs[PKG_TNUM] = TGapBind14ObjSaveFunc;
LoadObjFuncs[PKG_TNUM] = TGapBind14ObjLoadFunc;
#endif

CopyObjFuncs[PKG_TNUM] = &TGapBind14ObjCopyFunc;
CleanObjFuncs[PKG_TNUM] = &TGapBind14ObjCleanFunc;
Expand Down
8 changes: 8 additions & 0 deletions src/pkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ Obj TBlocksObjTypeFunc(Obj o) {
return TheTypeTBlocksObj;
}

#ifdef GAP_ENABLE_SAVELOAD

void TBipartObjSaveFunc(Obj o) {
Bipartition* b = bipart_get_cpp(o);
SaveUInt4(b->degree());
Expand Down Expand Up @@ -332,6 +334,8 @@ void TBlocksObjLoadFunc(Obj o) {
ADDR_OBJ(o)[0] = reinterpret_cast<Obj>(blocks);
}

#endif

// Filters for IS_BIPART, IS_BLOCKS

Obj IsBipartFilt;
Expand Down Expand Up @@ -500,8 +504,10 @@ static Int InitKernel(StructInitInfo* module) {
CleanObjFuncs[T_BIPART] = &TBipartObjCleanFunc;
IsMutableObjFuncs[T_BIPART] = &AlwaysNo;

#ifdef GAP_ENABLE_SAVELOAD
SaveObjFuncs[T_BIPART] = TBipartObjSaveFunc;
LoadObjFuncs[T_BIPART] = TBipartObjLoadFunc;
#endif

InitMarkFuncBags(T_BIPART, &MarkAllButFirstSubBags);
InitFreeFuncBag(T_BIPART, &TBipartObjFreeFunc);
Expand All @@ -520,8 +526,10 @@ static Int InitKernel(StructInitInfo* module) {
CleanObjFuncs[T_BLOCKS] = &TBlocksObjCleanFunc;
IsMutableObjFuncs[T_BLOCKS] = &AlwaysNo;

#ifdef GAP_ENABLE_SAVELOAD
SaveObjFuncs[T_BLOCKS] = TBlocksObjSaveFunc;
LoadObjFuncs[T_BLOCKS] = TBlocksObjLoadFunc;
#endif

InitMarkFuncBags(T_BLOCKS, &MarkNoSubBags);
InitFreeFuncBag(T_BLOCKS, &TBlocksObjFreeFunc);
Expand Down

0 comments on commit 3fa9f22

Please sign in to comment.