Math::Sidef - Perl interface to Sidef's mathematical library.
use 5.018; use Math::Sidef qw(factor composite prime ipow); say prime(1e7); # 10^7-th prime number say composite(1e7); # 10^7-th composite number # Prime factorization of 2^128 + 1 say join ' * ', factor(ipow(2, 128) + 1); # Iterate over prime numbers in range 50..100 Math::Sidef::each_prime(50, 100, sub { say $_[0]; });
Math::Sidef provides an easy interface to the numerical built-in system of Sidef.
It supports all the numerical functions provided by:
Sidef::Types::Number::Number
Sidef::Types::Number::Mod
Sidef::Types::Number::Gauss
Sidef::Types::Number::Quadratic
Sidef::Types::Number::Quaternion
Sidef::Types::Number::Polynomial
Sidef::Types::Number::Fraction
The returned numerical values are returned as Math::AnyNum objects.
Any function can be imported, using the following syntax:
use Math::Sidef qw(function_name);
Additionally, for importing all the functions, use:
use Math::Sidef qw(:all);
It's also possible to import only functions for specific uses:
:number export Number functions, with Number() constructor :gauss export Gauss functions, with Gauss() constructor :quadratic export Quadratic functions, with Quadratic() constructor :quaternion export Quaternion functions, with Quaternion() constructor :mod export Mod functions, with Mod() constructor :poly export Poly functions, with Poly() constructor :fraction export Fraction functions, with Fraction() constructor
Example:
use Math::Sidef qw(:gauss :quadratic); say pow(Gauss(3,4), 10); say powmod(Quadratic(3, 4, 100), 10, 97);
The list of functions available for importing, can be listed with:
CORE::say join ", ", sort @Math::Sidef::EXPORT_OK;
while the methods for a specific group (e.g.: quadratic), can be listed with:
CORE::say join ", ", sort @{$Math::Sidef::EXPORT_TAGS{quadratic}};
Sidef - The Sidef programming language.
Math::AnyNum - Arbitrary size precision for integers, rationals, floating-points and complex numbers.
Math::Prime::Util - Utilities related to prime numbers, including fast sieves and factoring.
Math::Prime::Util::GMP - Utilities related to prime numbers, using GMP.
https://github.com/trizen/Math-Sidef
Daniel "Trizen" Șuteu, <trizen@cpan.org>
Copyright (C) 2021 by Daniel "Trizen" Șuteu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.32.0 or, at your option, any later version of Perl 5 you may have available.
To install Math::Sidef, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Sidef
CPAN shell
perl -MCPAN -e shell install Math::Sidef
For more information on module installation, please visit the detailed CPAN module installation guide.