[Previous] [Next] [Contents]

[ImplState=stable,TestState=stable,DocState=stable]

## `combinat::permutations::peaks` -- Peaks of permutations

#### Introduction

Functions related to the peaks of permutations

#### Details

- A peak of a permutation p=(p1,p2,...,pn) is an integer i such that pi-1≤pi and pi>pi+1.

#### Method peaks: list of the peaks of a permutation

- `peaks(permutation p)`

- Returns the list of the peaks of the permutation `p`, that is the list of integers i such that `p[i-1]<=p[i]` and `p[i]>p[i+1]`.

#### Method peaksNumber: number of peaks of a permutation

- `peaksNumber(permutation p)`

- Returns the number of peaks of the permutation `p`.

#### Example 1

The peaks of a permutation are computed as:

    >> combinat::permutations::peaks([2, 1, 6, 4, 7, 3, 5])

                                      [3, 5]

The number of peaks can be directly computed using:

    >> combinat::permutations::peaksNumber([2, 1, 6, 4, 7, 3, 5])

                                         2

[Previous] [Next] [Contents]

MuPAD Combinat, an open source algebraic combinatorics package