perl 的 Pari 中的 allocatemem() 函数
allocatemem() function in Pari for perl
我使用 perl 的 Crypt::Random 模块生成随机数,该模块依赖于 Math::Pari,Pari/GP 的 perl 接口,在尝试生成 1.5M 时出现此错误位数:
C:\Users\Jlinne\Documents>perl -MCrypt::Random=makerandom_itv -E "say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000')" > num_1500000.txt
PARI: *** the PARI stack overflows !
current stack size: 4.0 Mbytes
[hint] you can increase GP stack with allocatemem()
C:\Users\Ryan\Documents\Perl Scripts>perl scripts1.pl
"use" not allowed in expression at scripts1.pl line 6, at end of line
syntax error at scripts1.pl line 6, near "use Math::Pari
use Math::PariInit "
BEGIN not safe after errors--compilation aborted at scripts1.pl line 7.
我的脚本:
#!/usr/bin/env perl
use warnings;
use strict;
use feature 'say';
use Math::Pari
use Math::PariInit qw( primes=12000000 stack=1e8 );
use Crypt::Random
我猜 allocatemem() 函数是一个 Math::Pari 函数,但它不是。与单行相比,有谁知道使用脚本将 GP 堆栈大小更改为 8.0 MB?谢谢
堆栈到 1e+32 的问题
C:\Users\Jlinne\Documents\Perl Scripts>perl scripts1.pl > BIGINT1500000.txt
PARI: *** the PARI stack overflows !
current stack size: 0.0 Mbytes
[hint] you can increase GP stack with allocatemem()
Compilation failed in require at C:/Strawberry/perl/site/lib/Math/PariInit.pm line 26.
BEGIN failed--compilation aborted at scripts1.pl line 6.
脚本:
use warnings 'all';
use strict;
use feature 'say';
# use Math::Pari;
use Math::PariInit qw( stack=1e32 );
use Crypt::Random qw(makerandom_itv);
say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000');
您不必使用 allocatemem()
,它被列为可以使用但不直接支持的功能之一,请参阅 this in Math::Pari。
相反,从 INITIALIZATION in Math::Pari
When Math::Pari is loaded, it examines variables $Math::Pari::initmem and $Math::Pari::initprimes. They specify up to which number the initial list of primes should be precalculated, and how large should be the arena for PARI calculations (in bytes). (These values have safe defaults.)
Since setting these values before loading requires either a BEGIN block, or postponing the loading (use vs. require), it may be more convenient to set them via Math::PariInit:
use Math::PariInit qw( primes=12000000 stack=1e8 );
查看 Math::PariInit 的(短)页面。
一个完整的例子
use warnings 'all';
use strict;
use feature 'say';
# use Math::Pari;
use Math::PariInit qw( stack=1e8 );
use Crypt::Random qw(makerandom_itv);
say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000')";
运行 script.pl > BIG_num.txt
生成一个带有编号的 1.5Mb
文件(在 11 分钟内)。
通过这种方式,堆栈大小是在编译时设置的。请参阅第一个 link 以动态更改它。
我使用 perl 的 Crypt::Random 模块生成随机数,该模块依赖于 Math::Pari,Pari/GP 的 perl 接口,在尝试生成 1.5M 时出现此错误位数:
C:\Users\Jlinne\Documents>perl -MCrypt::Random=makerandom_itv -E "say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000')" > num_1500000.txt
PARI: *** the PARI stack overflows !
current stack size: 4.0 Mbytes
[hint] you can increase GP stack with allocatemem()
C:\Users\Ryan\Documents\Perl Scripts>perl scripts1.pl
"use" not allowed in expression at scripts1.pl line 6, at end of line
syntax error at scripts1.pl line 6, near "use Math::Pari
use Math::PariInit "
BEGIN not safe after errors--compilation aborted at scripts1.pl line 7.
我的脚本:
#!/usr/bin/env perl
use warnings;
use strict;
use feature 'say';
use Math::Pari
use Math::PariInit qw( primes=12000000 stack=1e8 );
use Crypt::Random
我猜 allocatemem() 函数是一个 Math::Pari 函数,但它不是。与单行相比,有谁知道使用脚本将 GP 堆栈大小更改为 8.0 MB?谢谢
堆栈到 1e+32 的问题
C:\Users\Jlinne\Documents\Perl Scripts>perl scripts1.pl > BIGINT1500000.txt
PARI: *** the PARI stack overflows !
current stack size: 0.0 Mbytes
[hint] you can increase GP stack with allocatemem()
Compilation failed in require at C:/Strawberry/perl/site/lib/Math/PariInit.pm line 26.
BEGIN failed--compilation aborted at scripts1.pl line 6.
脚本:
use warnings 'all';
use strict;
use feature 'say';
# use Math::Pari;
use Math::PariInit qw( stack=1e32 );
use Crypt::Random qw(makerandom_itv);
say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000');
您不必使用 allocatemem()
,它被列为可以使用但不直接支持的功能之一,请参阅 this in Math::Pari。
相反,从 INITIALIZATION in Math::Pari
When Math::Pari is loaded, it examines variables $Math::Pari::initmem and $Math::Pari::initprimes. They specify up to which number the initial list of primes should be precalculated, and how large should be the arena for PARI calculations (in bytes). (These values have safe defaults.)
Since setting these values before loading requires either a BEGIN block, or postponing the loading (use vs. require), it may be more convenient to set them via Math::PariInit:
use Math::PariInit qw( primes=12000000 stack=1e8 );
查看 Math::PariInit 的(短)页面。
一个完整的例子
use warnings 'all';
use strict;
use feature 'say';
# use Math::Pari;
use Math::PariInit qw( stack=1e8 );
use Crypt::Random qw(makerandom_itv);
say makerandom_itv(Lower => '10^1499999', Upper => '10^1500000')";
运行 script.pl > BIG_num.txt
生成一个带有编号的 1.5Mb
文件(在 11 分钟内)。
通过这种方式,堆栈大小是在编译时设置的。请参阅第一个 link 以动态更改它。