问题描述
Rex Kerr 发布了有关在 Scala 中使用 GMP 的信息,特别是运行 pidigits 程序.libjpargmp.so 是使用 GmpUtil.c 生成的
Rex Kerr has posted info about using GMP with scala, in particular to run the pidigits program. libjpargmp.so is generated using GmpUtil.c
我的问题是:在哪里可以找到 GMPUtil.c?我的谷歌搜索没有任何结果.
My question is: where do I find GMPUtil.c? My google searches haven't turned up anything.
问候,道格
推荐答案
在 Alioth 计算机语言基准游戏论坛上发帖比在此处发帖更有可能产生答案.但是,在这种情况下,您已经很幸运了(尽管我不知道这是否是 StackOverflow 的正确用法).
Posting on the Alioth computer languages benchmark game forum would more likely yield an answer than posting here. However, in this case you've gotten lucky (though I don't know if this is exactly an appropriate use of 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) );
}
这篇关于scala 使用 GMPUtil 处理pidigits的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!