scala使用GMPUtil作为pidigits

时间:2010-12-09 23:12:22

标签: scala gmp

Rex Kerr发布了有关在scala中使用GMP的信息,特别是运行pidigits程序。 libjpargmp.so是使用GmpUtil.c

生成的

我的问题是:我在哪里可以找到GMPUtil.c?我的谷歌搜索没有发现任何东西。

此致 道格

1 个答案:

答案 0 :(得分:2)

在Alioth计算机语言基准游戏论坛上发布比在这里发布更有可能产生答案。但是,在这种情况下你很幸运(虽然我不知道这是否恰恰适用于StackOverflow)。

GmpUtil.h:

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class GmpUtil */

#ifndef _Included_GmpUtil
#define _Included_GmpUtil
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     GmpUtil
 * Method:    mpz_init
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init
  (JNIEnv *, jclass);

/*
 * Class:     GmpUtil
 * Method:    mpz_clear
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear
  (JNIEnv *, jclass, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_set_si
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si
  (JNIEnv *, jclass, jlong, jint);

/*
 * Class:     GmpUtil
 * Method:    mpz_get_si
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si
  (JNIEnv *, jclass, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_cmp
 * Signature: (JJ)I
 */
JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp
  (JNIEnv *, jclass, jlong, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_add
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add
  (JNIEnv *, jclass, jlong, jlong, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_sub
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub
  (JNIEnv *, jclass, jlong, jlong, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_mul_si
 * Signature: (JJI)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si
  (JNIEnv *, jclass, jlong, jlong, jint);

/*
 * Class:     GmpUtil
 * Method:    mpz_divexact
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact
  (JNIEnv *, jclass, jlong, jlong, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_tdiv_qr
 * Signature: (JJJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr
  (JNIEnv *, jclass, jlong, jlong, jlong, jlong);

/*
 * Class:     GmpUtil
 * Method:    mpz_gcd
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd
  (JNIEnv *, jclass, jlong, jlong, jlong);

#ifdef __cplusplus
}
#endif
#endif

GmpUtil.c:

#include "GmpUtil.h"
#include "gmp.h"

/*
 * Class:     GmpUtil
 * Method:    mpz_init
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_GmpUtil_mpz_1init
  (JNIEnv *x, jclass y)
{
  mpz_t *p = malloc( sizeof(__mpz_struct) );
  __gmpz_init( *p );

  return (jlong)p;
}

/*
 * Class:     GmpUtil
 * Method:    mpz_clear
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1clear
  (JNIEnv *x, jclass y, jlong o)
{
  mpz_t* p = (mpz_t*)o;
  __gmpz_clear( *p );
  free( p );
}

/*
 * Class:     GmpUtil
 * Method:    mpz_set_si
 * Signature: (JI)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1set_1si
  (JNIEnv *x, jclass y, jlong dest, jint val)
{
  __gmpz_set_si( *((mpz_t*)dest), (long) val);
}

/*
 * Class:     GmpUtil
 * Method:    mpz_get_si
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1get_1si
  (JNIEnv *x, jclass y, jlong dest)
{
  return (jint)__gmpz_get_si( *((mpz_t*)dest));
}

/*
 * Class:     GmpUtil
 * Method:    mpz_cmp
 * Signature: (JJ)I
 */
JNIEXPORT jint JNICALL Java_GmpUtil_mpz_1cmp
  (JNIEnv *x, jclass y, jlong op1, jlong op2)
{
  return (jint) __gmpz_cmp( *((mpz_t*)op1), *((mpz_t*)op2) );
}

/*
 * Class:     GmpUtil
 * Method:    mpz_add
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1add
  (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val)
{
  __gmpz_add( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) );
}

/*
 * Class:     GmpUtil
 * Method:    mpz_sub
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1sub
  (JNIEnv *x, jclass y, jlong dest, jlong src, jlong val)
{
  __gmpz_sub( *((mpz_t*)dest), *((mpz_t*)src), *((mpz_t*)val) );
}

/*
 * Class:     GmpUtil
 * Method:    mpz_mul_si
 * Signature: (JJI)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1mul_1si
  (JNIEnv *x, jclass y, jlong dest, jlong src, jint val)
{
  __gmpz_mul_si( *((mpz_t*)dest), *((mpz_t*)src), (long) val);
}

/*
 * Class:     GmpUtil
 * Method:    mpz_divexact
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1divexact
  (JNIEnv *x, jclass y, jlong quot, jlong n, jlong d)
{
  __gmpz_divexact( *((mpz_t*)quot), *((mpz_t*)n), *((mpz_t*)d));
}

/*
 * Class:     GmpUtil
 * Method:    mpz_tdiv_qr
 * Signature: (JJJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1tdiv_1qr
  (JNIEnv *x, jclass y, jlong q, jlong r, jlong n, jlong d)
{
  __gmpz_tdiv_qr( *((mpz_t*)q), *((mpz_t*)r), *((mpz_t*)n), *((mpz_t*)d) );
}

/*
 * Class:     GmpUtil
 * Method:    mpz_gcd
 * Signature: (JJJ)V
 */
JNIEXPORT void JNICALL Java_GmpUtil_mpz_1gcd
  (JNIEnv *x, jclass y, jlong r, jlong a, jlong b)
{
  __gmpz_gcd( *((mpz_t*)r), *((mpz_t*)a), *((mpz_t*)b) );
}