Kravchuk (or Krawtchouk if you prefer spelling from the original paper [4]) matrix viewer visualizes Kravchuk matrices modulo prime numbers. Note that Kravchuk matrices are sometimes called MacWilliams matrices [1], [3].
These matrices emerge in the field of coding theory and are used in numerous applications, however, it is not known how they behave modulo a prime number. Thus visualization is created to present this finite-automata-like phenomenon. Binomial coefficients are closely related to these matrices (in fact, they are included in them) and similar phenomenon for them is described by well-known theorem in Number Theory, namely, Lucas's theorem. Similar patterns appear in cellular automata, Pascal’s triangle modulo primes, and other discrete dynamical systems.
In short: this application lets you explore surprising self-similar and automaton-like patterns that appear in Kravchuk matrices when computed modulo primes.
This project is inspired by a quite old Wolfram Mathematica notebook [3]. As a reference of the theory one can use [1] or [2].
Here is an example of the Kravchuk matrix viewer in action:
- Visualize Kravchuk matrices modulo prime numbers
- Support for various prime numbers
- Interactive user interface
- Several color schemes to view the data
- Export images of matrices
- Gogin's scheme
- Gray-scale scheme
- logarithmic scheme
- linear hue scheme
- viridis
- magma
- plasma
| Key | Action |
|---|---|
| Q | Quit |
| C | Change color scheme |
| W/S | Change order |
| A/D | Change modulo |
| E | Export image |
Or more detailed:
Qexits the applicationCchanges color schemeWandSorUPandDOWNchange the orderAandDorLEFTandRIGHTchange the moduloSHIFTincreases speed of changeHorSPACEtoggles helping screenEexports the current matrix view as a .jpg image and saves it into assets/screenshots
Note that the size of the image depends on size of the window.
To install krview, clone the repository and build the project:
git clone https://github.com/supxinfy/krview.git
cd krview
zig buildInstall dependencies using Homebrew:
- Install SDL:
brew install sdl2 sdl_ttf sdl2_image- Install Zig:
brew install zigInstall dependencies using your package manager. For example, on Ubuntu:
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev zigThis project is actively maintained and tested on Zig 0.15+. See releases for tagged versions.
Run the application with:
zig build runor
zig build
./zig-out/bin/krviewFollow the on-screen instructions to visualize Kravchuk matrices.
This project is licensed under the MIT License. See the LICENSE file for details.
This project bundles Terminus Font version 4.49.3.
Terminus Font is licensed under the SIL Open Font License, Version 1.1. You can find license at assets/fonts/OFL.txt.
-
Nikita Gogin and Mika Hirvensalo. Recurrent Construction of MacWilliams and Chebyshev Matrices, TUCS Technical Report, No. 812, February 2007.
-
Philip Feinsilver and Jerzy Kocik. Krawtchouk polynomials and Krawtchouk matrices, Recent Advances in Applied Probability, Springer-Verlag, 2004.
-
N. Gogin, MacWilliams matrix, Mathematica notebook, MathSource, Wolfram Research, 2004. Available at the Wolfram Library Archive: https://library.wolfram.com/infocenter/MathSource/5223/
-
Mykhailo Kravchuk. Sur une généralisation des polynomes d'Hermite, Comptes Rendus Mathématique (in French), 189: 620–622, JFM 55.0799.01, 1929.







