Skip to content

Commit

Permalink
HACK: add JACOBI_INT
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jan 13, 2017
1 parent 19020f9 commit b45f1b8
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/gmpints.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static Obj ObjInt_UIntInv( UInt i );

/* debugging */
#ifndef DEBUG_GMP
#define DEBUG_GMP 0
#define DEBUG_GMP 1
#endif

#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
Expand Down Expand Up @@ -2005,6 +2005,51 @@ Obj FuncGCD_INT ( Obj self, Obj opL, Obj opR )
}


/****************************************************************************
**
*/
Obj JacobiInt ( Obj opL, Obj opR )
{
fake_mpz_t mpzL, mpzR;
int result;

CHECK_INT(opL);
CHECK_INT(opR);

FAKEMPZ_GMPorINTOBJ( mpzL, opL );
FAKEMPZ_GMPorINTOBJ( mpzR, opR );

result = mpz_kronecker( MPZ_FAKEMPZ(mpzL), MPZ_FAKEMPZ(mpzR) );

return INTOBJ_INT( result );
}

/****************************************************************************
**
*/
Obj FuncJACOBI_INT ( Obj self, Obj opL, Obj opR )
{
/* check the arguments */
while ( TNUM_OBJ(opL) != T_INT
&& TNUM_OBJ(opL) != T_INTPOS
&& TNUM_OBJ(opL) != T_INTNEG ) {
opL = ErrorReturnObj(
"JacobiInt: <left> must be an integer (not a %s)",
(Int)TNAM_OBJ(opL), 0L,
"you can replace <left> via 'return <left>;'" );
}
while ( TNUM_OBJ(opR) != T_INT
&& TNUM_OBJ(opR) != T_INTPOS
&& TNUM_OBJ(opR) != T_INTNEG ) {
opR = ErrorReturnObj(
"JacobiInt: <right> must be an integer (not a %s)",
(Int)TNAM_OBJ(opR), 0L,
"you can replace <right> via 'return <right>;'" );
}

/* return the gcd */
return JacobiInt( opL, opR );
}

/****************************************************************************
**
Expand Down Expand Up @@ -2149,6 +2194,9 @@ static StructGVarFunc GVarFuncs [] = {
{ "POW_OBJ_INT", 2, "obj, gmp",
FuncPOW_OBJ_INT, "src/gmpints.c:POW_OBJ_INT" },

{ "JACOBI_INT", 2, "gmp1, gmp2",
FuncJACOBI_INT, "src/gmpints.c:JACOBI_INT" },

{ "HexStringInt", 1, "gmp",
FuncHexStringInt, "src/gmpints.c:HexStringInt" },

Expand Down

0 comments on commit b45f1b8

Please sign in to comment.