Skip to content

Commit

Permalink
Fix linking issues in the docs for individual cairo files (#316)
Browse files Browse the repository at this point in the history
## Pull Request type

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [x] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->
Fixed broken links from the refactoring #312 . All the paths have been
renamed to `./packages/` which broke linking in the docs.

## What is the new behavior?

Linking to individual cairo files works as it should. 

## Does this introduce a breaking change?

- [ ] Yes
- [x] No
  • Loading branch information
robertkodra committed Jun 19, 2024
1 parent 3041887 commit ef3292b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 47 deletions.
10 changes: 6 additions & 4 deletions packages/data_structures/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Data structures

## [Array extension](./packages/array_ext.cairo)
## [Array extension](./src/array_ext.cairo)

A collection of handy functions to help with array manipulation.

## [Span extension](./packages/span_ext.cairo)
## [Span extension](./src/span_ext.cairo)

A collection of handy functions to help with span manipulation.

## [Queue](./packages/queue.cairo)
## [Queue](./src/queue.cairo)

The queue is used to store and manipulate a collection of elements where the elements are processed in a **first-in, first-out** (FIFO) order, the oldest element being processed first.

## [Stack](./packages/stack.cairo)
## [Stack](./src/stack.cairo)

The stack is used to store and manipulate a collection of elements where the elements are processed in a **last-in, first-out** (LIFO) order, the most recently added element being processed first.
6 changes: 3 additions & 3 deletions packages/encoding/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Encoding

## [Base64](./packages/base64.cairo)
## [Base64](./src/base64.cairo)

Base64 is a binary-to-text encoding scheme used for transferring binary data safely over media designed for text. It divides input data into 3-byte blocks, each converted into 4 ASCII characters using a specific index table. If input bytes aren't divisible by three, it's padded with '=' characters. The process is reversed for decoding.

## [Solidity ABI](./packages/sol_abi.cairo)
## [Solidity ABI](./src/sol_abi.cairo)

**sol_abi** is a wrapper around `alexandria_bytes::Bytes` providing easy to use interfaces to mimic Solidity's `abi` functions.

Expand Down Expand Up @@ -63,7 +63,7 @@ use starknet::{ContractAddress, eth_address::U256IntoEthAddress, EthAddress};

fn main() {
let encoded: Bytes = ...

let mut offset = 0;
let o1: u8 = encoded.decode(ref offset);
let o2: u128 = encoded.decode(ref offset);
Expand Down
6 changes: 3 additions & 3 deletions packages/linalg/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Linear Algebra

## [Norm](./packages/norm.cairo)
## [Norm](./src/norm.cairo)

Calculate the norm of an u128 array ([see also](https://numpy.org/doc/stable/reference/generated/numpy.linalg.norm.html)).

## [Dot product](./packages/dot.cairo)
## [Dot product](./src/dot.cairo)

The dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors), and returns a single number. Algebraically, the dot product is the sum of the products of the corresponding entries of the two sequences of numbers ([see also](https://en.wikipedia.org/wiki/Dot_product)).

## [Kronecker product](./packages/kron.cairo)
## [Kronecker product](./src/kron.cairo)

The Kronecker product is an an algebraic operation that takes two equal-length sequences of numbers and returns an array of numbers([see also](https://numpy.org/doc/stable/reference/generated/numpy.kron.html)).
44 changes: 27 additions & 17 deletions packages/math/README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,87 @@
# Math

## [Fast Root](./packages/fast_root.cairo)
## [Fast Root](./src/fast_root.cairo)

The fast root algorithm uses Newton-Raphson method to calculate a arbitrary root of a given number (e.g., square root, cubic root, etc.). The algorithm is used to find the roots of a polynomial equation, which has applications in various areas of mathematics, including algebra, calculus, and number theory. The fast root algorithm is also used in computer science, as it can be used to solve problems involving the roots of a polynomial equation.

## [Is Power Of Two](./packages/is_power_of_two.cairo)
## [Is Power Of Two](./src/is_power_of_two.cairo)

The `is_power_of_two` algorithm is used to determine whether a given positive integer is a power of two or not.

## [Fast trigonometric functions (sin, cos, tan)](./packages/trigonometry.cairo)
## [Fast trigonometric functions (sin, cos, tan)](./src/trigonometry.cairo)

The trigonometric functions are a set of mathematical functions that relate the angles of a triangle to the lengths of its sides. The most common trigonometric functions are sine, cosine, and tangent. These functions are used in many areas of mathematics, including geometry, calculus, and statistics. They are also used in physics, engineering, and other sciences.

Fast trigonometric functions are computational and spatial efficient, with minor errors compared to the standard trigonometric functions. Refer to http://hevi.info/tag/fast-sine-function/ for detailed information.

## [Is Prime](./packages/is_prime.cairo)
## [Is Prime](./src/is_prime.cairo)

The `is_prime` algorithm is used to determine whether a given positive integer is a prime number or not.

## [Aliquot sum](./packages/aliquot_sum.cairo)
## [Aliquot sum](./src/aliquot_sum.cairo)

The aliquot sum algorithm calculates the sum of proper divisors of a given positive integer, providing insight into factors and divisors of a number, and classifying it as perfect, abundant, or deficient.
These classifications have applications in areas of math, including geometry, cryptography, and number theory. The algorithm is used for problem-solving and generating puzzles and games.

## [Armstrong number](./packages/armstrong_number.cairo)
## [Armstrong number](./src/armstrong_number.cairo)

The Armstrong number algorithm is used to determine if a number is an Armstrong number, where the sum of its digits raised to the power of the number of digits equals the original number.
The algorithm is used for problem-solving and mathematical puzzles, and has applications in number theory, discrete mathematics, and computer science, as well as in generating strong encryption keys.
By identifying Armstrong numbers, the algorithm provides insight into the properties of numbers and can be used in various applications in mathematics and computer science.

## [Bitmap](./packages/bitmap.cairo)
## [Bitmap](./src/bitmap.cairo)

Bitmap function to manage, search and manipulate bits efficiently.

## [Collatz sequence](./packages/collatz_sequence.cairo)
## [Collatz sequence](./src/collatz_sequence.cairo)

The Collatz sequence number algorithm is a mathematical algorithm used to generate the Collatz sequence of a given positive integer.
The purpose of the Collatz sequence number algorithm is to explore the behavior of the Collatz conjecture, which is a famous unsolved problem in mathematics. The conjecture states that for any positive integer, the Collatz sequence will eventually reach the number 1. The Collatz sequence number algorithm is used to generate and study these sequences, which have applications in various areas of mathematics and computer science.
Additionally, the algorithm is used in generating mathematical puzzles and in teaching concepts such as iteration, recursion, and complexity theory.

## [Extended euclidean](./packages/extended_euclidean_algorithm.cairo)
## [Extended euclidean](./src/extended_euclidean_algorithm.cairo)

The extended Euclidean algorithm is a mathematical algorithm used to calculate the greatest common divisor (GCD) of two numbers and to find the coefficients that satisfy the Bézout's identity, which is a relationship between the GCD and the two numbers.
The purpose of the extended Euclidean algorithm is to provide a way to solve linear Diophantine equations, which are equations in which the variables must be integers.
The algorithm has applications in various areas of mathematics, including number theory, cryptography, and computer science. Additionally, the algorithm is used in generating encryption keys and in solving problems related to modular arithmetic.

## [Fast power](./packages/fast_power.cairo)
## [Fast power](./src/fast_power.cairo)

The fast power algorithm is a mathematical algorithm used to efficiently calculate the power of a given number.
The purpose of the fast power algorithm is to reduce the number of operations required to calculate a power, making it more efficient than traditional methods. The algorithm has applications in various areas of mathematics and computer science, including cryptography, where it is used to perform exponentiation in encryption and decryption operations. The fast power algorithm is also used in programming and software development, as it can improve the efficiency of algorithms that require the calculation of powers.
By reducing the number of operations required to calculate a power, the fast power algorithm provides a more efficient way to perform calculations involving powers.

## [Fibonacci](./packages/fibonacci.cairo)
## [Fibonacci](./src/fibonacci.cairo)

The Fibonacci algorithm is a mathematical algorithm used to generate the Fibonacci sequence, which is a sequence of numbers where each number is the sum of the previous two.
The purpose of the Fibonacci algorithm is to explore the properties and patterns of the Fibonacci sequence, which has applications in various areas of mathematics, including number theory, combinatorics, and geometry. The algorithm is also used in problem-solving and generating mathematical puzzles and games. Additionally, the Fibonacci sequence has applications in computer science and data structures, as it can be used to model recursive algorithms and to generate random numbers.

## [GCD of N numbers](./packages/gcd_of_n_numbers.cairo)
## [GCD of N numbers](./src/gcd_of_n_numbers.cairo)

The GCD (Greatest Common Divisor) of n numbers algorithm is used to find the largest positive integer that divides each of the given n numbers without a remainder.
The purpose of this algorithm is to determine the highest common factor of the given set of numbers. It has applications in various areas of mathematics, including number theory, algebra, and cryptography. The GCD of n numbers algorithm is used in many real-world applications, such as finding the optimal solution to a problem that requires dividing resources among multiple agents. It is also used in computer science for designing efficient algorithms that require determining common factors or multiples of numbers.

## [LCM of N numbers](./packages/lcm_of_n_numbers.cairo)
## [LCM of N numbers](./src/lcm_of_n_numbers.cairo)

The LCM (Lowest Common Multiple) of n numbers algorithm is used to find the smallest positive integer that is a multiple of each of the given n numbers ([see also](https://numpy.org/doc/stable/reference/generated/numpy.lcm.html)).

## [Perfect Number Algorithm](./packages/perfect_number.cairo)
## [Perfect Number Algorithm](./src/perfect_number.cairo)

The perfect number algorithm is used to determine whether a given positive integer is a perfect number or not.
A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself).
The purpose of the algorithm is to identify these special numbers and to study their properties. Perfect numbers have applications in various areas of mathematics, including number theory and algebraic geometry. They are also used in cryptography and coding theory. The perfect number algorithm is important for understanding the structure of numbers and their relationships to each other, and it has been studied for centuries by mathematicians.

## [Zeller's congruence](./packages/zellers_congruence.cairo)
## [Zeller's congruence](./src/zellers_congruence.cairo)

Zeller's congruence algorithm is used to determine the day of the week for a given date.
The purpose of the algorithm is to provide a simple and efficient way to calculate the day of the week based on the date.
It is widely used in various applications, including calendar systems, scheduling, and time management.
The algorithm takes into account the year, month, and day of the given date and performs a series of mathematical calculations to determine the day of the week. By providing an easy-to-use method for calculating the day of the week, Zeller's congruence algorithm is an important tool for many industries and organizations that rely on accurate and efficient time management systems.

## [ed25519](./packages/ed25519.cairo)
## [ed25519](./src/ed25519.cairo)

In public-key cryptography, Edwards-curve Digital Signature Algorithm (EdDSA) is a digital signature scheme using a variant of Schnorr signature based on twisted Edwards curves. It is designed to be faster than existing digital signature schemes without sacrificing security.

## [sha512](./packages/sha512.cairo)
## [sha512](./src/sha512.cairo)

SHA-512 is from the SHA-2 family (Secure Hash Algorithm 2) which is a set of cryptographic hash functions designed by the United States National Security Agency (NSA) and first published in 2001. They are built using the Merkle–Damgård construction, from a one-way compression function itself built using the Davies–Meyer structure from a specialized block cipher.
7 changes: 4 additions & 3 deletions packages/merkle_tree/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Merkle Tree related stuff

## [Merkle Tree](./packages/merkle_tree.cairo)
## [Merkle Tree](./src/merkle_tree.cairo)

The Merkle tree algorithm is a cryptographic hashing algorithm used to create a hash tree, which is a tree data structure where each leaf node represents a data block and each non-leaf node represents a hash of its child nodes.
The purpose of the Merkle tree algorithm is to provide a way to verify the integrity and authenticity of large amounts of data without needing to store the entire data set. The algorithm has applications in various areas of computer science, including cryptocurrency, file sharing, and database management.
The Merkle tree algorithm is also used in creating digital signatures and verifying the authenticity of transactions.
By providing a secure and efficient way to verify data integrity, the Merkle tree algorithm is an important tool in cryptography and information security.
A generic implementation is available to manage both pedersen (legacy) and poseidon hash methods.

## [Starknet Storage Proof Verifier](./packages/storage_proof.cairo)
Implementation of Starknet ([storage proofs](https://docs.starknet.io/documentation/architecture_and_concepts/State/starknet-state/)) returned by `pathfinder_getproof` API endpoint ([see](https://github.com/eqlabs/pathfinder/blob/main/doc/rpc/pathfinder_rpc_api.json)).
## [Starknet Storage Proof Verifier](./src/storage_proof.cairo)

Implementation of Starknet ([storage proofs](https://docs.starknet.io/documentation/architecture_and_concepts/State/starknet-state/)) returned by `pathfinder_getproof` API endpoint ([see](https://github.com/eqlabs/pathfinder/blob/main/doc/rpc/pathfinder_rpc_api.json)).
13 changes: 7 additions & 6 deletions packages/numeric/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# Numerical analysis

## [Trapezoidal rule](./packages/trapezoidal_rule.cairo)
## [Trapezoidal rule](./src/trapezoidal_rule.cairo)

In numerical analysis and scientific computing, the trapezoidal rule is a numerical method to solve ordinary differential equations derived from the trapezoidal rule for computing integrals ([see also](https://en.wikipedia.org/wiki/Trapezoidal_rule_(differential_equations))).
In numerical analysis and scientific computing, the trapezoidal rule is a numerical method to solve ordinary differential equations derived from the trapezoidal rule for computing integrals ([see also](<https://en.wikipedia.org/wiki/Trapezoidal_rule_(differential_equations)>)).

## [Interpolation](./packages/interpolate.cairo)
## [Interpolation](./src/interpolate.cairo)

Returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xs, ys), evaluated at x ([see also](https://numpy.org/doc/stable/reference/generated/numpy.interp.html)).
Several interpolation methods are supported as follow:

- Linear interpolation: y is linearly interpolated between the two nearest neighbors at x
- Nearest-neighbor interpolation: y is set to the value of the nearest neighbor at x
- Constant left interpolation: ys behaves as an integer part function where each y data point extends to the left up to the next index
- Constant right interpolation: ys behaves as an integer part function where each y data point extends to the right up to the next index

## [Cumsum](./packages/cumsum.cairo)
## [Cumsum](./src/cumsum.cairo)

Return the cumulative sum of the elements ([see also](https://numpy.org/doc/stable/reference/generated/numpy.cumsum.html#numpy-cumsum)).

## [Cumprod](./packages/cumprod.cairo)
## [Cumprod](./src/cumprod.cairo)

Return the cumulative product of the elements ([see also](https://numpy.org/doc/stable/reference/generated/numpy.cumprod.html#numpy-cumprod)).

## [Diff](./packages/diff.cairo)
## [Diff](./src/diff.cairo)

Return the discrete difference of the elements ([see also](https://numpy.org/doc/stable/reference/generated/numpy.diff.html#numpy.diff)).
8 changes: 4 additions & 4 deletions packages/searching/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Searching

## [Boyer-Moore algorithm](./packages/bm_search.cairo)
## [Boyer-Moore algorithm](./src/bm_search.cairo)

The Boyer-Moore algorithm is a string-searching algorithm that finds the position of a pattern in a string. It preprocesses the pattern to create two lookup tables: one for the bad character rule and one for the good suffix rule. The bad character rule shifts the pattern to align with the last occurrence of the mismatched character in the pattern. The good suffix rule shifts the pattern to align with the last occurrence of the suffix of the pattern that matches the suffix of the text.

The Boyer-Moore algorithm has a best-case time complexity of O(n/m) and a worst-case time complexity of O(nm), where n is the length of the text and m is the length of the pattern. It is the most efficient string-searching algorithm in practice.

## [Binary search](./packages/binary_search.cairo)
## [Binary search](./src/binary_search.cairo)

The binary search algorithm is a simple search in an ordered array-like compound. It starts by comparing the value we are looking for to the middle of the array. If it's not a match, the function calls itself recursively on the right or left half of the array until it does(n't) find the value in the array.

## [Dijkstra](./packages/dijkstra.cairo)
## [Dijkstra](./src/dijkstra.cairo)

Dijkstra's algorithm is a graph search algorithm that finds the shortest path from a source node to all other nodes in a weighted graph, ensuring the shortest distances are progressively updated as it explores nodes. It maintains a priority queue of nodes based on their tentative distances from the source and greedily selects the node with the smallest distance at each step.

## [Levenshtein distance](./packages/levenshtein_distance.cairo)
## [Levenshtein distance](./src/levenshtein_distance.cairo)

The Levenshtein distance is a string metric for measuring the difference between two sequences. It is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other. This version of the algorithm optmizes the space complexity. Time complexity: O(nm). Space complexity: O(n),
Loading

0 comments on commit ef3292b

Please sign in to comment.