Skip to content

Releases: trizen/sidef

Version 26.04

01 Apr 13:06
26.04
734e970

Choose a tag to compare

Sidef 26.04 Release Notes

Release date: April 1, 2026

This release brings several new built-in methods, major performance improvements across number-theory operations, important bug fixes, updated dependency requirements, and a substantially expanded documentation suite.


New Features

PolyMod — generalized modulus

The PolyMod() class now accepts any object (not just integers) as the modulus, enabling polynomial arithmetic modulo a polynomial:

say PolyMod([1,2,3], [4,5,6])   #=> 3/4*x + 3/2 (mod 4*x^2 + 5*x + 6)

Number.prime_signature(n)

Returns the prime signature of n — the exponents of its prime-power factorization, sorted in descending order:

say prime_signature(324)                                      #=> [4, 2]  (324 = 2^2 * 3^4)
say 30.of { .prime_signature.prod_kv{|k,v| prime(k+1)**v } }  #=> OEIS: A046523

String.bwt_encode() and String.bwt_decode()

Burrows–Wheeler Transform encoding and decoding for strings:

var (bwt, idx) = "banana".bwt_encode
say bwt_decode(bwt, idx)   #=> "banana"

String.from_json and Object.to_json

Round-trip JSON conversion between Sidef objects and JSON strings:

var hash = '{"a":42, "c":{"d":["foo", "bar", true, false, 42.9, 1234]}}'.from_json
say hash
say hash.to_json

Array.huffman()

Builds a Huffman tree from an array of Number objects:

say [1234, 123, 11, 111, 333, 11, 11, 11].huffman

Number.znlog() — composite modulus support

znlog(a, g, n) has been generalized to work with composite moduli and with inputs where gcd(g, n) ≠ 1. The implementation is now also faster and more robust (see Performance section below).


Performance Improvements

binomialmod(n, k, m) — major overhaul

The Number.binomialmod() method has been extensively refactored and optimized across multiple iterations:

  • Refactored internal structure with several optimizations for small k.
  • A new "small k" path is now selected based on p*q (where p^q is a prime power of m) rather than p^q, yielding better overall performance.
  • Dramatic speed-ups for large prime-power moduli:
binomialmod(2*283686649 - 1, 283686649, 283686649)       # 0.01s  (was: ~3s)
binomialmod(2*283686649 - 1, 283686649, 283686649**2)    # 0.1s   (was: ~7.5s)
binomialmod(2*4514260853041 - 1, 4514260853041-1, 4514260853041)  # 0.8s (was: very long)

Number.znlog(a, g, n) — Pohlig-Hellman + Pollard ρ + CRT

A new, faster algorithm now drives discrete logarithm computation: Pohlig-Hellman for prime powers, Pollard rho for primes, combined via the Chinese Remainder Theorem:

{ znlog(-1, 3, 3**_ - 2) || 0 }.map(2..30)                  # 0.01s  (was: 4.7s)
znlog(15, 2, 1000000000000000000117)                        # 0.01s  (was: very long)
znlog(232752345212475230211680, 23847293847923847239847098123812075234, 804842536444911030681947)         # 0.002s

Array.huffman() — O(N log N) heap-based implementation

The Huffman tree builder was reimplemented using a heap priority queue, improving its asymptotic complexity from O(N² log N) to O(N log N). The method is also now deterministic and handles the single-unique-symbol case with an early return.

prime_count(a, b) — lookup-table proximity fast path

prime_count now detects when its arguments are close to internal lookup-table checkpoints and uses a fast incremental path, often reducing computation to a few milliseconds:

prime_count(5000000000000000 - 1000)                 #=> 142377417196334  (0.001s)
prime_count(5000000000000000 + 1000)                 #=> 142377417196393  (0.002s)
prime_count(123456, 5000000000000000 + 1000)         #=> 142377417184792  (0.003s)

Number.rough_count — sublinear optimization

When p_{x-1}² > n, rough_count now returns π(n) − x + 1 immediately, avoiding unnecessary computation.

Acceleration via Math::Prime::Util >= 0.75

When Math::Prime::Util >= 0.75 is available, the following functions for native integers are now faster:

  • is_palindrome
  • is_safe_prime
  • aliquot
  • sopfr
  • sopf

Other performance tweaks

  • k.almost_primes_each(lo, hi, {...}) — minor iteration speed-up for large ranges.
  • Number._n_over_d_divisors — finds a divisor pair and returns early, doing less work.
  • _cached_primorial(n) — keeps the most valuable entries when the internal cache fills up.
  • _find_prime_count_checkpoint() now uses binary search for faster lookups.

Bug Fixes

  • binomialmod on 32-bit systems — Fixed multiple edge cases that caused incorrect results for large inputs on 32-bit platforms (three successive fixes).
  • binomialmod with large prime powers in modulus — Fixed a subtle correctness bug affecting these cases.

Dependency Updates

  • Math::Prime::Util::GMP >= 0.53 — now required.
  • Math::Prime::Util >= 0.74 — now assumed when the module is present; functions from >= 0.75 are used opportunistically when available.

Documentation

This release includes a major documentation overhaul:

  • SIDEF_ADVANCED_GUIDE.md — new advanced guide covering deeper language topics.
  • COMPUTATIONAL_ALGEBRA_GUIDE.md — new guide dedicated to computational algebra.
  • NUMBER_THEORY_TUTORIAL.md — new tutorial with examples and algorithm implementations for number theory in Sidef.
  • SIDEF_BEGINNER_GUIDE.md — merged with the former TUTORIAL.md, rewritten, and substantially expanded (broken examples fixed, missing topics added, installation section completed).
  • CONTRIBUTING.md — new contributing guidelines, including a bug-report template.
  • README.md — overhauled with a modern structure, CLI reference, and language showcase. Perl version requirement corrected to 5.18+.
  • lib/Sidef.pod — expanded and modernized: added INSTALLATION, COMMAND-LINE USAGE, and an expanded LANGUAGE OVERVIEW section.
  • POD documentation added for the Parser, Sidef deparser, Perl deparser, and Optimizer modules.
  • Various smaller fixes and improvements throughout the existing Markdown documentation.

Full Changelog: 26.01...26.04

Version 26.01

13 Jan 18:39
26.01
b3f6a20

Choose a tag to compare

We're pleased to announce the release of Sidef 26.01, featuring several improvements to number theory functions, comprehensive documentation enhancements, and important bug fixes.

New Features

Number Methods

  • Added arg(z) method: Returns the argument (phase angle) of a complex number, equivalent to atan2(z.imag, z.real)

Fraction Methods

  • Added is_proper method: Tests if a fraction is proper (numerator < denominator)
  • Added is_improper method: Tests if a fraction is improper (numerator ≥ denominator)
  • Added as_mixed method: Converts an improper fraction to mixed number representation

Improvements

Number Theory Functions

  • Enhanced is_pandigital(n, base=10): Significantly improved performance
  • Improved factor_upto(n, limit): Refactored implementation with added perfect power checks
  • Fixed valuation(0, n): Now returns 0 instead of +Inf for better practical usability
  • Fixed is_achilles(): Corrected return value behavior

Polynomial Operations

  • Fixed Polynomial.gcd(a, b): Now returns normalized results matching PARI/GP output
    var x = Poly(1)
    say gcd(x**2 - 1, 2*x)   #=> 1  (previously returned -1)
    

Internal Improvements

  • Integrated Math::Prime::Util::omega_primes() for better performance
  • Fixed minor bug in the Optimizer for already optimized code
  • Refactored and reorganized code in lib/Sidef/Deparse/Perl.pm
  • Loaded Sidef::Types::Block::Block inside modules that use Block objects

Documentation

This release includes extensive documentation improvements across the entire codebase:

Core Classes

  • Enhanced documentation for Number, Fraction, Polynomial, Matrix, Vector, Quaternion, Gauss (Gaussian integers), Quadratic, and Mod classes
  • Expanded Array, Hash, String, Set, Bag, and Pair class documentation
  • Improved Range, RangeNumber, RangeString documentation with detailed examples

I/O and System Classes

  • Updated File, Dir, FileHandle, DirHandle, Pipe, Socket, and SocketHandle documentation
  • Enhanced Backtick and Sys class documentation with usage examples and security considerations

Advanced Features

  • Comprehensive documentation for Block, Try, Fork, Lazy, Enumerator, and LazyMethod classes
  • Enhanced Regex and Match class documentation with common patterns
  • Improved documentation for GetOpt, Sig (signal handling), and NamedParam classes

Mathematical Classes

  • Detailed descriptions added for PolynomialMod and mathematical operation classes
  • Enhanced Perl bridge documentation with security considerations
  • Expanded Math::Math class documentation with algorithm explanations

Reference Materials

  • New NUMBER_THEORY_REFERENCE.md file added
  • Simplified and improved TUTORIAL.md
  • Enhanced sidef -h output with more examples and information
  • Updated README.md for better clarity and structure

Documentation Tools

  • Improved pod_generator.pl utility:
    • Added support for =over sections
    • Implemented Pod::Simple::SimpleTree for POD parsing
    • Added proper escaping for < and > characters

Test Coverage

  • Added scripts/Tests/number_methods_edge_cases.sf
  • Added scripts/Tests/polynomial_edge_cases.sf
  • Updated existing test files for better coverage

Miscellaneous

  • Relaxed several version number requirements in Build.PL
  • Fixed multiple formatting issues and typos across documentation
  • Removed legacy GitBook references from README.md

Full Changelog: 25.12...26.01

Version 25.12

21 Dec 00:28
25.12
c37f473

Choose a tag to compare

Additions

  • Added the Number prime_cluster(lo, hi, *diffs) method. (fbfdc1c)
  • Added the Number factor_upto(n, limit) method. (428ea06, f424140)
  • Added the Number pillai(n) method. (a5471a6)
  • Added the Number rootmod_all(a, k, n) method. (ddc7864)
  • Added the Number rootmod(a,k,m) to compute only one root. (0a5d945)
  • Added the Number linear_forms_primes(A, B, [a_1, b_1], ..., [a_k, b_k]) method. (199ddee, 7498245)
  • Added the Number exp_omega(n,k) and exp_omega_sum(n,k) methods. (57439f7)
  • Added the Number exp_bigomega(n,k) and exp_bigomega_sum(n,k) methods. (57439f7)
  • Added the Number exp_squarefree_omega(n,k) and exp_squarefree_omega_sum(n,k) methods. (57439f7)
  • Added the Number psi_sum(n,k=1) method. (ef2771d)
  • Added the Number pillai_sum(n,k=1) method. (de0ff5c)
  • Added the Number omega_sum(n,k=0) method. (880d404)
  • Added the Number bigomega_sum(n,k=0) method. (880d404)
  • Added the Number totient_sum(n, k=1) method. (52344d0)
  • Added the Number sigma_sum(n,k) function. (afebe73, f48594e)
  • Added the Array imin, imax and iminmax methods. (ea4e533)
  • Added the Array iuniq method. (281a307)

Improvements

  • Refactor is_almost_prime(n,k) and is_omega_prime(n,k), removing code duplication. (05d8f77)
  • Refactor special_factors(n) method. (69ef2e5)
  • Performance and memory optimization in Number _dynamic_preimage(). (103dceb)
  • Much faster algorithm in Number sum_of_squares(n) for numbers with many solutions and higher powers. (9631701)
  • Slightly better performance in Number lcm(a, b) for native integers a and b when a*b < ULONG_MAX. (637c5b9)
  • Use sizeinbase(n,2)-1 <=> k instead of comparing n with 2**k. (3d2bc3c)
  • Better performance in Number k.rough_count(n) for non-native n. (f7889c4, e281c9f)
  • Better performance in liouville_sum(n) for n > 10^6. (25371e4)
  • Tweak performance in _sieve_almost_primes() for narrow ranges. (32ea94b)
  • Extended the _any2mpz() internal function, to support an additional argument k. (bfc4e2e)
  • Optimization: use Math::Prime::Util::prime_powers(lo,hi) for 1.omega_primes(lo,hi). (af2f4da)
  • Optimized the generation of k-almost primes and k-omega primes when lo and hi are close to each other. (1649912)
  • Slightly better performance in several Number methods that return native integers. (3d90269)
  • Slightly better performance in Number liouville_sum(n) method. (88e93a3)
  • Better performance in Array sort and uniq methods for arrays of numbers. (07fa765)
  • Use isort and iuniq in the Number class, where possible. (281a307)
  • Generalized the Number factorial_valuation(n,k) to support composite values for k. (e25e9b8)
  • Better performance in Number is_omega_prime(n,k) and is_almost_prime(n,k) with Num!USE_CONJECTURES = true. (428ea06)
  • Slightly better performance in Number next_prime_power(n) for native inputs. (f984e2b)

Full Changelog: 24.11...25.12

Version 24.11

28 Nov 19:11
24.11
9ac0a9b

Choose a tag to compare

Additions

  • Added the Array .isort and .isort_by{...} methods. (558edae)
  • Added the Array .skip(n), .skip_last(n) and .skip_by { ... } methods. (dba4feb)
  • Added the Number farey(n) method. (c392646)
  • Added the Number farey_neighbors(n, p/q) method. (ec8e01d)
  • Added the Number egypt_greedy(p/q) method. (262b1a5)
  • Added the String sayf(format_str, ...) method. (17ea7e1)
  • Added the String .byte(n) method. (a561092)
  • Added the String .head and .tail aliases for .first and .last methods. (a561092)
  • Added the String .cons(n) and .each_cons(n, {...}) methods. (9b4a54b)
  • Added the FileHandle .get_byte method. (532056c)
  • Added the FileHandle .printlnf() method (also aliased as sayf). (0d9ec08)

Improvements

  • Funnier parsing error-messages, generated with Chat GPT. (adabed4)
  • Extended the FileHandle .new_buf() method, to accept an optional initial string. (5745d87)
  • Extended the given/when statement to support a block, testing for trueness. (019350a)
  • Better performance in Number nth_powerfree(n,k) for large enough n (>10^30). (94bfebe, 14a1ee2, 9b4a54b)
  • Simplified the liouville_sum function for slightly better performance. (61f50c7)

Changes

  • Renamed the Array and String method jaro_distance to jaro. (f7e725f)

Bug-fixes

  • Fixed a minor issue in Perl.to_sidef() method. (2d6af54)
  • Fixed Number mertens(n) for non-native values of n. (61f50c7)
  • Guard against "Modification of a read-only value attempted" errors. (0f8b1ab)

Full Changelog: 24.05...24.11

Version 24.05

12 May 07:38
24.05
e7e1203

Choose a tag to compare

Additions

  • Added the Number fibonorial(n) method. (b811901)
  • Added the Number is_primitive_abundant(n) method. (eb11b34)
  • Added several aliases for trigonometric functions. (4aa0032)

Improvements

  • Several minor optimizations in the Number class. (40c23f8)
  • Slightly better performance in Number powerful_count. (387da41)
  • Slightly faster generation of k-powerful numbers in a given range. (100f7d8)
  • No longer do trial division for small n in is_carmichael(n). (02b1ab3)
  • Slightly less overhead in RangeNumber iter for native integers and step=1. (5521bbf)
  • Number _primality_pretest(): when n > 10^50_000, try gcd with primorial(10^9) (on 64-bit systems). (2e99031)

Changes

  • Parse 'ZERO WIDTH SPACE' (U+200B) as whitespace. (2f6a1f8)
  • Return false from Number is_strong_psp(n, b) when gcd(n,b) != 1. (f72e891, 9b833eb)
  • Reimplemented Number is_pseudoprime(n,b) for better consistency. (f72e891)

Bug-fixes

  • No longer use VERSION in eval() (ready for Perl 5.40). (acdaf87)
  • Fixed gcd(-n) and lcm(-n) to return n instead of -n. (5d478d9)
  • Fixed the deparsing of an empty array that contains empty expressions, under -O1. (9547182)

All changes: 24.01...24.05


P.S.: This is a minor release, preparing Sidef for Perl 5.40.

Version 24.01

06 Jan 17:13
24.01
2f78041

Choose a tag to compare

Additions

  • Added the Number Num!USE_PFGW class-variable. (disabled by default) (04e7c13, 65ee349)
  • Added the Number znlog(a, g, m) method. (c9ba93e)
  • Added the Number geometric_summod(n, r, m) method. (fe5852e)
  • Added the Number centered_pyramidal(n,k) method. (0f76bd9)
  • Added the Number centered_pyramidal_root(n,k) method. (0f76bd9)
  • Added the Number antidivisors(n) and antidivisor_count(n) methods. (c733f79)
  • Added the Number antidivisor_sum(n) method. (d8d9ca3)
  • Added the Number pisano_period(n) method. (2b750d7)
  • Added the Number solve_quadratic_form(d, n) method. (de88fe0)
  • Added the Number smod(a, m) method. (aa825ef)
  • Added the Number germain_factor(n) method. (ac72a2b)
  • Added the Block { ... }.nest(n, initial_value=0) method. (f904fc4)
  • Added the Array .summod(m) and .prodmod(m) methods. (12dc78b)
  • REPL: added support for executing a Sidef script in interactive mode (-i). (f1c1848)

Improvements

  • Much faster generation of Carmichael and Lucas-Carmichael numbers with few prime factors. (6925ddc)
  • Slightly better performance in generating native pseudoprimes. (426346e)
  • Optimized Number idiv_ceil(a,b) for native positive integers. (0a9cd66)
  • Slightly faster generation of pseudoprimes (Carmichael, Lucas-Carmichal and Fermat). (0a9cd66)
  • Call _primality_pretest(n) from _is_prob_prime(n) for large enough n. (8dc1329)
  • Ignore trial-division factors when looking for special factors in Number _factor(n). (30aead5)
  • Minor tweaks in is_almost_prime(n,k) and is_omega_prime(n,k) for slightly better performance. (30f35b6)
  • Slightly better performance in Number is_prob_prime(n) and all_prime(...) for n < 10^1000. (858add2)
  • Optimized Number ipow2(n) and ipow10(n) when the result is a native integer. (b787581)
  • Optimized Number n.remove(k) for native integers. (d99908c)
  • Less overhead in Number _big2istr(), _big2uistr and _big2pistr() private functions. (164425c)
  • Slightly better performance in Number is_mersenne_prime. (038de75)
  • Optimized Number factorial_valuation(n,p) for native integers. (67377c2)
  • Several optimizations in the Number class for native integers. (204dc7d)
  • Better performance in Number is_carmichael(n) and is_lucas_carmichael(n). (74c5901, 294f4a3, 25df4d7)

Changes

  • Stringify PolyMod objects as x^k + ... + c (mod m). (6847de6)

Bug-fixes

  • Workaround for a bug in interactive mode. (5930a89)
  • Allow Set and Bag objects to be used as arrays. (3202fad)
  • Minor fix in lucas_factor(n,j,tries) when j is nil. (25327ca)
  • REPL: add typed words to auto-completion only when the code is valid. (731abe5)
  • REPL: allow variable declarations in interactive mode to contain empty lines. (1e97aae)
  • REPL: allow lines to extend over multiple lines, by using the backslash (\) character. (5930a89)
  • Fixed a minor issue in Number is_powerful(n,k): return false if n is negative and k == 1. (2074f27)

All changes: 23.11...24.01

Version 23.11

07 Nov 05:43
23.11
3689f1b

Choose a tag to compare

Additions

  • Added the PolyMod([...], m) built-in class. (fe8303d)
  • Added the PolyMod chinese(...) method. (fada375)
  • Added the Gauss factor(z) and factor_exp(z) methods. (8827635)
  • Added the Gauss divisors(z) method. (805442f)
  • Added the Number is_bfsw_psp(n) method. (762af27)
  • Added the Number totient_range(a,b) method. (17aa258)
  • Added the Number proper_sigma0(n) method. (17aa258)
  • Added the Number proper_divisors(n) method. (17aa258)
  • Added the Number mobius_range(n) method. (17aa258)
  • Added the Number is_deficient(n) method. (17aa258)
  • Added the Number is_amicable(n,m) method. (17aa258)
  • Added the Number linear_congruence(n, r, m) method. (219320b)
  • Added the Number bphi(n) method. (a121ecd)
  • Added the Number iphi(n,k=1) method. (68049c4)
  • Added the Number nuphi(n) method. (8bd9444)
  • Added several more Polynomial methods. (4d18279)

Improvements

  • Optimization in Number modular_quadratic_formula(a,b,c,m) when gcd(2*a, m) == 1. (6f88a08)
  • Return ealry if input is a prime number in Number special_factor(n). (bae4ff1)
  • Extended the Number aliquot(n) method to accept an extra argument. (17aa258)
  • Minor optimization in Number trial_factor(n,lim). (1b781e9)
  • Minor performance improvements in Number is_powerful(n,k). (455eeed)
  • Optimized Number is_div(n,k) for native integers. (15dc482)
  • Better performance in Number k.powerful_count(n) for non-native n. (9d131a7)
  • Optimized the Number divisors(n,k) method for better performance. (e662b70)
  • Generalized the Number phi and uphi methods to accept an extra argument. (af72440)

Bug-fixes

  • Fixed an issue in Number modular_quadratic_formula(x,y,z,m) for x != 1. (219320b)
  • Fixed a minor issue in Number irand(0,x). (f92fbc5)
  • Fixed two rare issues in Number is_almost_prime(n,k) and is_omega_prime(n,k). (bc745eb)
  • bin/sidef: add to history only words <= 50 chars in length. (6e4ba2a)
  • Make Range::Range, Block::Try and Block::Fork real objects, by inheriting from Sidef::Object::Object. (5322489)

All changes: 23.10...23.11

Version 23.10

17 Oct 05:03
23.10
adbff39

Choose a tag to compare

Additions

  • Added the Number Num!USE_PARI_GP class-variable (disabled by default). (12fe3db bd13ad0)
  • Added the Number Num!USE_CONJECTURES class-variable (disabled by default). (43b8165)
  • Added the Number is_bfw_psp(n) method. (218aa60)
  • Added support for parsing polynomials as Poly(str). (819a5ae)
  • Added the Array .bsearch_min{...}, .bsearch_max{...}, .bindex_min{...} and .bindex_max{...} methods. (70d81cb)
  • Added the File.link and File.symlink methods. (cf029ea 379f1a6)
  • Added support for method-name completion in the REPL. (3d5c1ba 1d2f6a9)
  • Added the Array arr.ordered_partitions(k, { ... }) method. (6378d47)

Improvements

  • Extended the include("file.sf") statement. (865857f)
  • Use a cryptographically-secure pseudorandom number generator in the Number irand method. (5e5c7e4)
  • Improved the Number primality_pretest(n) method for n > 10^1000. (38f844b)
  • Better performance in computing the modular Lucas V and U sequences. (1dbbf7e, 919bfb3)
  • Use is_almost_extra_strong_lucas_pseudoprime in Number all_prime and is_safe_prime. (d066781)
  • Slightly better performance in the generation of native k-powerful numbers. (5e5c7e4)
  • Slightly better performance in Number is_square(n), is_cube(n) and is_power(n,k) for native integers. (3bbff08)
  • Minor performance tweaks inside Number special_factor(n). (68a6048)
  • Better bounds in Number nth_powerfree(n,k) for k = 2. (e001622)
  • Much better performance in Number next_perfect_power(n) and prev_perfect_power(n). (81af8f0)

Changes

  • Changed the Number is_prob_prime(n) method to use the Frobenius-Underwood test. (38f844b)
  • Perl.to_sidef(): parse numbers with a decimal point, as floating-point numbers. (4f34c47)
  • Return a Sidef::Module::OO object from Block.thread(). (76c87b2)

Bug-fixes

  • No longer use integer in Number smooth_count. (2be1792)
  • Extended the Matrix .pow(n) method to accept an arbitrary large integer. (574d6a5)
  • Fixed a performance issue in Number prime_count(a,b) when a and b are close to each other. (7e53839)
  • Fixed a segmentation fault in Regex lt, le, gt and ge methods. (9626332)
  • Fixed a segmentation fault in Array .le, .lt, .gt and .ge methods. (5d543a8)
  • Fixed a right-shift issue for native integers with perl < 5.24.0. (67a636a d1ee265)

All changes: 23.08...23.10

Version 23.08

29 Aug 10:39
23.08
fb588f3

Choose a tag to compare

Additions

  • Added the Num!USE_PRIMESUM class-variable. (disabled by default) (28e2ac3)
  • Added the Number lpf_sum(a,b) method. (9c70da2)
  • Added the Number gpf_sum(a,b) method. (096ead5)
  • Added the Number k.squarefree_almost_prime_sum(a,b) method. (601bb75)
  • Added the Number k.almost_prime_sum(a,b) method. (6b1d971)
  • Added the Number prime_power_sum(n) method. (90d77d9)
  • Added the Number k.omega_prime_sum(a,b) method. (d238139)
  • Added the Number k.power_count(a,b) and k.power_sum(a,b) methods. (19cd8c9)
  • Added the Number perfect_power_sum(n) method. (c799a1c)
  • Added the Number nth_perfect_power(n) method. (ab462f6)
  • Added the Number next_perfect_power(n,k=nil) and prev_perfect_power(n,k=nil) methods. (5c195e3)
  • Added the Number prev_prime_power(n) method. (e51de62)
  • Added the Number n.prev_omega_prime(k=2) method. (44c3723)
  • Added the Number prev_semiprime(n) method. (ad8928b)
  • Added the Number prev_almost_prime(n,k) method. (ad8928b)
  • Added the Number prev_squarefree(n) method. (cb6917d)
  • Added the Number next_squarefree_semiprime(n) method. (a6e26d0)
  • Added the Number n.prev_powerfree(k=2) method. (8457fd4)
  • Added the Number n.prev_powerful(k=2) method. (8d4907f)
  • Added the Number n.prev_squarefree_semiprime method. (6da4bba)
  • Added the Number n.prev_squarefree_almost_prime(k=2) method. (6da4bba)
  • Added the Number nth_nonpowerfree(n,k) method. (6cc777f)
  • Added the Number next_nonpowerfree(n,k=2) and prev_nonpowerfree(n,k=2) methods. (809aa9b)
  • Added the Number muladdmulmod(a, b, c, d, m) and mulsubmulmod(a, b, c, d, m) methods. (9e230f4)
  • Added the Number muladdmod(a,b,c,m), mulsubmod(a,b,c,m) and submulmod(a,b,c,m) methods. (d50ffde)
  • Added several cube_* and cubefree_* aliases for 3.power_* and 3.powerfree_. (bb0784e)
  • Added the FileHandle .rewind method. (3b40438)
  • Added the String .codes method. (6da6122)
  • Added the Range .sort {|a,b| ... } and .sort_by {|v| ... } methods. (1eacc45)

Improvements

  • Extended the Number fibmod method to accept 3 arguments. (b79e09d)
  • Extended expnorm(n,b) to accept any value for base b, including a complex number. (b79e09d)
  • Use primecount --phi in Number k.rough_count(n) when Num!USE_PRIMECOUNT is enabled. (28e2ac3)
  • Extended cop_factor(n) to potentially find more factors. (a2cdf75)
  • Allow the Number gamma method to be called as Num.gamma, returning the Euler-Mascheroni constant. (b79e09d)
  • Added a few more terms in the lookup table for mertens(2**n) and mertens(2**n). (e9ebca0)
  • bin/sidef: added the faith rounding option for -M, which does faithful rounding (with mpfr >= 4.0.0). (fde163a)
  • Better performance in is_omega_prime(n,k) and is_almost_prime(n,k) for large n. (abc0c1e)
  • Num(str, base) now returns a blessed native integer, when possible. (47aa40a)
  • Added a few more terms in the Number almost_prime_count() lookup tables. (56b16a3)
  • Better performance in Number nth_almost_prime(n,k) when the result doesn't fit inside a native integer. (b6afa3d)
  • Better performance in Number k.almost_primes(a,b) and k.omega_prime_count(a,b) when the GitHub version of Math::Prime::Util is installed.
  • Better performance in Number fibonacci(n,k) for k >= 3 and large enough n. (bf9f8b9)
  • Added internal cache inside the Number _is_prob_prime internal function. (7697083)

Changes

  • Renamed the Number k.non_powerfree(a,b) method to k.nonpowerfree(a,b). (384eb06)
  • Reimplemented the Array and String .slice(offset, length) methods. (68d11ff, 11887b8, 724882e)
  • Renamed the Number .partitions method to .partition_count, which better reflects what it returns. (34c2fc9)
  • Renamed the Number *squareful* and *cubeful* methods to *squarefull* and *cubefull* respectively. (5433491)

Bug-fixes

  • Added a better defined Array .ft(i,j) method. (724882e)
  • Fixed the help command inside the REPL. (efa54f1)
  • Fixed the code generation for a hash-lookup applied on the result of a prefix method-call. (4575600)
  • Fixed a bug in Number divmod(a,b,m) introduced in version 22.05, when a is evenly divisible by b. (48fcbbe)

All changes: 23.05...23.08

Version 23.05

11 May 10:04
23.05
580cbb5

Choose a tag to compare

Additions

  • Added support for transparently converting Perl subroutines to Sidef blocks. (36f6bc0)
  • Added the %perl{...} and %Perl{...} syntax for executing arbitrary Perl code. (8aa1284)
  • Added the Perl.tie() and Perl.untie() methods. (2372474)
  • Added the Number urand(a,b) and useed(n) methods. (f7f6db3, 44a6c4b)
  • Added the Number euler_numbers(n) method. (4ae8698)
  • Added the Number bernoulli_numbers(n) method. (45733ff)
  • Added the Number addmulmod(x, y, z, m) method. (47c4117)
  • Added the Number fubini(n) and fubini_numbers(n) method. (fcf86d1)
  • Added the Number composite_sum(a,b,k=1) method. (35f1f43)
  • Added the Number k.powerful_sum(a,b) method. (6984696)
  • Added the Number k.non_powerfree(a,b) method. (f2c430d)
  • Added the Number k.non_powerfree_each(a, b, { ... }) method. (6b2133f)
  • Added the Number k.non_powerfree_count(a,b) and k.non_powerfree_sum(a,b) methods. (fce0153)
  • Added the Number k.powerfree(a,b) and k.powerfree_each(a,b,{...}) methods. (5e30232)
  • Added the Number is_non_powerfree(n,k), is_non_squarefree(n) and is_non_cubefree(n) methods. (1105641)
  • Added the Number roots_of_unity(n) method. (0afea1e)
  • Added the Fraction inv, powmod and invmod methods. (7c3a7ec)
  • Added the Range neg method. (4a6c5a6)
  • Added the String .each_slice(n, {...}) method. (b984aa2)
  • Added the String .each_kv{|k,v| ... } method. (8dca2c6)
  • Added the String .uniq method. (bbedb55)
  • Added the Block .time method. (2adaae1)
  • Added the Block .bsearch, .bsearch_le, .bsearch_ge and bsearch_inverse methods. (d275993, 5bf031f)
  • Added the Polynomial roots(f) method. (a3397e8)
  • Added the Polynomial newtwon_method(f, x=1i) method. (a3397e8)
  • Added the File .open_arw method. (a5baa6c)
  • Added the FileHandle.new_buf(encoding=:utf8) class method. (a5baa6c)

Improvements

  • Extended the FileHandle << operator, to accept multiple arguments. (e3c6536)
  • Slightly better performance in Number is_squarefree(n), is_powerfree(n,k) and is_powerful(n,k) for native n. (f37ac37)
  • Several optimizations in the Number class for native integers when Math::Prime::Util is not installed. (db4692b)
  • Several optimizations in Number ilog(n,b) for native n. (18f62bd)
  • Better performance in Number is_abs_euler_psp(n) for native n. (2e7480a)
  • Slightly better performance in Number chebyshev_factor(n). (2e7480a)
  • Better performance in Number k.powerful_count(n) for native and large n. (7636988)
  • Slightly better performance in Number prime_power_count(n), k.omega_prime_count(n), k.almost_prime_count(n) and k.squarefree_almost_prime(n). (88a6131)
  • Unpack floor(a/b) and ceil(a/b) into a native integer, if possible. (88a6131)
  • Faster algorithm in Number squarefree_count(n). (c36fad3)
  • Extended Number nth_composite(n), nth_prime(n), nth_prime_power(n) and nth_semiprime(n) for non-native integers n. (914595f)
  • Use primecount in Number nth_prime(n) when n is large enough and Num!USE_PRIMECOUNT is enabled. (fc781e4)
  • Improved the Optimizer to cover more cases. (f741a5e, 68198cf, 7e284dd, 4a6c5a6)
  • Optimized Number sum(...) for native integers. (7869c37)
  • Optimized Number divmod(a,b,m) for native integers. (b5b1117, 8b94722)
  • Deparser: added constant cache for literal numbers and strings. (68198cf)
  • Better performance in Number idiv(a,b) for native inputs. (ca17233)
  • Slightly better performance in Number all_prime(...) for native inputs. (9b796c6)
  • Optimized Number powmod(a,n,m) for native inputs. (3de883d)
  • Optimized n.is_coprime(k) when either n or k is a native integer. (3de883d)
  • Optimized gcd(a,b) when either a or b is a native integer. (3de883d)
  • Slightly better performance in Number digits2num for native integers. (428490d, 5463548)
  • Better performance in Number n.jordan_totient(k) for large n. (391d4ae)
  • Optimized Number digits(n,b) and sumdigits(n,b) for native inputs. (dbff96a)
  • Optimized Number n.as_bin, n.as_oct and n.as_hex for native integers n. (dbff96a)
  • Optimized Quadratic div(q,n) where n is a Number object. (dbff96a)
  • Slightly better performance in Number is_abundant(n) for large n and native n. (cc724a2)
  • Perl deparser: more efficient code generation for array and hash lookups. (f137849)
  • Better performance in znorder(a,n) and lambda(n) for large n. (1fd66bd)
  • Slightly better performance in special_factor(n). (2a47419)

Changes

  • REPL: dump floating-point number with f suffix. (daf91ad)
  • No longer UTF-8 encode the self-string in String .open_r. (e3c6536)
  • Modified the String .open_r method to accept an optional argument specifying the encoding, which by default is utf8. (a5baa6c)
  • Removed several warnings from the File class. (3199b46)
  • Perl deparser: re-implemented the smartmatch operator (~~) (12f9e2f)
  • Renamed the Number method random_safe_prime(n) to random_nbit_safe_prime(n). (f741a5e)
  • Changed String hex, oct and bin to return 0 for an empty string (instead of NaN). (f741a5e)
  • Parser: no longer parse the + sign as part of a number. (68198cf)
  • Parser: no longer parse - as part of a number. (4a6c5a6)
  • Allow numbers to contain optional whitespace when passed to Number(...). (575792e)

Bug-fixes

  • Fixed an issue in Polynomial(), when the zero coefficient is passed for a power. (787cf8d)
  • Fixed an issue in Number as_cfrac(n) for rationals and native integers. (bb30265)
  • Made RAT % INT to be consistent with INT % INT when the modulo is negative. (7869c37)
  • Fixed a minor issue in _set_int(n) when n is a Perl string with leading zeros. (3de883d)
  • String.apply_escapes(): fixed an issue that caused binary strings to get inconsistent byte representations during -O1. (ecf99e6)
  • Fixed an edge case in is_almost_prime(n,k) and is_omega_prime(n,k) for numbers n that contain the prime factor 101. (1c16e5f)
  • Fixed an issue Number is_lucas_carmichael(n) for native integers n. (522e4ba)

All changes: 23.03...23.05