mirror of
https://github.com/gonum/gonum.git
synced 2025-10-10 01:20:14 +08:00
stat/combin: fix typos
The four functions explained by the modified comments panic if n or k of parameters are "negative", not "non-negative".
This commit is contained in:
@@ -192,7 +192,7 @@ func nextCombination(s []int, n, k int) {
|
|||||||
// CombinationIndex returns the inverse of IndexToCombination.
|
// CombinationIndex returns the inverse of IndexToCombination.
|
||||||
//
|
//
|
||||||
// CombinationIndex panics if comb is not a sorted combination of the first
|
// CombinationIndex panics if comb is not a sorted combination of the first
|
||||||
// [0,n) integers, if n or k are non-negative, or if k is greater than n.
|
// [0,n) integers, if n or k are negative, or if k is greater than n.
|
||||||
func CombinationIndex(comb []int, n, k int) int {
|
func CombinationIndex(comb []int, n, k int) int {
|
||||||
if n < 0 || k < 0 {
|
if n < 0 || k < 0 {
|
||||||
panic(errNegInput)
|
panic(errNegInput)
|
||||||
@@ -238,7 +238,7 @@ func CombinationIndex(comb []int, n, k int) int {
|
|||||||
// The combination is stored in-place into dst if dst is non-nil, otherwise
|
// The combination is stored in-place into dst if dst is non-nil, otherwise
|
||||||
// a new slice is allocated and returned.
|
// a new slice is allocated and returned.
|
||||||
//
|
//
|
||||||
// IndexToCombination panics if n or k are non-negative, if k is greater than n,
|
// IndexToCombination panics if n or k are negative, if k is greater than n,
|
||||||
// or if idx is not in [0, Binomial(n,k)-1]. IndexToCombination will also panic
|
// or if idx is not in [0, Binomial(n,k)-1]. IndexToCombination will also panic
|
||||||
// if dst is non-nil and len(dst) is not k.
|
// if dst is non-nil and len(dst) is not k.
|
||||||
func IndexToCombination(dst []int, idx, n, k int) []int {
|
func IndexToCombination(dst []int, idx, n, k int) []int {
|
||||||
@@ -531,7 +531,7 @@ func (p *PermutationGenerator) Permutation(dst []int) []int {
|
|||||||
// PermutationIndex returns the inverse of IndexToPermutation.
|
// PermutationIndex returns the inverse of IndexToPermutation.
|
||||||
//
|
//
|
||||||
// PermutationIndex panics if perm is not a permutation of k of the first
|
// PermutationIndex panics if perm is not a permutation of k of the first
|
||||||
// [0,n) integers, if n or k are non-negative, or if k is greater than n.
|
// [0,n) integers, if n or k are negative, or if k is greater than n.
|
||||||
func PermutationIndex(perm []int, n, k int) int {
|
func PermutationIndex(perm []int, n, k int) int {
|
||||||
if n < 0 || k < 0 {
|
if n < 0 || k < 0 {
|
||||||
panic(errNegInput)
|
panic(errNegInput)
|
||||||
@@ -605,7 +605,7 @@ func (s sortInts) Swap(i, j int) {
|
|||||||
// The permutation is stored in-place into dst if dst is non-nil, otherwise
|
// The permutation is stored in-place into dst if dst is non-nil, otherwise
|
||||||
// a new slice is allocated and returned.
|
// a new slice is allocated and returned.
|
||||||
//
|
//
|
||||||
// IndexToPermutation panics if n or k are non-negative, if k is greater than n,
|
// IndexToPermutation panics if n or k are negative, if k is greater than n,
|
||||||
// or if idx is not in [0, NumPermutations(n,k)-1]. IndexToPermutation will also panic
|
// or if idx is not in [0, NumPermutations(n,k)-1]. IndexToPermutation will also panic
|
||||||
// if dst is non-nil and len(dst) is not k.
|
// if dst is non-nil and len(dst) is not k.
|
||||||
func IndexToPermutation(dst []int, idx, n, k int) []int {
|
func IndexToPermutation(dst []int, idx, n, k int) []int {
|
||||||
|
Reference in New Issue
Block a user