◆nakoGMP

情報

作者名:1.0e+21
引用元:mpirライブラリをなでしこ用に改変


概要

mpirと言う、Windows用に移植されたC言語用GMPライブラリを使用して、なでしこで多倍長整数(巨大な整数)の計算をできるようにします。
なでしこ用プラグインをインストールするので、なでしこ標準の関数と同じように使用できます。
関数名はほとんどGMPのMPZ(整数)で使用できるものがほとんどなので、以下のサイトなどを参考にすると、だいたい使えると思います。
https://gmplib.org/manual/Integer-Functions.html



サンプルプログラム

「nakoGMP ver:{NAKOGMP_DLLバージョン}、mpir ver:{Get_mpir_version}」と表示

A=mpz_init //多倍長整数を使用するためのキーが作成される。
「Aのキー:{A}」を表示

B=mpz_init
「Bのキー:{B}」を表示

C=mpz_init
「Cのキー:{C}」を表示

mpz_set_str(A、『123456789012345678901234567890123456789』、10)
mpz_set_str(B、『987654321098765432109876543210987654321』、10)


「A={mpz_get_str(A,10)}」を表示
「B={mpz_get_str(B,10)}」を表示


mpz_add(C,A,B)
「A+B={mpz_get_str(C,10)}」を表示

mpz_mul(C,B,A)
「A*B={mpz_get_str(C,10)}」を表示


mpz_clear(A)
mpz_clear(B)
mpz_clear(C)
 //mpz_add(C,A,B)
 //↑のコメントを外すと、不正なキーを使用するので、エラーが発生する。

本体

https://www.dropbox.com/s/o9njvw9jd48zu1a/nakoGMP.dll
よりダウンロードして、なでしこのプラグインフォルダにコピー
又は、このページに添付されているdllをダウンロードして、なでしこのプラグインフォルダにコピー


使用可能な関数


~初期化用。GMPと引数が少ないので注意。キーが返される。
mpz_init
mpz_init_set_str(str,base)
mpz_init_set_si(rop)


~ropのbase進法での文字列が返される。GMPと引数が少ないので注意。
mpz_get_str(rop,base)


~細々としたもの?
mpz_set_str(rop,str,base)
mpz_set_si(rop,op)
mpz_clear(x)
mpz_size(op)



~以下自動育成
mpz_add(rop,op1,op2);
mpz_add_ui(rop,op1,op2);
mpz_sub(rop,op1,op2);
mpz_sub_ui(rop,op1,op2);
mpz_ui_sub(rop,op1,op2);
mpz_mul(rop,op1,op2);
mpz_mul_si(rop,op1,op2);
mpz_mul_ui(rop,op1,op2);
mpz_addmul(rop,op1,op2);
mpz_addmul_ui(rop,op1,op2);
mpz_submul(rop,op1,op2);
mpz_submul_ui(rop,op1,op2);
mpz_mul_2exp(rop,op1,op2);
mpz_neg(rop,op);
mpz_abs(rop,op);


mpz_cdiv_q(q,n,d);
mpz_cdiv_r(r,n,d);
mpz_cdiv_qr(q,r,n,d);
mpz_cdiv_q_ui(q,n,d);
mpz_cdiv_r_ui(r,n,d);
mpz_cdiv_qr_ui(q,r,n,d);
mpz_cdiv_ui(n,d);
mpz_cdiv_q_2exp(q,n,b);
mpz_cdiv_r_2exp(r,n,b);
mpz_fdiv_q(q,n,d);
mpz_fdiv_r(r,n,d);
mpz_fdiv_qr(q,r,n,d);
mpz_fdiv_q_ui(q,n,d);
mpz_fdiv_r_ui(r,n,d);
mpz_fdiv_qr_ui(q,r,n,d);
mpz_fdiv_ui(n,d);
mpz_fdiv_q_2exp(q,n,b);
mpz_fdiv_r_2exp(r,n,b);
mpz_tdiv_q(q,n,d);
mpz_tdiv_r(r,n,d);
mpz_tdiv_qr(q,r,n,d);
mpz_tdiv_q_ui(q,n,d);
mpz_tdiv_r_ui(r,n,d);
mpz_tdiv_qr_ui(q,r,n,d);
mpz_tdiv_ui(n,d);
mpz_tdiv_q_2exp(q,n,b);
mpz_tdiv_r_2exp(r,n,b);
mpz_mod(r,n,d);
mpz_mod_ui(r,n,d);
mpz_divexact(q,n,d);
mpz_divexact_ui(q,n,d);
mpz_divisible_p(n,d);
mpz_divisible_ui_p(n,d);
mpz_divisible_2exp_p(n,b);
mpz_congruent_p(n,c,d);
mpz_congruent_ui_p(n,c,d);
mpz_congruent_2exp_p(n,c,b);

mpz_powm(rop,base,exp,mod);
mpz_powm_ui(rop,base,exp,mod);
mpz_powm_sec(rop,base,exp,mod);
mpz_pow_ui(rop,base,exp);
mpz_ui_pow_ui(rop,base,exp);

mpz_root(rop,op,n);
mpz_rootrem(root,rem,u,n);
mpz_sqrt(rop,op);
mpz_sqrtrem(rop1,rop2,op);
mpz_perfect_power_p(op);
mpz_perfect_square_p(op);

mpz_probab_prime_p(n,reps);
mpz_nextprime(rop,op);
mpz_gcd(rop,op1,op2);
mpz_gcd_ui(rop,op1,op2);
mpz_gcdext(g,s,t,a,b);
mpz_lcm(rop,op1,op2);
mpz_lcm_ui(rop,op1,op2);
mpz_invert(rop,op1,op2);
mpz_jacobi(a,b);
mpz_legendre(a,p);
mpz_kronecker(a,b);
mpz_kronecker_si(a,b);
mpz_kronecker_ui(a,b);
mpz_si_kronecker(a,b);
mpz_ui_kronecker(a,b);
mpz_remove(rop,op,f);
mpz_fac_ui(rop,n);
mpz_2fac_ui(rop,n);
mpz_mfac_uiui(rop,n,m);
mpz_primorial_ui(rop,n);
mpz_bin_ui(rop,n,k);
mpz_bin_uiui(rop,n,k);
mpz_fib_ui(fn,n);
mpz_fib2_ui(fn,fnsub1,n);
mpz_lucnum_ui(ln,n);
mpz_lucnum2_ui(ln,lnsub1,n);


~デバッグ用
Get_mpir_version
NAKOGMP_DLLバージョン
Get_MPZs_next
Get_MPZs_size
Get_MPZs_capacity
GetZNum※
GetNumZ※

※印は、設定間違えて、使用不可能です。










ライセンスとか

僕はmpirを移植して、なでしこで使用可能にしただけなので、mpir(gmp)のライセンスを守ってください。

Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
Contributed by the AriC and Caramel projects, INRIA.

This file is part of the GNU MPFR Library.

The GNU MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

The GNU MPFR Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

##############################################################################

The GNU MPFR distribution contains the following files:
(This does not apply to code retrieved by Subversion.)

AUTHORS - the authors of the library
BUGS - bugs in MPFR - please read this file!
COPYING - the GNU General Public License, version 3
COPYING.LESSER - the GNU Lesser General Public License, version 3
ChangeLog - the log of changes
INSTALL - how to install MPFR (see also mpfr.texi)
Makefile* - files for building the library
NEWS - new features with respect to previous versions
PATCHES - empty file (until patches are applied)
README - this file
TODO - what remains to do (any help is welcome!)
VERSION - version of MPFR (next release version if taken by Subversion)
ac*.m4 - automatic configuration files
compile - auxiliary installation file
config.* - auxiliary installation files
configure* - configuration files
depcomp - auxiliary installation file
doc/ - directory containing the documentation (manual, FAQ)
examples/ - directory containing examples
install-sh - installation file
ltmain.sh - auxiliary installation file
m4/ - directory containing additional configuration files
missing - auxiliary installation file
src/ - directory containing the MPFR source
tests/ - directory containing the testsuite (for "make check")
tools/ - directory containing various tools
tune/ - directory containing files for tuning MPFR

According to the special exception to the GNU General Public License,
the autotools files compile, config.sub, config.guess, ltmain.sh,
m4/libtool.m4 and missing are distributed under the same licence of
GNU MPFR.


You can get the latest source code by Subversion at INRIAGForge:

 svn checkout svn://scm.gforge.inria.fr/svn/mpfr/trunk mpfr

or

 svn checkout https://scm.gforge.inria.fr/svn/mpfr/trunk mpfr

(the last argument can be any directory name). You can use

svn ls svn://scm.gforge.inria.fr/svn/mpfr/branches
svn ls svn://scm.gforge.inria.fr/svn/mpfr/tags

to get the list of branches or tags (releases), then checkout a
particular branch or tag instead of the trunk. Alternatively, you
can now use the "https:" scheme (a.k.a. DAV) instead of "svn:".
For more information about Subversion, please see:

http://svnbook.red-bean.com/ (the official Subversion book);
http://gcc.gnu.org/wiki/SvnHelp (written for GCC developers,
   but interesting general information can be found there);
http://subversion.apache.org/faq.html (the Subversion FAQ).

Subversion users should read the file "doc/README.dev" (provided via
SVN only).



名前:
コメント:


タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2014年01月27日 01:20
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。
添付ファイル