G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
Banner Institutions GREYC CNRS ENSICAEN UNICAEN

A Full-Featured Open-Source Framework for Image Processing



Latest stable version: 4.0.4 (2026/08/19)

Reference

Reptorian's Combinatorics Library: Permutations


Description

Permutations are ordered arrangements of elements where order matters.

For example, the sequences { 1,2,3 } and { 3,2,1 } are two different
permutations of the same elements.

Examples:

rep_permutation(s)_

Standard permutations where all elements are distinct
and each element is used exactly once.

$ +rep_permutations 3 repeat w { e[0] {I[#-1,$>]} }

[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,1,2
[gmic]./ 0,2,1
[gmic]./ 1,0,2
[gmic]./ 1,2,0
[gmic]./ 2,0,1
[gmic]./ 2,1,0
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
  size = (6,1,1,3) [72 b of float32].
  data = (0,0,1,1,2,2^1,2,0,2,0,1^2,1,2,0,1,0).
  min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (4,0,0,0).
[gmic]./ End G'MIC interpreter.

rep_npr_permutation(s)_

Permutations where only a subset of elements is selected
from a larger set. Each element may appear at most once.

$ +rep_npr_permutations 4,2 repeat w { e[0] {I[#-1,$>]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,1
[gmic]./ 0,2
[gmic]./ 0,3
[gmic]./ 1,0
[gmic]./ 1,2
[gmic]./ 1,3
[gmic]./ 2,0
[gmic]./ 2,1
[gmic]./ 2,3
[gmic]./ 3,0
[gmic]./ 3,1
[gmic]./ 3,2
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
  size = (12,1,1,2) [96 b of float32].
  data = (0,0,0,1,1,1,2,2,2,3,3,3^1,2,3,0,2,3,0,1,3,0,1,2).
  min = 0, max = 3, mean = 1.5, std = 1.11803, coords_min = (0,0,0,0), coords_max = (9,0,0,0).
[gmic]./ End G'MIC interpreter.

rep_r_permutation(s)_

Permutations with repetition allowed, where elements
may appear multiple times.

$ +rep_r_permutations 3,2  repeat w { e[0] {I[#-1,$>]} }

[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0
[gmic]./ 0,1
[gmic]./ 0,2
[gmic]./ 1,0
[gmic]./ 1,1
[gmic]./ 1,2
[gmic]./ 2,0
[gmic]./ 2,1
[gmic]./ 2,2
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
  size = (9,1,1,2) [72 b of float32].
  data = (0,0,0,1,1,1,2,2,2^0,1,2,0,1,2,0,1,2).
  min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (6,0,0,0).
[gmic]./ End G'MIC interpreter.

Commands

Permutations:

rep_permutations    rep_permutation_index2list     rep_permutation_list2index
 rep_npr_permutationsrep_npr_permutation_index2list rep_npr_permutation_list2index
 rep_r_permutations  rep_r_permutation_index2list   rep_r_permutation_list2index
G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing

G'MIC is an open-source software distributed under the CeCILL free software licenses (LGPL-like and/or
GPL-compatible). Copyrights (C) Since July 2008, David Tschumperlé - GREYC UMR CNRS 6072, Image Team.