Skip to content

Commit

Permalink
docs tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nessan committed Aug 23, 2024
1 parent 33a433c commit d40b0c0
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 52 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ The `bit` library provides a rich interface to set up and manipulate bit-vectors

The `bit::polynomial` class has methods to compute $x^N\bmod{p(x)}$ where $p(x)$ is a polynomial over $\mathbb{F}_2$ and $N$ is a potentially huge integer.

## Installation

This library is header-only, so there is nothing to compile and link—drop the `bit` include directory somewhere convenient, and you're good to go.

Alternatively, if you are using `CMake`, you can use the standard `FetchContent` module by adding a few lines to your project's `CMakeLists.txt` file:

```cmake
include(FetchContent)
FetchContent_Declare(bit URL https://github.com/nessan/bit/releases/download/current/bit.zip)
FetchContent_MakeAvailable(bit)
```

This command downloads and unpacks an archive of the current version of the `bit` library to your project's build folder. You can then add a dependency on `bit::bit`, a `CMake` alias for `bit`. `FetchContent` will automatically ensure the build system knows where to find the downloaded header files and any needed compiler flags.

Used like this, `FetchContent` will only download a minimal library version without any redundant test code, sample programs, documentation files, etc.

## Example

Here is a simple example of a program that uses `bit`:
Expand Down Expand Up @@ -69,6 +53,22 @@ The polynomial sum c(M) gives:

**NOTE:** `bit` makes it possible to quickly extract the characteristic polynomial for a bit-matrix with millions of elements. This problem chokes a naive implementation that needs to consider the unique nature of arithmetic in GF(2).

## Installation

This library is header-only, so there is nothing to compile and link—drop the `bit` include directory somewhere convenient, and you're good to go.

Alternatively, if you are using `CMake`, you can use the standard `FetchContent` module by adding a few lines to your project's `CMakeLists.txt` file:

```cmake
include(FetchContent)
FetchContent_Declare(bit URL https://github.com/nessan/bit/releases/download/current/bit.zip)
FetchContent_MakeAvailable(bit)
```

This command downloads and unpacks an archive of the current version of the `bit` library to your project's build folder. You can then add a dependency on `bit::bit`, a `CMake` alias for `bit`. `FetchContent` will automatically ensure the build system knows where to find the downloaded header files and any needed compiler flags.

Used like this, `FetchContent` will only download a minimal library version without any redundant test code, sample programs, documentation files, etc.

## Why Use `bit`?

The standard library already has [`std::bitset`][], an efficient _bitset_ class that is familiar and well thought through, so our `bit::vector` class replicates and extends much of that interface.
Expand Down
2 changes: 1 addition & 1 deletion docs/_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ elementary-row-ops: "[elementary row operations](https://en.wikipedia.org/wiki/E
Frobenius-form: "[Frobenius form](https://encyclopediaofmath.org/wiki/Frobenius_matrix)"
Galois-Field: "[Galois Field](https://en.wikipedia.org/wiki/Finite_field)"
Gaussian-elimination: "[Gaussian elimination](https://en.wikipedia.org/wiki/Gaussian_elimination)"
GF2: "[GF(2)](https://en.wikipedia.org/wiki/GF(2))"
gf2: "[GF(2)](https://en.wikipedia.org/wiki/GF(2))"
Gram-Schmidt: "[Gram-Schmidt](https://en.wikipedia.org/wiki/Gram–Schmidt_process)"
Hessenberg: "[Hessenberg](https://en.wikipedia.org/wiki/Hessenberg_matrix)"
LU-decomposition: "[LU decomposition](https://en.wikipedia.org/wiki/lu)"
Expand Down
43 changes: 22 additions & 21 deletions docs/pages/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ title: The `bit`Library

## Introduction

`bit` is a header-only {{< var cpp >}} library for numerical work in *bit-space* which mathematicians call {GF2} or {f2}, the simplest [Galois field] with just two elements 0 & 1.
`bit` is a header-only {cpp} library for numerical work in *bit-space* which mathematicians call {gf2} or {f2}.
This is the simplest Galois field with just two elements, 0 and 1.
All arithmetic operations in bit-space are mod 2, so what starts in bit-space stays in bit-space.

The library provides vector and matrix classes for performing linear algebra in bit-space.
Expand All @@ -21,26 +22,6 @@ The `bit` library provides a rich interface to set up and manipulate bit-vectors
Amongst other things, the interface includes methods to solve systems of linear equations over {f2} and to look at the eigen-structure of bit-matrices.
The `bit::polynomial` class has methods to compute $x^N\bmod{P(x)}$ where $P(x)$ is a polynomial over {f2} and $N$ is a potentially huge integer.

## Installation

This library is header-only, so there is nothing to compile and link. Drop the `bit` include directory somewhere convenient, and you are good to go.

Alternatively, if you are using `CMake`, you can use the standard `FetchContent` module by adding a few lines to your project's `CMakeLists.txt` file:
```cmake
include(FetchContent)
FetchContent_Declare(bit URL https://github.com/nessan/bit/releases/download/current/bit.zip)
FetchContent_MakeAvailable(bit)
```
This command downloads and unpacks an archive of the current version of `bit` to your project's build folder. You can then add a dependency on `bit::bit`, a `CMake` alias for `bit`. `FetchContent` will automatically ensure the build system knows where to find the downloaded header files and any needed compiler flags.

Used like this, `FetchContent` will only download a minimal library version without any redundant test code, sample programs, documentation files, etc.

::: {.callout-note}
# Library versions
The shown `URL` gets the `current` version of the library---whatever is in the main branch.
For a fixed, stable library version (say release `2.0.0`), use a `URL` parameter like `https://github.com/nessan/bit/releases/download/2.0.0/bit.zip`.
:::

## Example

Here is a simple example of a program that uses `bit`:
Expand Down Expand Up @@ -82,6 +63,26 @@ c(M) yields:
`bit` makes it possible to quickly extract the characteristic polynomial for a bit-matrix with millions of elements---​a problem that chokes a naive implementation that does not consider the special nature of arithmetic in {f2}.
:::

## Installation

This library is header-only, so there is nothing to compile and link. Drop the `bit` include directory somewhere convenient, and you are good to go.

Alternatively, if you are using `CMake`, you can use the standard `FetchContent` module by adding a few lines to your project's `CMakeLists.txt` file:
```cmake
include(FetchContent)
FetchContent_Declare(bit URL https://github.com/nessan/bit/releases/download/current/bit.zip)
FetchContent_MakeAvailable(bit)
```
This command downloads and unpacks an archive of the current version of `bit` to your project's build folder. You can then add a dependency on `bit::bit`, a `CMake` alias for `bit`. `FetchContent` will automatically ensure the build system knows where to find the downloaded header files and any needed compiler flags.

Used like this, `FetchContent` will only download a minimal library version without any redundant test code, sample programs, documentation files, etc.

::: {.callout-note}
# Library versions
The shown `URL` gets the `current` version of the library---whatever is in the main branch.
For a fixed, stable library version (say release `2.0.0`), use a `URL` parameter like `https://github.com/nessan/bit/releases/download/2.0.0/bit.zip`.
:::

## Why Use `bit`?

The standard library already has {std.bitset}, an efficient *bitset* class that is familiar and well thought through, so our `bit::vector` class replicates and extends much of that interface.
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/matrix/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "The `bit::matrix` Class"

## Introduction

A `bit::matrix` represents a matrix over {GF2} (also known as {f2}) the simplest _Galois_ field that has just two elements usually denoted 0 & 1, or as booleans--true & false, or as bits--set & unset.
A `bit::matrix` represents a matrix over {gf2} (also known as {f2}) the simplest _Galois_ field that has just two elements usually denoted 0 & 1, or as booleans--true & false, or as bits--set & unset.

Arithmetic in {f2} is mod 2, which means that addition/subtraction becomes the `XOR` operation while multiplication/division becomes `AND`.

Expand Down Expand Up @@ -34,7 +34,7 @@ We also define functions like `dot(lhs, rhs)` to handle matrix-vector, vector-ma

There are methods to solve linear systems of equations $A \cdot x = b$.

Danilevsky's method to compute characteristic polynomials (and the determinant) for a `bit::matrix` is available and works for quite large matrices (ones with millions of entries) that would choke a naive implementation that didn't take into account the nature of arithmetic over {GF2}.
Danilevsky's method to compute characteristic polynomials (and the determinant) for a `bit::matrix` is available and works for quite large matrices (ones with millions of entries) that would choke a naive implementation that didn't take into account the nature of arithmetic over {gf2}.

## Declaration

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/notes/danilevsky.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ filters:

It isn't well known, so we review how it works for real-valued matrices.

We then go on to explain how it applies explicitly to bit-matrices, i.e., matrices over {GF2}, the simplest [Galois field] with just two elements 0 & 1 where addition/subtraction and multiplication/division operations are all done mod two which keeps everything closed in the set $\{0,1\}$.
We then go on to explain how it applies explicitly to bit-matrices, i.e., matrices over {gf2}, the simplest [Galois field] with just two elements 0 & 1 where addition/subtraction and multiplication/division operations are all done mod two which keeps everything closed in the set $\{0,1\}$.

## Characteristic Polynomials

Expand Down
6 changes: 3 additions & 3 deletions docs/pages/notes/design.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ title: "Library Design Notes"

## Motivation

We want `bit` to be an _efficient_ linear algebra library for {GF2}, also known as {f2}, which is the set with just two elements 0 & 1.
We want `bit` to be an _efficient_ linear algebra library for {gf2}, also known as {f2}, which is the set with just two elements 0 & 1.
In {f2}, all arithmetic operations are mod 2 to keep everything closed in the set $\{0,1\}$.

Because arithmetic is always mod 2, addition/subtraction becomes the `XOR` operation while multiplication/division becomes `AND`.
A primary goal of the `bit` library is to use those equivalences to perform most interactions on and between bit-vectors and bit-matrices very efficiently by working on whole blocks of elements at a time.

Of course, there are already several very well-known linear algebra libraries in {{< var cpp >}} such as {Eigen}.
Of course, there are already several very well-known linear algebra libraries in {cpp} such as {Eigen}.
Those packages efficiently handle the standard _numeric_ types (floats, doubles, integers, etc.), but none handle {f2} all that well.
They will allow you to create vectors and matrices of integers where all the elements are 0 or 1, but there is no built-in knowledge in those libraries that arithmetic in {f2} is mod 2.

Expand Down Expand Up @@ -66,7 +66,7 @@ std::vector<Block, Allocator> m_block; // <2>
The number of blocks allocated depends on the size of the bit-vector.

The `std::vector<Block>` data member handles any memory allocations and de-allocations.
These days, it is often the case in {{< var cpp >}} that one can completely omit the need to manually manage memory using the `new` and `delete` operators and instead use one of the containers in the standard library.
These days, it is often the case in {cpp} that one can completely omit the need to manually manage memory using the `new` and `delete` operators and instead use one of the containers in the standard library.

::: {.callout-note}
In a `bit::vector`, if there are $d$ binary digits in a block where by default $d = 64$, then bit-vector element $v_i$ is located at bit `i%d` of the block indexed `i/d`.
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/notes/gf2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ filters:

## Introduction

`bit` is a header-only {{< var cpp >}} library that provides classes for bit-vectors and bit-matrices.
`bit` is a header-only {cpp} library that provides classes for bit-vectors and bit-matrices.

In the jargon of professional mathematics, the classes make it possible to perform linear algebra over {GF2}, the simplest [Galois field] with just two elements 0 & 1.
In {GF2}, also commonly known as {f2}, addition/subtraction and multiplication/division operations are all done mod two, which keeps everything closed in the set {0,1}.
In the jargon of professional mathematics, the classes make it possible to perform linear algebra over {gf2}, the simplest [Galois field] with just two elements 0 & 1.
In {gf2}, also commonly known as {f2}, addition/subtraction and multiplication/division operations are all done mod two, which keeps everything closed in the set {0,1}.

This document contains some technical notes on the joys and travails of mathematics using vectors and matrices where the elements are all just zeros and ones and where all arithmetic is mod 2.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/notes/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Technical Notes

## Introduction

There isn't a lot of material on the web devoted to computational work in {GF2}. \
There isn't a lot of material on the web devoted to computational work in {gf2}. \
We add some here:

Paper | Topic
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/polynomial/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "The `bit::polynomial` Class"

## Introduction

A `bit::polynomial` represents a polynomial over {GF2} (also known as {f2}), the simplest {Galois-Field} that has just two elements 0 & 1, where arithmetic is mod 2.
A `bit::polynomial` represents a polynomial over {gf2} (also known as {f2}), the simplest {Galois-Field} that has just two elements 0 & 1, where arithmetic is mod 2.

If $p(x)$ is the bit-polynomial:
$$
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/vector/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "The `bit::vector` Class"

## Introduction

A {bit.vector} represents a vector over {GF2} (also known as {f2}) the simplest {Galois-Field} with just two elements usually denoted 0 & 1, as the booleans true & false, or as the bits set & unset.
A {bit.vector} represents a vector over {gf2} (also known as {f2}) the simplest {Galois-Field} with just two elements usually denoted 0 & 1, as the booleans true & false, or as the bits set & unset.
Arithmetic over {f2} is mod 2, so addition/subtraction becomes the `XOR` operation while multiplication/division becomes `AND`.

The `bit::vector` class is a hybrid between a {std.vector} and a {std.bitset}, along with extra mathematical features to facilitate linear algebra.
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/vector/reference.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: "`bit::vector::reference` --- Proxy Class"

`bit::vector::reference` is a publicly accessible nested _proxy class_ that lets users interact with individual elements/bits in a bit-vector.

It is needed because standard {{< var cpp >}} types cannot target down to the bit level of precision.
It is needed because standard {cpp} types cannot target down to the bit level of precision.

The primary use of this class is to provide an _l-value_ that can be returned from `operator[]` and `operator()` in the `bit::vector` class.

Expand Down
2 changes: 1 addition & 1 deletion include/bit/verify.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// @brief Verification macro that checks a condition and exit with a message if that check fails.
/// @link https://nessan.github.io/bit
/// SPDX-FileCopyrightText: 2024 Nessan Fitzmaurice <[email protected]>
/// SPDX-FileCopyrightText: 2023 Nessan Fitzmaurice <[email protected]>
/// SPDX-License-Identifier: MIT
#pragma once

Expand Down

0 comments on commit d40b0c0

Please sign in to comment.