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 parametersn,kand initializes it to the lexicographically first multiset element, i.e.,0repeatedktimes. firsties!! π₯
my $ms = Math::GSL::Multiset->($n, $k);
init_firstβ Initializes the multiset to the lexicographically first multiset element, i.e.0repeatedktimes. back to the beginning, no cap.
$ms->init_first;
init_lastβ Initializes the multisetcto the lexicographically last multiset element, i.e.n-1repeatedktimes. she went to the end bestie π
$ms->init_last;
getβ Returns the value of thei-th element of the multiset. but listen β ifilies outside the allowed range of0tok-1then the error handler is invoked and0is 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 returnsGSL_SUCCESS. but if no further multisets elements are available it returnsGSL_FAILUREand 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, returningGSL_SUCCESS. If no previous multiset is available it returnsGSL_FAILUREand 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 index0and 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_callocgsl_multiset_allocgsl_multiset_init_firstgsl_multiset_init_lastgsl_multiset_freegsl_multiset_memcpygsl_multiset_getgsl_multiset_ngsl_multiset_kgsl_multiset_datagsl_multiset_validgsl_multiset_nextgsl_multiset_prevgsl_multiset_fwritegsl_multiset_freadgsl_multiset_fprintfgsl_multiset_fscanf
π AUTHORS π
Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> β absolute legends, we stan π«Ά
β COPYRIGHT AND LICENSE β
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
- ubuntu stonking: libmath-gsl-perl 0.49-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms