From ef3292bbd9b35218dea18876373a31bf7f18934e Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 19 Jun 2024 17:07:16 +0300 Subject: [PATCH] Fix linking issues in the docs for individual cairo files (#316) ## 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? 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 --- packages/data_structures/README.md | 10 ++++--- packages/encoding/README.md | 6 ++-- packages/linalg/README.md | 6 ++-- packages/math/README.md | 44 ++++++++++++++++++------------ packages/merkle_tree/README.md | 7 +++-- packages/numeric/README.md | 13 +++++---- packages/searching/README.md | 8 +++--- packages/sorting/README.md | 11 +++----- 8 files changed, 58 insertions(+), 47 deletions(-) diff --git a/packages/data_structures/README.md b/packages/data_structures/README.md index 1932df90..fd37500e 100644 --- a/packages/data_structures/README.md +++ b/packages/data_structures/README.md @@ -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. diff --git a/packages/encoding/README.md b/packages/encoding/README.md index 21a50753..7e292ad1 100644 --- a/packages/encoding/README.md +++ b/packages/encoding/README.md @@ -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. @@ -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); diff --git a/packages/linalg/README.md b/packages/linalg/README.md index c6495f82..97fd4548 100644 --- a/packages/linalg/README.md +++ b/packages/linalg/README.md @@ -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)). diff --git a/packages/math/README.md b/packages/math/README.md index 62fc528e..2620647a 100644 --- a/packages/math/README.md +++ b/packages/math/README.md @@ -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. diff --git a/packages/merkle_tree/README.md b/packages/merkle_tree/README.md index 3824025a..d88e1e19 100644 --- a/packages/merkle_tree/README.md +++ b/packages/merkle_tree/README.md @@ -1,6 +1,6 @@ # 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. @@ -8,5 +8,6 @@ The Merkle tree algorithm is also used in creating digital signatures and verify 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)). \ No newline at end of file +## [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)). diff --git a/packages/numeric/README.md b/packages/numeric/README.md index 8874c135..3ad850ec 100644 --- a/packages/numeric/README.md +++ b/packages/numeric/README.md @@ -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]()). -## [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)). diff --git a/packages/searching/README.md b/packages/searching/README.md index 559a6851..6b5f05c3 100644 --- a/packages/searching/README.md +++ b/packages/searching/README.md @@ -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), diff --git a/packages/sorting/README.md b/packages/sorting/README.md index bdec4754..4f734ddb 100644 --- a/packages/sorting/README.md +++ b/packages/sorting/README.md @@ -1,6 +1,6 @@ # Sorting -## [Quick Sort](./packages/quick_sort.cairo) +## [Quick Sort](./src/quick_sort.cairo) The Quick Sort algorithm is an efficient sorting algorithm used to sort a list of elements. It operates by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then recursively sorted. @@ -10,18 +10,16 @@ The time complexity of the Quick Sort algorithm on average is O(n log n), but in The space complexity of the algorithm is O(log n) due to the stack space required for recursion. The Quick Sort algorithm is considered one of the more efficient sorting algorithms, especially for larger lists. Its efficiency and low space complexity make it a popular choice for many sorting tasks, despite the potential for a high time complexity in the worst-case scenario. - -## [Bubble Sort](./packages/bubble_sort.cairo) +## [Bubble Sort](./src/bubble_sort.cairo) The bubble sort algorithm is a simple sorting algorithm used to sort a list of elements by repeatedly swapping adjacent elements if they are in the wrong order until the list is sorted. -The purpose of the bubble sort algorithm is to provide a basic and intuitive sorting method that is easy to understand and implement. While the algorithm has a time complexity of O(n^2), which can make it inefficient for large lists, it is useful for smaller lists and can serve as a starting point for more complex sorting algorithms. +The purpose of the bubble sort algorithm is to provide a basic and intuitive sorting method that is easy to understand and implement. While the algorithm has a time complexity of O(n^2), which can make it inefficient for large lists, it is useful for smaller lists and can serve as a starting point for more complex sorting algorithms. The time complexity of the bubble sort algorithm is O(n^2). The space complexity of the algorithm is O(1). The bubble sort algorithm is considered one of the least efficient sorting algorithms, especially for larger lists, as its time complexity makes it impractical for large datasets. However, it is still useful in some specific situations where memory usage is a concern. - -## [Merge Sort](./packages/merge_sort.cairo) +## [Merge Sort](./src/merge_sort.cairo) The merge sort algorithm is a sorting algorithm used to sort a list of elements by dividing it into smaller sub-lists, sorting those sub-lists, and then merging them back together. The purpose of the merge sort algorithm is to provide a way to efficiently sort large amounts of data. The algorithm has applications in various areas of computer science and data analysis, including database management, information retrieval, and machine learning. @@ -30,4 +28,3 @@ Additionally, the merge sort algorithm is used in programming and software devel The time complexity of the merge sort algorithm is O(n log n). The space complexity of the algorithm is O(n). The merge sort algorithm is considered one of the most efficient sorting algorithms, as it has a good balance between time and space complexity, and can efficiently handle large amounts of data. -