Math::...ultiset(3pm)

πŸ’… NAME πŸ’…

Math::GSL::Multiset β€” literally just multisets manipulation bestie, that's the whole vibe. It's part of the user contributed Perl documentation, so you know it's the good stuff. ✨


🌸 SYNOPSIS 🌸

okay so first you gotta pull it in:

use Math::GSL::Multiset qw/:all/;

my $ms = Math::GSL::Multiset->($n, $k);

my $value = $ms->get(2);

# compute next multiset
$ms->next;
# compute the previous multiset

# clone a multiset
my $other = $ms->clone();

yes she's giving main character energy with the constructor, the get, the next, and the clone. slay. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: a multiset c is represented by an array of k integers, and every single one of them lives in the range 0 to n-1. and here's the twist β€” each value c_i can show up more than once. not me being obsessed with repetition πŸ’€.

so what does that actually mean? the multiset c corresponds to the indices of k elements chosen from an n element vector with replacement. that's the math tea. and in mathematical terms: n is the cardinality of the multiset, while k is the maximum multiplicity of any value. periodt. πŸ‘‘

πŸŽ€ Object Oriented API πŸŽ€

Handy Perl-style OO API for Multisets. so convenient, so cute, so iconic.

  • new β€” Creates a new multiset with parameters n, k and initializes it to the lexicographically first multiset element, i.e., 0 repeated k times. firsties!! πŸ₯‡
my $ms = Math::GSL::Multiset->($n, $k);
  • init_first β€” Initializes the multiset to the lexicographically first multiset element, i.e. 0 repeated k times. back to the beginning, no cap.
$ms->init_first;
  • init_last β€” Initializes the multiset c to the lexicographically last multiset element, i.e. n-1 repeated k times. she went to the end bestie 🏁
$ms->init_last;
  • get β€” Returns the value of the i-th element of the multiset. but listen β€” if i lies outside the allowed range of 0 to k-1 then the error handler is invoked and 0 is returned. so stay in your lane fr fr 😭
my $val = $ms->get($k-1);
  • next β€” Advances the multiset to the next multiset element in lexicographic order and returns GSL_SUCCESS. but if no further multisets elements are available it returns GSL_FAILURE and leaves the multiset unmodified (no touchy πŸ™ˆ). Starting with the first multiset and repeatedly applying this function will iterate through all possible multisets of a given order. it's giving completionist energy.
$ms->next();
  • prev β€” Steps backwards from the multiset to the previous multiset element in lexicographic order, returning GSL_SUCCESS. If no previous multiset is available it returns GSL_FAILURE and leaves the multiset unmodified. so she can walk backwards too, versatile queen πŸ‘‘
$ms->prev();
  • to_list β€” Creates a Perl list of integers with the values from the multiset, starting at index 0 and ending at index $k-1. here's your lil list bestie:
@data = $ms->to_list;
  • clone β€” Creates a new multiset with the same size, and same values. twin where have you been πŸ’–
my $new = $ms->clone;

🧚 GSL API 🧚

For reference on these methds, please consult the GSL documentation. (that's your homework bestie, go read it πŸ“š)

  • gsl_multiset_calloc
  • gsl_multiset_alloc
  • gsl_multiset_init_first
  • gsl_multiset_init_last
  • gsl_multiset_free
  • gsl_multiset_memcpy
  • gsl_multiset_get
  • gsl_multiset_n
  • gsl_multiset_k
  • gsl_multiset_data
  • gsl_multiset_valid
  • gsl_multiset_next
  • gsl_multiset_prev
  • gsl_multiset_fwrite
  • gsl_multiset_fread
  • gsl_multiset_fprintf
  • gsl_multiset_fscanf

🌈 AUTHORS 🌈

Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> β€” absolute legends, we stan 🫢


Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


okay that's the whole page bestie, you ate it up πŸ’…

this iconic lil page is from the User Contributed Perl Documentation, running alongside perl v5.42.3, dated 2026-08-20 β€” and the manual name is Math::GSL::Multiset(3pm). mwah, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from