NAME

Math::Sidef - Perl interface to Sidef's mathematical library.

SYNOPSIS

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];
});

DESCRIPTION

Math::Sidef provides an easy interface to the numerical built-in system of Sidef.

It supports all the numerical functions provided by:

The returned numerical values are returned as Math::AnyNum objects.

IMPORT

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}};

SEE ALSO

  • 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.

REPOSITORY

https://github.com/trizen/Math-Sidef

AUTHOR

Daniel "Trizen" Șuteu, <trizen@cpan.org>

COPYRIGHT AND LICENSE

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.