C++ Library Extensions 2022.12.09
To help learn modern C++ programming
tpf::ncrnpr Namespace Reference

Implements nCr, nPr. More...

Classes

class  combination
 
class  permutation
 
class  range_t
 
class  simple_positive_rational
 

Typedefs

using range_vector_t = std::vector< range_t >
 

Functions

template<template< typename, typename... > class ContainerType, typename EleType , typename... Types>
int sgn (const ContainerType< EleType, Types... > &cntr)
 Computes the inversion of a permutation. More...
 
template<typename SpanType , typename StartType , typename EndType >
range_vector_t split_range_span (SpanType min_span, StartType st, EndType ed)
 Split range. More...
 
template<typename CountType , typename StartType , typename EndType >
range_vector_t split_range_count (CountType count, StartType st, EndType ed)
 
template<typename Type1 , typename Type2 , typename ReturnType = unsigned long long>
enable_if_all_in_list_t< types::type_list_t< Type1, Type2 >, integral_list_t, ReturnType > ncr (Type1 nn, Type2 rr)
 
template<typename Type1 , typename Type2 , typename ReturnType = unsigned long long>
enable_if_all_in_list_t< types::type_list_t< Type1, Type2 >, integral_list_t, ReturnType > npr (Type1 nn, Type2 rr)
 
template<typename Type , typename ReturnType = unsigned long long>
enable_if_in_list_t< Type, integral_list_t, ReturnType > fact (Type n)
 
template<template< typename, typename... > class SetContainer = std::vector, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename ReturnType = std::vector<EleType>>
ReturnType enumerate_combination (combination cmb, MthType m_th, SetContainer< EleType, ContainerTails... > from_set, SelectCountType select_count)
 
template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, EleType>, typename ReturnType = tpf::duet_set_t<SetTagType>>
ReturnType enumerate_combination_and_complement (combination cmb, MthType m_th, SetContainer< EleType, ContainerTails... > from_set, SelectCountType select_count)
 
template<template< typename, typename... > class ReturnContainer = std::vector, typename MthType = combination::m_th_t, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::duet_set_t<SetTagType>>
auto enumerate_combination_and_complement (MthType m_th, SetSizeType set_size, SelectCountType select_count)
 
template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, EleType>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto enumerate_combinations_and_offsets (SetContainer< EleType, ContainerTails... > from_set, SelectCountType select_count=tpf::InvalidIndex)
 
template<template< typename, typename... > class ReturnContainer = std::vector, typename MthType = combination::m_th_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::duet_set_t<SetTagType>>
ReturnType enumerate_combinations_and_offsets_indices (combination cmb, MthType m_th, std::vector< int > from_set, SelectCountType select_count)
 
template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto enumerate_combinations_and_offsets_indices (SetSizeType set_size, SelectCountType select_count=tpf::InvalidIndex)
 
template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto enumerate_combination_including_indices (std::vector< int > include_set, SetSizeType set_size, SelectCountType select_count=tpf::InvalidIndex)
 
template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto enumerate_combination_excluding_indices (std::vector< int > exclude_set, SetSizeType set_size, SelectCountType select_count=tpf::InvalidIndex)
 
template<typename RType , typename MType >
std::vector< int > enumerate_permutation (std::vector< int > e, RType r, MType m_th)
 
template<typename T >
std::vector< T > enum_permutation (T n, T r, T m_th)
 
template<typename T >
std::vector< T > enum_permutation_remainder (T n, T r, T m_th)
 
template<typename PType , typename NRType , typename MType >
std::vector< NRType > enum_permutation_static (PType permu, NRType n, NRType r, MType m_th)
 
template<typename T >
std::vector< T > enum_permutation_list (T n, T r, T mth)
 
template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = unsigned long long, typename EleType = int, typename CountType = int>
ReturnContainer< EleType > enumerate_permutation (MthType m_th, SetContainer< EleType, ContainerTails... > from_set, CountType r)
 

Detailed Description

Implements nCr, nPr.

Typedef Documentation

◆ range_vector_t

using tpf::ncrnpr::range_vector_t = typedef std::vector<range_t>

Definition at line 148 of file tpf_ncrnpr.hpp.

Function Documentation

◆ enum_permutation()

template<typename T >
std::vector< T > tpf::ncrnpr::enum_permutation ( n,
r,
m_th 
)

Definition at line 1306 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enum_permutation_list()

template<typename T >
std::vector< T > tpf::ncrnpr::enum_permutation_list ( n,
r,
mth 
)

Definition at line 1430 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enum_permutation_remainder()

template<typename T >
std::vector< T > tpf::ncrnpr::enum_permutation_remainder ( n,
r,
m_th 
)

Definition at line 1344 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enum_permutation_static()

template<typename PType , typename NRType , typename MType >
std::vector< NRType > tpf::ncrnpr::enum_permutation_static ( PType  permu,
NRType  n,
NRType  r,
MType  m_th 
)

Definition at line 1387 of file tpf_ncrnpr.hpp.

Here is the caller graph for this function:

◆ enumerate_combination()

template<template< typename, typename... > class SetContainer = std::vector, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename ReturnType = std::vector<EleType>>
ReturnType tpf::ncrnpr::enumerate_combination ( combination  cmb,
MthType  m_th,
SetContainer< EleType, ContainerTails... >  from_set,
SelectCountType  select_count 
)

Definition at line 724 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enumerate_combination_and_complement() [1/2]

template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, EleType>, typename ReturnType = tpf::duet_set_t<SetTagType>>
ReturnType tpf::ncrnpr::enumerate_combination_and_complement ( combination  cmb,
MthType  m_th,
SetContainer< EleType, ContainerTails... >  from_set,
SelectCountType  select_count 
)

Definition at line 792 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enumerate_combination_and_complement() [2/2]

template<template< typename, typename... > class ReturnContainer = std::vector, typename MthType = combination::m_th_t, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::duet_set_t<SetTagType>>
auto tpf::ncrnpr::enumerate_combination_and_complement ( MthType  m_th,
SetSizeType  set_size,
SelectCountType  select_count 
)

Definition at line 867 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_combination_excluding_indices()

template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto tpf::ncrnpr::enumerate_combination_excluding_indices ( std::vector< int >  exclude_set,
SetSizeType  set_size,
SelectCountType  select_count = tpf::InvalidIndex 
)

Definition at line 1149 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_combination_including_indices()

template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto tpf::ncrnpr::enumerate_combination_including_indices ( std::vector< int >  include_set,
SetSizeType  set_size,
SelectCountType  select_count = tpf::InvalidIndex 
)

Definition at line 1068 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_combinations_and_offsets()

template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = combination::m_th_t, typename EleType = int, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, EleType>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto tpf::ncrnpr::enumerate_combinations_and_offsets ( SetContainer< EleType, ContainerTails... >  from_set,
SelectCountType  select_count = tpf::InvalidIndex 
)

Definition at line 899 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_combinations_and_offsets_indices() [1/2]

template<template< typename, typename... > class ReturnContainer = std::vector, typename MthType = combination::m_th_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::duet_set_t<SetTagType>>
ReturnType tpf::ncrnpr::enumerate_combinations_and_offsets_indices ( combination  cmb,
MthType  m_th,
std::vector< int >  from_set,
SelectCountType  select_count 
)

Definition at line 950 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_combinations_and_offsets_indices() [2/2]

template<template< typename, typename... > class ReturnContainer = std::vector, typename SetSizeType = size_t, typename SelectCountType = size_t, typename SetTagType = tpf::set_tag<ReturnContainer, int>, typename ReturnType = tpf::set_of_duets_t<SetTagType>>
auto tpf::ncrnpr::enumerate_combinations_and_offsets_indices ( SetSizeType  set_size,
SelectCountType  select_count = tpf::InvalidIndex 
)

Definition at line 1013 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_permutation() [1/2]

template<template< typename, typename... > class ReturnContainer = std::vector, template< typename, typename... > class SetContainer = std::list, typename... ContainerTails, typename MthType = unsigned long long, typename EleType = int, typename CountType = int>
ReturnContainer< EleType > tpf::ncrnpr::enumerate_permutation ( MthType  m_th,
SetContainer< EleType, ContainerTails... >  from_set,
CountType  r 
)

Definition at line 1476 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ enumerate_permutation() [2/2]

template<typename RType , typename MType >
std::vector< int > tpf::ncrnpr::enumerate_permutation ( std::vector< int >  e,
RType  r,
MType  m_th 
)

Definition at line 1271 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fact()

template<typename Type , typename ReturnType = unsigned long long>
enable_if_in_list_t< Type, integral_list_t, ReturnType > tpf::ncrnpr::fact ( Type  n)

Definition at line 452 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:

◆ ncr()

template<typename Type1 , typename Type2 , typename ReturnType = unsigned long long>
enable_if_all_in_list_t< types::type_list_t< Type1, Type2 >, integral_list_t, ReturnType > tpf::ncrnpr::ncr ( Type1  nn,
Type2  rr 
)

Definition at line 390 of file tpf_ncrnpr.hpp.

Here is the caller graph for this function:

◆ npr()

template<typename Type1 , typename Type2 , typename ReturnType = unsigned long long>
enable_if_all_in_list_t< types::type_list_t< Type1, Type2 >, integral_list_t, ReturnType > tpf::ncrnpr::npr ( Type1  nn,
Type2  rr 
)

Definition at line 428 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sgn()

template<template< typename, typename... > class ContainerType, typename EleType , typename... Types>
int tpf::ncrnpr::sgn ( const ContainerType< EleType, Types... > &  cntr)

Computes the inversion of a permutation.

Parameters
cntrfor container
Returns
int, +1 for even inversion, -1 for odd inversion

https://en.wikipedia.org/wiki/Leibniz_formula_for_determinants

Definition at line 78 of file tpf_ncrnpr.hpp.

◆ split_range_count()

template<typename CountType , typename StartType , typename EndType >
range_vector_t tpf::ncrnpr::split_range_count ( CountType  count,
StartType  st,
EndType  ed 
)

Definition at line 225 of file tpf_ncrnpr.hpp.

Here is the caller graph for this function:

◆ split_range_span()

template<typename SpanType , typename StartType , typename EndType >
range_vector_t tpf::ncrnpr::split_range_span ( SpanType  min_span,
StartType  st,
EndType  ed 
)

Split range.

Template Parameters
SpanType
StartType
EndType
Parameters
min_span
st
ed
Returns
range_vector_t

Definition at line 173 of file tpf_ncrnpr.hpp.

Here is the call graph for this function:
Here is the caller graph for this function: