/**************************************************************************** ** ** This file is part of GAP, a system for computational discrete algebra. ** ** Copyright of GAP belongs to its developers, whose names are too numerous ** to list here. Please refer to the COPYRIGHT file for details. ** ** SPDX-License-Identifier: GPL-2.0-or-later
*/
// LibGAP API - API for using GAP as shared library.
//// //// Garbage collector interface //// void GAP_MarkBag(Obj obj)
{ // For now pass a dummy 'ref' value to MarkBag. That's fine // when using GASMAN or Boehm GC. It won't work with Julia GC // but that's fine as GAP.jl doesn't need it.
MarkBag(obj, 0);
}
// call the function switch (narg) { case 0:
result = CALL_0ARGS(func); break; case 1:
result = CALL_1ARGS(func, args[0]); break; case 2:
result = CALL_2ARGS(func, args[0], args[1]); break; case 3:
result = CALL_3ARGS(func, args[0], args[1], args[2]); break; case 4:
result = CALL_4ARGS(func, args[0], args[1], args[2], args[3]); break; case 5:
result =
CALL_5ARGS(func, args[0], args[1], args[2], args[3], args[4]); break; case 6:
result = CALL_6ARGS(func, args[0], args[1], args[2], args[3],
args[4], args[5]); break; default:
list = NewPlistFromArray(args, narg);
result = CALL_XARGS(func, list);
}
} else {
list = NewPlistFromArray(args, narg);
result = DoOperation2Args(CallFuncListOper, func, list);
}
return result;
}
Obj GAP_CallFunc0Args(Obj func)
{
Obj result;
if (TNUM_OBJ(func) == T_FUNCTION) {
result = CALL_0ARGS(func);
} else {
Obj list = NewEmptyPlist();
result = DoOperation2Args(CallFuncListOper, func, list);
}
staticBOOL fitsInIntObj(Int i)
{ return INT_INTOBJ_MIN <= i && i <= INT_INTOBJ_MAX;
}
Obj GAP_NewRange(Int len, Int low, Int inc)
{ if (!inc) return GAP_Fail; if (!fitsInIntObj(len)) return GAP_Fail; if (!fitsInIntObj(low)) return GAP_Fail; if (!fitsInIntObj(inc)) return GAP_Fail; Int high = low + (len - 1) * inc; if (!fitsInIntObj(high)) return GAP_Fail; return NEW_RANGE(len, low, inc);
}
// Returns 1 if <obj> is a GAP matrix or matrix obj, 0 if not. int GAP_IsMatrixOrMatrixObj(Obj obj)
{ return obj && CALL_1ARGS(IsMatrixOrMatrixObjFilt, obj) == True;
}
// Returns 1 if <obj> is a GAP matrix, 0 if not. int GAP_IsMatrix(Obj obj)
{ return obj && CALL_1ARGS(IsMatrixFilt, obj) == True;
}
// Returns 1 if <obj> is a GAP matrix obj, 0 if not. int GAP_IsMatrixObj(Obj obj)
{ return obj && CALL_1ARGS(IsMatrixObjFilt, obj) == True;
}
// Returns the number of rows of the given GAP matrix obj. // If <mat> is not a GAP matrix obj, an error may be raised.
UInt GAP_NrRows(Obj mat)
{
Obj nrows = CALL_1ARGS(NrRowsAttr, mat); return UInt_ObjInt(nrows);
}
// Returns the number of columns of the given GAP matrix or matrix obj. // If <mat> is not a GAP matrix or matrix obj, an error may be raised.
UInt GAP_NrCols(Obj mat)
{
Obj ncols = CALL_1ARGS(NrColsAttr, mat); return UInt_ObjInt(ncols);
}
// Assign <val> at the <row>, <col> into the GAP matrix or matrix obj <mat>. // If <val> is zero, then this unbinds the list entry. // If <mat> is not a GAP matrix or matrix obj, an error may be raised. void GAP_AssMat(Obj mat, UInt row, UInt col, Obj val)
{
Obj r = ObjInt_UInt(row);
Obj c = ObjInt_UInt(col);
ASS_MAT(mat, r, c, val);
}
// Returns the element at the <row>, <col> in the GAP matrix obj <mat>. // Returns 0 if <row> or <col> are out of bounds, i.e., if either // is zero, or larger than the number of rows respectively columns of <mat>. // If <mat> is not a GAP matrix or matrix obj, an error may be raised.
Obj GAP_ElmMat(Obj mat, UInt row, UInt col)
{
Obj r = ObjInt_UInt(row);
Obj c = ObjInt_UInt(col); return ELM_MAT(mat, r, c);
}
//// //// records ////
int GAP_IsRecord(Obj obj)
{ return obj && IS_REC(obj);
}
int GAP_Error_Prejmp_(constchar * file, int line)
{
GAP_ENTER_DEBUG_MESSAGE("Error_Prejmp", file, line); if (EnterStackCount > 0) { return 1;
}
RecursionDepth = GetRecursionDepth(); return 0;
}
/* Helper function for GAP_Error_Postjmp_ (see libgap-api.h) which manipulates * EnterStackCount in the (generally unlikely) case of returning from a * longjmp
*/ void GAP_Error_Postjmp_Returning_(void)
{ /* This only should have been called from the outer-most * GAP_EnterStack() call so make sure it resets the EnterStackCount; * We set EnterStackCount to its negative which indicates to * GAP_EnterStack that we just returned from a long jump and should * reset EnterStackCount to its value at the return point rather than
* increment it again */ if (EnterStackCount > 0) {
EnterStackCount = -EnterStackCount;
}
SetRecursionDepth(RecursionDepth);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.