function_name
stringlengths
3
35
file_path
stringlengths
28
76
focal_code
stringlengths
385
27.9k
file_content
stringlengths
869
132k
language
stringclasses
1 value
function_component
dict
metadata
dict
graham_scan
Rust-master/src/geometry/graham_scan.rs
pub fn graham_scan(mut points: Vec<Point>) -> Vec<Point> { if points.len() <= 2 { return vec![]; } let min_point = points.iter().min_by(point_min).unwrap().clone(); points.retain(|p| p != &min_point); if points.is_empty() { // edge case where all the points are the same retu...
use crate::geometry::Point; use std::cmp::Ordering; fn point_min(a: &&Point, b: &&Point) -> Ordering { // Find the bottom-most point. In the case of a tie, find the left-most. if a.y == b.y { a.x.partial_cmp(&b.x).unwrap() } else { a.y.partial_cmp(&b.y).unwrap() } } // Returns a Vec of...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Point {\n pub x: f64,\n pub y: f64,\n}" ], "name": "points", ...
{ "class_name": "", "class_signature": "" }
ramer_douglas_peucker
Rust-master/src/geometry/ramer_douglas_peucker.rs
pub fn ramer_douglas_peucker(points: &[Point], epsilon: f64) -> Vec<Point> { if points.len() < 3 { return points.to_vec(); } let mut dmax = 0.0; let mut index = 0; let end = points.len() - 1; for i in 1..end { let d = perpendicular_distance(&points[i], &points[0], &points[end]);...
use crate::geometry::Point; pub fn ramer_douglas_peucker(points: &[Point], epsilon: f64) -> Vec<Point> { if points.len() < 3 { return points.to_vec(); } let mut dmax = 0.0; let mut index = 0; let end = points.len() - 1; for i in 1..end { let d = perpendicular_distance(&points[i...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Point {\n pub x: f64,\n pub y: f64,\n}" ], "name": "points", "type": "&[Point]" } ], "end_line": 27, "name": "ramer_douglas_peucker", "signature": "pub fn ramer_douglas_peucker(points: &[Point], epsilon: f...
{ "class_name": "", "class_signature": "" }
k_means
Rust-master/src/machine_learning/k_means.rs
pub fn k_means(data_points: Vec<(f64, f64)>, n_clusters: usize, max_iter: i32) -> Option<Vec<u32>> { if data_points.len() < n_clusters { return None; } let mut centroids: Vec<(f64, f64)> = Vec::new(); let mut labels: Vec<u32> = vec![0; data_points.len()]; for _ in 0..n_clusters { l...
use rand::random; fn get_distance(p1: &(f64, f64), p2: &(f64, f64)) -> f64 { let dx: f64 = p1.0 - p2.0; let dy: f64 = p1.1 - p2.1; ((dx * dx) + (dy * dy)).sqrt() } fn find_nearest(data_point: &(f64, f64), centroids: &[(f64, f64)]) -> u32 { let mut cluster: u32 = 0; for (i, c) in centroids.iter()...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "data_points", "type": "Vec<(f64, f64" } ], "end_line": 70, "name...
{ "class_name": "", "class_signature": "" }
cholesky
Rust-master/src/machine_learning/cholesky.rs
pub fn cholesky(mat: Vec<f64>, n: usize) -> Vec<f64> { if (mat.is_empty()) || (n == 0) { return vec![]; } let mut res = vec![0.0; mat.len()]; for i in 0..n { for j in 0..=i { let mut s = 0.0; for k in 0..j { s += res[i * n + k] * res[j * n + k]; ...
pub fn cholesky(mat: Vec<f64>, n: usize) -> Vec<f64> { if (mat.is_empty()) || (n == 0) { return vec![]; } let mut res = vec![0.0; mat.len()]; for i in 0..n { for j in 0..=i { let mut s = 0.0; for k in 0..j { s += res[i * n + k] * res[j * n + k]; ...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "mat", "type": "Vec<f64>" } ], "end_line": 31, "name": "cholesky"...
{ "class_name": "", "class_signature": "" }
knapsack
Rust-master/src/dynamic_programming/knapsack.rs
pub fn knapsack(capacity: usize, items: Vec<Item>) -> KnapsackSolution { let num_items = items.len(); let item_weights: Vec<usize> = items.iter().map(|item| item.weight).collect(); let item_values: Vec<usize> = items.iter().map(|item| item.value).collect(); let knapsack_matrix = generate_knapsack_matri...
//! This module provides functionality to solve the knapsack problem using dynamic programming. //! It includes structures for items and solutions, and functions to compute the optimal solution. use std::cmp::Ordering; /// Represents an item with a weight and a value. #[derive(Debug, PartialEq, Eq)] pub struct Item {...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Item {\n weight: usize,\n value: usize,\n}" ], "name": "items", ...
{ "class_name": "", "class_signature": "" }
minimum_cost_path
Rust-master/src/dynamic_programming/minimum_cost_path.rs
pub fn minimum_cost_path(matrix: Vec<Vec<usize>>) -> Result<usize, MatrixError> { // Check if the matrix is rectangular if !matrix.iter().all(|row| row.len() == matrix[0].len()) { return Err(MatrixError::NonRectangularMatrix); } // Check if the matrix is empty or contains empty rows if matr...
use std::cmp::min; /// Represents possible errors that can occur when calculating the minimum cost path in a matrix. #[derive(Debug, PartialEq, Eq)] pub enum MatrixError { /// Error indicating that the matrix is empty or has empty rows. EmptyMatrix, /// Error indicating that the matrix is not rectangular i...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = G...
{ "class_name": "", "class_signature": "" }
fractional_knapsack
Rust-master/src/dynamic_programming/fractional_knapsack.rs
pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values: Vec<f64>) -> f64 { // vector of tuple of weights and their value/weight ratio let mut weights: Vec<(f64, f64)> = weights .iter() .zip(values.iter()) .map(|(&w, &v)| (w, v / w)) .collect(); // sort in de...
pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values: Vec<f64>) -> f64 { // vector of tuple of weights and their value/weight ratio let mut weights: Vec<(f64, f64)> = weights .iter() .zip(values.iter()) .map(|(&w, &v)| (w, v / w)) .collect(); // sort in de...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "weights", "type": "Vec<f64>" }, { "definitions": [ "...
{ "class_name": "", "class_signature": "" }
dutch_national_flag_sort
Rust-master/src/sorting/dutch_national_flag_sort.rs
pub fn dutch_national_flag_sort(mut sequence: Vec<Colors>) -> Vec<Colors> { // We take ownership of `sequence` because the original `sequence` will be modified and then returned let length = sequence.len(); if length <= 1 { return sequence; // Arrays of length 0 or 1 are automatically sorted } ...
/* A Rust implementation of the Dutch National Flag sorting algorithm. Reference implementation: https://github.com/TheAlgorithms/Python/blob/master/sorts/dutch_national_flag_sort.py More info: https://en.wikipedia.org/wiki/Dutch_national_flag_problem */ #[derive(PartialOrd, PartialEq, Eq)] pub enum Colors { Red,...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub enum Colors {\n Red, // \\\n White, // | Define the three colors of the Dutch Fla...
{ "class_name": "", "class_signature": "" }
dijkstra
Rust-master/src/graph/dijkstra.rs
pub fn dijkstra( graph: &Graph<V, E>, start: V, ) -> BTreeMap<V, Option<(V, E)>> { let mut ans = BTreeMap::new(); let mut prio = BTreeSet::new(); // start is the special case that doesn't have a predecessor ans.insert(start, None); for (new, weight) in &graph[&start] { ans.insert(*...
use std::collections::{BTreeMap, BTreeSet}; use std::ops::Add; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; // performs Dijsktra's algorithm on the given graph from the given start // the graph is a positively-weighted directed graph // // returns a map that for each reachable vertex associates the distance and th...
rust
{ "argument_definitions": [ { "definitions": [ ") -> BTreeMap<V, Option<(V, E)>> {\n let mut ans = BTreeMap::new();\n let mut prio = BTreeSet::new();\n\n // start is the special case that doesn't have a predecessor\n ans.insert(start, None);\n\n for (new, weight) in &graph[&start] {\n...
{ "class_name": "", "class_signature": "" }
astar
Rust-master/src/graph/astar.rs
pub fn astar( graph: &Graph<V, E>, start: V, target: V, heuristic: impl Fn(V) -> E, ) -> Option<(E, Vec<V>)> { // traversal front let mut queue = BinaryHeap::new(); // maps each node to its predecessor in the final path let mut previous = BTreeMap::new(); // weights[v] is the accumul...
use std::{ collections::{BTreeMap, BinaryHeap}, ops::Add, }; use num_traits::Zero; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; #[derive(Clone, Debug, Eq, PartialEq)] struct Candidate<V, E> { estimated_weight: E, real_weight: E, state: V, } impl<V: Ord + Copy, E: Ord + Copy> PartialOrd for Ca...
rust
{ "argument_definitions": [ { "definitions": [ "struct Candidate<V, E> {\n estimated_weight: E,\n real_weight: E,\n state: V,\n}" ], "name": "graph", "type": "&Graph<V, E>" } ], "end_line": 99, "name": "astar", "signature": "pub fn astar(\n graph: &Graph<V, ...
{ "class_name": "", "class_signature": "" }
ford_fulkerson
Rust-master/src/graph/ford_fulkerson.rs
pub fn ford_fulkerson( graph: &[Vec<usize>], source: usize, sink: usize, ) -> Result<usize, FordFulkersonError> { validate_ford_fulkerson_input(graph, source, sink)?; let mut residual_graph = graph.to_owned(); let mut parent = vec![usize::MAX; graph.len()]; let mut max_flow = 0; while ...
//! The Ford-Fulkerson algorithm is a widely used algorithm to solve the maximum flow problem in a flow network. //! //! The maximum flow problem involves determining the maximum amount of flow that can be sent from a source vertex to a sink vertex //! in a directed weighted graph, subject to capacity constraints on th...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "graph", "type": "&[Vec<usize>]" } ], "end_line": 140, "name": "f...
{ "class_name": "", "class_signature": "" }
breadth_first_search
Rust-master/src/graph/breadth_first_search.rs
pub fn breadth_first_search(graph: &Graph, root: Node, target: Node) -> Option<Vec<u32>> { let mut visited: HashSet<Node> = HashSet::new(); let mut history: Vec<u32> = Vec::new(); let mut queue = VecDeque::new(); visited.insert(root); queue.push_back(root); while let Some(currentnode) = queue.p...
use std::collections::HashSet; use std::collections::VecDeque; /// Perform a breadth-first search on Graph `graph`. /// /// # Parameters /// /// - `graph`: The graph to search. /// - `root`: The starting node of the graph from which to begin searching. /// - `target`: The target node for the search. /// /// # Returns ...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n nodes: Vec<Node>,\n edges: Vec<Edge>,\n}" ], "name": "graph", "type": "&Graph" }, { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n nodes: Ve...
{ "class_name": "", "class_signature": "" }
depth_first_search
Rust-master/src/graph/depth_first_search.rs
pub fn depth_first_search(graph: &Graph, root: Vertex, objective: Vertex) -> Option<Vec<u32>> { let mut visited: HashSet<Vertex> = HashSet::new(); let mut history: Vec<u32> = Vec::new(); let mut queue = VecDeque::new(); queue.push_back(root); // While there is an element in the queue // get the...
use std::collections::HashSet; use std::collections::VecDeque; // Perform a Depth First Search Algorithm to find a element in a graph // // Return a Optional with a vector with history of vertex visiteds // or a None if the element not exists on the graph pub fn depth_first_search(graph: &Graph, root: Vertex, objectiv...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n vertices: Vec<Vertex>,\n edges: Vec<Edge>,\n}" ], "name": "graph", "type": "&Graph" }, { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n vert...
{ "class_name": "", "class_signature": "" }
manacher
Rust-master/src/string/manacher.rs
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct String {\n vec: Vec<u8>,\n}" ], "name": "s", "type": "String" } ], "end_line": 76, "name": "manacher", "signature": "pub fn manacher(s: String) -> String", "start_line": 1 }
{ "class_name": "", "class_signature": "" }
kth_smallest_heap
Rust-master/src/searching/kth_smallest_heap.rs
pub fn kth_smallest_heap(input: &[T], k: usize) -> Option<T> { if input.len() < k { return None; } // heap will maintain the kth smallest elements // seen so far, when new elements, E_new arrives, // it is compared with the largest element of the // current Heap E_large, which is the cu...
use crate::data_structures::Heap; use std::cmp::{Ord, Ordering}; /// Returns k-th smallest element of an array. /// Time complexity is stably O(nlog(k)) in all cases /// Extra space is required to maintain the heap, and it doesn't /// mutate the input list. /// /// It is preferrable to the partition-based algorithm in...
rust
{ "argument_definitions": [], "end_line": 52, "name": "kth_smallest_heap", "signature": "pub fn kth_smallest_heap(input: &[T], k: usize) -> Option<T>", "start_line": 13 }
{ "class_name": "", "class_signature": "" }
compute_totient
Rust-master/src/number_theory/compute_totient.rs
pub fn compute_totient(n: i32) -> vec::Vec<i32> { let mut phi: Vec<i32> = Vec::new(); // initialize phi[i] = i for i in 0..=n { phi.push(i); } // Compute other Phi values for p in 2..=n { // If phi[p] is not computed already, // then number p is prime if phi[(p)...
// Totient function for // all numbers smaller than // or equal to n. // Computes and prints // totient of all numbers // smaller than or equal to n use std::vec; pub fn compute_totient(n: i32) -> vec::Vec<i32> { let mut phi: Vec<i32> = Vec::new(); // initialize phi[i] = i for i in 0..=n { phi.p...
rust
{ "argument_definitions": [], "end_line": 37, "name": "compute_totient", "signature": "pub fn compute_totient(n: i32) -> vec::Vec<i32>", "start_line": 11 }
{ "class_name": "", "class_signature": "" }
fast_factorial
Rust-master/src/big_integer/fast_factorial.rs
pub fn fast_factorial(n: usize) -> BigUint { if n < 2 { return BigUint::one(); } // get list of primes that will be factors of n! let primes = sieve_of_eratosthenes(n); // Map the primes with their index let p_indices = primes .into_iter() .map(|p| (p, index(p, n))) ...
// Algorithm created by Peter Borwein in 1985 // https://doi.org/10.1016/0196-6774(85)90006-9 use crate::math::sieve_of_eratosthenes; use num_bigint::BigUint; use num_traits::One; use std::collections::BTreeMap; /// Calculate the sum of n / p^i with integer division for all values of i fn index(p: usize, n: usize) ->...
rust
{ "argument_definitions": [], "end_line": 60, "name": "fast_factorial", "signature": "pub fn fast_factorial(n: usize) -> BigUint", "start_line": 25 }
{ "class_name": "", "class_signature": "" }
transposition
Rust-master/src/ciphers/transposition.rs
pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String { let key_uppercase = key.to_uppercase(); let mut cipher_msg: String = msg.to_string(); let keys: Vec<&str> = if decrypt_mode { key_uppercase.split_whitespace().rev().collect() } else { key_uppercase.split_whitespa...
//! Transposition Cipher //! //! The Transposition Cipher is a method of encryption by which a message is shifted //! according to a regular system, so that the ciphertext is a rearrangement of the //! original message. The most commonly referred to Transposition Cipher is the //! COLUMNAR TRANSPOSITION cipher, which i...
rust
{ "argument_definitions": [], "end_line": 59, "name": "transposition", "signature": "pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String", "start_line": 12 }
{ "class_name": "", "class_signature": "" }
blake2b
Rust-master/src/ciphers/blake2b.rs
pub fn blake2b(m: &[u8], k: &[u8], nn: u8) -> Vec<u8> { let kk = min(k.len(), KK_MAX); let nn = min(nn, NN_MAX); // Prevent user from giving a key that is too long let k = &k[..kk]; let dd = max(ceil(kk, BB) + ceil(m.len(), BB), 1); let mut blocks: Vec<Block> = vec![blank_block(); dd]; /...
// For specification go to https://www.rfc-editor.org/rfc/rfc7693 use std::cmp::{max, min}; use std::convert::{TryFrom, TryInto}; type Word = u64; const BB: usize = 128; const U64BYTES: usize = (u64::BITS as usize) / 8; type Block = [Word; BB / U64BYTES]; const KK_MAX: usize = 64; const NN_MAX: u8 = 64; // Array...
rust
{ "argument_definitions": [], "end_line": 206, "name": "blake2b", "signature": "pub fn blake2b(m: &[u8], k: &[u8], nn: u8) -> Vec<u8>", "start_line": 179 }
{ "class_name": "", "class_signature": "" }
decimal_to_hexadecimal
Rust-master/src/conversions/decimal_to_hexadecimal.rs
pub fn decimal_to_hexadecimal(base_num: u64) -> String { let mut num = base_num; let mut hexadecimal_num = String::new(); loop { let remainder = num % 16; let hex_char = if remainder < 10 { (remainder as u8 + b'0') as char } else { (remainder as u8 - 10 + b'A...
pub fn decimal_to_hexadecimal(base_num: u64) -> String { let mut num = base_num; let mut hexadecimal_num = String::new(); loop { let remainder = num % 16; let hex_char = if remainder < 10 { (remainder as u8 + b'0') as char } else { (remainder as u8 - 10 + b'A...
rust
{ "argument_definitions": [], "end_line": 21, "name": "decimal_to_hexadecimal", "signature": "pub fn decimal_to_hexadecimal(base_num: u64) -> String", "start_line": 1 }
{ "class_name": "", "class_signature": "" }
area_under_curve
Rust-master/src/math/area_under_curve.rs
pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 { assert!(step_count > 0); let (start, end) = if start > end { (end, start) } else { (start, end) }; //swap if bounds reversed let step_length: f64 = (end - start) / step_count as f64; ...
pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 { assert!(step_count > 0); let (start, end) = if start > end { (end, start) } else { (start, end) }; //swap if bounds reversed let step_length: f64 = (end - start) / step_count as f64; ...
rust
{ "argument_definitions": [ { "definitions": [ "pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 {\n assert!(step_count > 0);\n\n let (start, end) = if start > end {\n (end, start)\n } else {\n (start, end)\n }; //swap if bounds ...
{ "class_name": "", "class_signature": "" }
miller_rabin
Rust-master/src/math/miller_rabin.rs
pub fn miller_rabin(number: u64, bases: &[u64]) -> u64 { // returns zero on a probable prime, and a witness if number is not prime // A base set for deterministic performance on 64 bit numbers is: // [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] // another one for 32 bits: // [2, 3, 5, 7], with small...
use num_bigint::BigUint; use num_traits::{One, ToPrimitive, Zero}; use std::cmp::Ordering; fn modulo_power(mut base: u64, mut power: u64, modulo: u64) -> u64 { base %= modulo; if base == 0 { return 0; // return zero if base is divisible by modulo } let mut ans: u128 = 1; let mut bbase: u128...
rust
{ "argument_definitions": [], "end_line": 65, "name": "miller_rabin", "signature": "pub fn miller_rabin(number: u64, bases: &[u64]) -> u64", "start_line": 38 }
{ "class_name": "", "class_signature": "" }
bell_number
Rust-master/src/math/bell_numbers.rs
pub fn bell_number(n: u32) -> BigUint { let needs_resize; // Check if number is already in lookup table { let lookup_table = LOOKUP_TABLE_LOCK.read().unwrap(); if let Some(entry) = lookup_table.get(n as usize) { return entry; } needs_resize = (n + 1) as usize >...
use num_bigint::BigUint; use num_traits::{One, Zero}; use std::sync::RwLock; /// Returns the number of ways you can select r items given n options fn n_choose_r(n: u32, r: u32) -> BigUint { if r == n || r == 0 { return One::one(); } if r > n { return Zero::zero(); } // Any combina...
rust
{ "argument_definitions": [], "end_line": 101, "name": "bell_number", "signature": "pub fn bell_number(n: u32) -> BigUint", "start_line": 69 }
{ "class_name": "", "class_signature": "" }
least_square_approx
Rust-master/src/math/least_square_approx.rs
pub fn least_square_approx( points: &[(T, U)], degree: i32, ) -> Option<Vec<f64>> { use nalgebra::{DMatrix, DVector}; /* Used for rounding floating numbers */ fn round_to_decimals(value: f64, decimals: i32) -> f64 { let multiplier = 10f64.powi(decimals); (value * multiplier).round()...
/// Least Square Approximation <p> /// Function that returns a polynomial which very closely passes through the given points (in 2D) /// /// The result is made of coeficients, in descending order (from x^degree to free term) /// /// Parameters: /// /// points -> coordinates of given points /// /// degree -> degree of t...
rust
{ "argument_definitions": [], "end_line": 56, "name": "least_square_approx", "signature": "pub fn least_square_approx(\n points: &[(T, U)],\n degree: i32,\n) -> Option<Vec<f64>>", "start_line": 12 }
{ "class_name": "", "class_signature": "" }
modular_exponential
Rust-master/src/math/modular_exponential.rs
pub fn modular_exponential(base: i64, mut power: i64, modulus: i64) -> i64 { if modulus == 1 { return 0; // Base case: any number modulo 1 is 0 } // Adjust if the exponent is negative by finding the modular inverse let mut base = if power < 0 { mod_inverse(base, modulus) } else { ...
/// Calculate the greatest common divisor (GCD) of two numbers and the /// coefficients of Bézout's identity using the Extended Euclidean Algorithm. /// /// # Arguments /// /// * `a` - One of the numbers to find the GCD of /// * `m` - The other number to find the GCD of /// /// # Returns /// /// A tuple (gcd, x1, x2) s...
rust
{ "argument_definitions": [], "end_line": 84, "name": "modular_exponential", "signature": "pub fn modular_exponential(base: i64, mut power: i64, modulus: i64) -> i64", "start_line": 60 }
{ "class_name": "", "class_signature": "" }
prime_factors
Rust-master/src/math/prime_factors.rs
pub fn prime_factors(n: u64) -> Vec<u64> { let mut i = 2; let mut n = n; let mut factors = Vec::new(); while i * i <= n { if n % i != 0 { if i != 2 { i += 1; } i += 1; } else { n /= i; factors.push(i); } ...
// Finds the prime factors of a number in increasing order, with repetition. pub fn prime_factors(n: u64) -> Vec<u64> { let mut i = 2; let mut n = n; let mut factors = Vec::new(); while i * i <= n { if n % i != 0 { if i != 2 { i += 1; } i += 1...
rust
{ "argument_definitions": [], "end_line": 22, "name": "prime_factors", "signature": "pub fn prime_factors(n: u64) -> Vec<u64>", "start_line": 3 }
{ "class_name": "", "class_signature": "" }
baby_step_giant_step
Rust-master/src/math/baby_step_giant_step.rs
pub fn baby_step_giant_step(a: usize, b: usize, n: usize) -> Option<usize> { if greatest_common_divisor::greatest_common_divisor_stein(a as u64, n as u64) != 1 { return None; } let mut h_map = HashMap::new(); let m = (n as f64).sqrt().ceil() as usize; // baby step let mut step = 1; ...
use crate::math::greatest_common_divisor; /// Baby-step Giant-step algorithm /// /// Solving discrete logarithm problem: /// a^x = b (mod n) , with respect to gcd(a, n) == 1 /// with O(sqrt(n)) time complexity. /// /// Wikipedia reference: https://en.wikipedia.org/wiki/Baby-step_giant-step /// When a is the primiti...
rust
{ "argument_definitions": [], "end_line": 35, "name": "baby_step_giant_step", "signature": "pub fn baby_step_giant_step(a: usize, b: usize, n: usize) -> Option<usize>", "start_line": 13 }
{ "class_name": "", "class_signature": "" }
trial_division
Rust-master/src/math/trial_division.rs
pub fn trial_division(mut num: i128) -> Vec<i128> { if num < 0 { return trial_division(-num); } let mut result: Vec<i128> = vec![]; if num == 0 { return result; } while num % 2 == 0 { result.push(2); num /= 2; num = double_to_int(floor(num as f64, 0)) ...
fn floor(value: f64, scale: u8) -> f64 { let multiplier = 10i64.pow(scale as u32) as f64; (value * multiplier).floor() } fn double_to_int(amount: f64) -> i128 { amount.round() as i128 } pub fn trial_division(mut num: i128) -> Vec<i128> { if num < 0 { return trial_division(-num); } let ...
rust
{ "argument_definitions": [], "end_line": 41, "name": "trial_division", "signature": "pub fn trial_division(mut num: i128) -> Vec<i128>", "start_line": 10 }
{ "class_name": "", "class_signature": "" }
zellers_congruence_algorithm
Rust-master/src/math/zellers_congruence_algorithm.rs
pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String { let q = date; let (m, y) = if month < 3 { (month + 12, year - 1) } else { (month, year) }; let day: i32 = (q + (26 * (m + 1) / 10) + (y % 100) + ((y % 100) / 4) + ((y / 100) / 4...
// returns the day of the week from the Gregorian Date pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String { let q = date; let (m, y) = if month < 3 { (month + 12, year - 1) } else { (month, year) }; let day: i32 = (q + (26 * (m +...
rust
{ "argument_definitions": [], "end_line": 27, "name": "zellers_congruence_algorithm", "signature": "pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String", "start_line": 3 }
{ "class_name": "", "class_signature": "" }
prime_numbers
Rust-master/src/math/prime_numbers.rs
pub fn prime_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); if max >= 2 { result.push(2) } for i in (3..=max).step_by(2) { let stop: usize = (i as f64).sqrt() as usize + 1; let mut status = true; for j in (3..stop).step_by(2) { ...
pub fn prime_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); if max >= 2 { result.push(2) } for i in (3..=max).step_by(2) { let stop: usize = (i as f64).sqrt() as usize + 1; let mut status = true; for j in (3..stop).step_by(2) { ...
rust
{ "argument_definitions": [], "end_line": 23, "name": "prime_numbers", "signature": "pub fn prime_numbers(max: usize) -> Vec<usize>", "start_line": 1 }
{ "class_name": "", "class_signature": "" }
contains_cell
alacritty-master/alacritty_terminal/src/selection.rs
pub fn contains_cell( &self, indexed: &Indexed<&Cell>, point: Point, shape: CursorShape, ) -> bool { // Do not invert block cursor at selection boundaries. if shape == CursorShape::Block && point == indexed.point && (self.start == indexed.point...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Indexed<T> {\n pub point: Point,\n pub cell: T,\n}", "pub struct Cell {\n pub c: char,\n pub fg: Color,\n pub bg: Color,\n pub flags: Flags,\n pub extra: Option<Arc<CellExtra>>,\n}" ], "name": "indexe...
{ "class_name": "impl SelectionRange {\n /// Check if a point lies within the selection.\n pub fn contains(&self, point: Point) -> bool {\n self.start.line <= point.line\n && self.end.line >= point.line\n && (self.start.column <= point.column\n || (self.start.line != ...
rotate
alacritty-master/alacritty_terminal/src/selection.rs
pub fn rotate( mut self, dimensions: &D, range: &Range<Line>, delta: i32, ) -> Option<Selection> { let bottommost_line = dimensions.bottommost_line(); let range_bottom = range.end; let range_top = range.start; let (mut start, mut end) = (&mut self.reg...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Range<Idx> {\n /// The lower bound of the range (inclusive).\n #[stable(feature = \"rust1\", since = \"1.0.0\")]\n pub start: Idx,\n /// The upper bound of the range (exclusive).\n #[stable(feature = \"rust1\", since = \"1.0.0...
{ "class_name": "impl Selection {\n pub fn new(ty: SelectionType, location: Point, side: Side) -> Selection {\n Self {\n region: Range { start: Anchor::new(location, side), end: Anchor::new(location, side) },\n ty,\n }\n }\n\n /// Update the end of the selection.\n pub ...
intersects_range
alacritty-master/alacritty_terminal/src/selection.rs
pub fn intersects_range(&self, range: R) -> bool { let mut start = self.region.start.point.line; let mut end = self.region.end.point.line; if start > end { mem::swap(&mut start, &mut end); } let range_top = match range.start_bound() { Bound::Included(&ra...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [], "end_line": 249, "name": "intersects_range", "signature": "pub fn intersects_range(&self, range: R) -> bool", "start_line": 228 }
{ "class_name": "impl Selection {\n pub fn new(ty: SelectionType, location: Point, side: Side) -> Selection {\n Self {\n region: Range { start: Anchor::new(location, side), end: Anchor::new(location, side) },\n ty,\n }\n }\n\n /// Update the end of the selection.\n pub ...
range_semantic
alacritty-master/alacritty_terminal/src/selection.rs
fn range_semantic(term: &Term<T>, mut start: Point, mut end: Point) -> SelectionRange { if start == end { if let Some(matching) = term.bracket_search(start) { if (matching.line == start.line && matching.column < start.column) || (matching.line < start.line) ...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "impl Selection {\n pub fn new(ty: SelectionType, location: Point, side: Side) -> Selection {\n Self {\n region: Range { start: Anchor::new(location, side), end: Anchor::new(location, side) },\n ty,\n }\n }\n\n /// Update the end of the selection.\n pub ...
range_simple
alacritty-master/alacritty_terminal/src/selection.rs
fn range_simple( &self, mut start: Anchor, mut end: Anchor, columns: usize, ) -> Option<SelectionRange> { if self.is_empty() { return None; } // Remove last cell if selection ends to the left of a cell. if end.side == Side::Left && start.p...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [ { "definitions": [ "struct Anchor {\n point: Point,\n side: Side,\n}" ], "name": "start", "type": "Anchor" }, { "definitions": [ "struct Anchor {\n point: Point,\n side: Side,\n}" ], "name": "end", "typ...
{ "class_name": "impl Selection {\n pub fn new(ty: SelectionType, location: Point, side: Side) -> Selection {\n Self {\n region: Range { start: Anchor::new(location, side), end: Anchor::new(location, side) },\n ty,\n }\n }\n\n /// Update the end of the selection.\n pub ...
range_block
alacritty-master/alacritty_terminal/src/selection.rs
fn range_block(&self, mut start: Anchor, mut end: Anchor) -> Option<SelectionRange> { if self.is_empty() { return None; } // Always go top-left -> bottom-right. if start.point.column > end.point.column { mem::swap(&mut start.side, &mut end.side); mem:...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
rust
{ "argument_definitions": [ { "definitions": [ "struct Anchor {\n point: Point,\n side: Side,\n}" ], "name": "start", "type": "Anchor" }, { "definitions": [ "struct Anchor {\n point: Point,\n side: Side,\n}" ], "name": "end", "typ...
{ "class_name": "impl Selection {\n pub fn new(ty: SelectionType, location: Point, side: Side) -> Selection {\n Self {\n region: Range { start: Anchor::new(location, side), end: Anchor::new(location, side) },\n ty,\n }\n }\n\n /// Update the end of the selection.\n pub ...
motion
alacritty-master/alacritty_terminal/src/vi_mode.rs
pub fn motion(mut self, term: &mut Term<T>, motion: ViMotion) -> Self { match motion { ViMotion::Up => { if self.point.line > term.topmost_line() { self.point.line -= 1; } }, ViMotion::Down => { if self.point...
use std::cmp::min; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::event::EventListener; use crate::grid::{Dimensions, GridCell}; use crate::index::{Boundary, Column, Direction, Line, Point, Side}; use crate::term::cell::Flags; use crate::term::Term; /// Possible vi mode motion movements. #...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "impl ViModeCursor {\n pub fn new(point: Point) -> Self {\n Self { point }\n }\n\n /// Move vi mode cursor.\n #[must_use = \"this returns the result of the operation, without modifying the original\"]\n pub fn motion<T: EventListener>(mut self, term: &mut Term<T>, motion: ViMotio...
last
alacritty-master/alacritty_terminal/src/vi_mode.rs
fn last(term: &Term<T>, mut point: Point) -> Point { // Expand across wide cells. point = term.expand_wide(point, Direction::Right); // Find last non-empty cell in the current line. let occupied = last_occupied_in_line(term, point.line).unwrap_or_default(); if point.column < occupied.column { ...
use std::cmp::min; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::event::EventListener; use crate::grid::{Dimensions, GridCell}; use crate::index::{Boundary, Column, Direction, Line, Point, Side}; use crate::term::cell::Flags; use crate::term::Term; /// Possible vi mode motion movements. #...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
first_occupied
alacritty-master/alacritty_terminal/src/vi_mode.rs
fn first_occupied(term: &Term<T>, mut point: Point) -> Point { let last_column = term.last_column(); // Expand left across wide chars, since we're searching lines left to right. point = term.expand_wide(point, Direction::Left); // Find first non-empty cell in current line. let occupied = first_occ...
use std::cmp::min; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::event::EventListener; use crate::grid::{Dimensions, GridCell}; use crate::index::{Boundary, Column, Direction, Line, Point, Side}; use crate::term::cell::Flags; use crate::term::Term; /// Possible vi mode motion movements. #...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
semantic
alacritty-master/alacritty_terminal/src/vi_mode.rs
fn semantic( term: &Term<T>, mut point: Point, direction: Direction, side: Side, ) -> Point { // Expand semantically based on movement direction. let expand_semantic = |point: Point| { // Do not expand when currently on a semantic escape char. let cell = &term.grid()[point]; ...
use std::cmp::min; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::event::EventListener; use crate::grid::{Dimensions, GridCell}; use crate::index::{Boundary, Column, Direction, Line, Point, Side}; use crate::term::cell::Flags; use crate::term::Term; /// Possible vi mode motion movements. #...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
word
alacritty-master/alacritty_terminal/src/vi_mode.rs
fn word( term: &Term<T>, mut point: Point, direction: Direction, side: Side, ) -> Point { // Make sure we jump above wide chars. point = term.expand_wide(point, direction); if direction == side { // Skip whitespace until right before a word. let mut next_point = advance(term...
use std::cmp::min; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::event::EventListener; use crate::grid::{Dimensions, GridCell}; use crate::index::{Boundary, Column, Direction, Line, Point, Side}; use crate::term::cell::Flags; use crate::term::Term; /// Possible vi mode motion movements. #...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
grid_clamp
alacritty-master/alacritty_terminal/src/index.rs
pub fn grid_clamp(mut self, dimensions: &D, boundary: Boundary) -> Self { let last_column = dimensions.last_column(); self.column = min(self.column, last_column); let topmost_line = dimensions.topmost_line(); let bottommost_line = dimensions.bottommost_line(); match boundary { ...
//! Line and Column newtypes for strongly typed tty/grid/terminal APIs. /// Indexing types and implementations for Grid and Line. use std::cmp::{max, min, Ord, Ordering}; use std::fmt; use std::ops::{Add, AddAssign, Deref, Sub, SubAssign}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::gri...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum Boundary {\n /// Cursor's range of motion in the grid.\n ///\n /// This is equal to the viewport when the user isn't scrolled into the history.\n Cursor,\n\n /// Topmost line in history until the bottommost line in the terminal....
{ "class_name": "impl Point {\n /// Subtract a number of columns from a point.\n #[inline]\n #[must_use = \"this returns the result of the operation, without modifying the original\"]\n pub fn sub<D>(mut self, dimensions: &D, boundary: Boundary, rhs: usize) -> Self\n where\n D: Dimensions,\n ...
grid_clamp
alacritty-master/alacritty_terminal/src/index.rs
pub fn grid_clamp(self, dimensions: &D, boundary: Boundary) -> Self { match boundary { Boundary::Cursor => max(Line(0), min(dimensions.bottommost_line(), self)), Boundary::Grid => { let bottommost_line = dimensions.bottommost_line(); let topmost_line = dim...
//! Line and Column newtypes for strongly typed tty/grid/terminal APIs. /// Indexing types and implementations for Grid and Line. use std::cmp::{max, min, Ord, Ordering}; use std::fmt; use std::ops::{Add, AddAssign, Deref, Sub, SubAssign}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::gri...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum Boundary {\n /// Cursor's range of motion in the grid.\n ///\n /// This is equal to the viewport when the user isn't scrolled into the history.\n Cursor,\n\n /// Topmost line in history until the bottommost line in the terminal....
{ "class_name": "impl Line {\n /// Clamp a line to a grid boundary.\n #[must_use]\n pub fn grid_clamp<D: Dimensions>(self, dimensions: &D, boundary: Boundary) -> Self {\n match boundary {\n Boundary::Cursor => max(Line(0), min(dimensions.bottommost_line(), self)),\n Boundary::Gri...
new
alacritty-master/alacritty_terminal/src/grid/row.rs
pub fn new(columns: usize) -> Row<T> { debug_assert!(columns >= 1); let mut inner: Vec<T> = Vec::with_capacity(columns); // This is a slightly optimized version of `std::vec::Vec::resize`. unsafe { let mut ptr = inner.as_mut_ptr(); for _ in 1..columns { ...
//! Defines the Row type which makes up lines in the grid. use std::cmp::{max, min}; use std::ops::{Index, IndexMut, Range, RangeFrom, RangeFull, RangeTo, RangeToInclusive}; use std::{ptr, slice}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::grid::GridCell; use crate::index::Column; use ...
rust
{ "argument_definitions": [], "end_line": 56, "name": "new", "signature": "pub fn new(columns: usize) -> Row<T>", "start_line": 37 }
{ "class_name": "impl<T: Default> Row<T> {\n /// Create a new terminal row.\n ///\n /// Ideally the `template` should be `Copy` in all performance sensitive scenarios.\n pub fn new(columns: usize) -> Row<T> {\n debug_assert!(columns >= 1);\n\n let mut inner: Vec<T> = Vec::with_capacity(colum...
from
alacritty-master/alacritty_terminal/src/term/mod.rs
fn from(value: KeyboardModes) -> Self { let mut mode = Self::empty(); let disambiguate_esc_codes = value.contains(KeyboardModes::DISAMBIGUATE_ESC_CODES); mode.set(TermMode::DISAMBIGUATE_ESC_CODES, disambiguate_esc_codes); let report_event_types = value.contains(KeyboardModes::REPORT_EV...
//! Exports the `Term` type which is a high-level API for the Grid. use std::ops::{Index, IndexMut, Range}; use std::sync::Arc; use std::{cmp, mem, ptr, slice, str}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use base64::engine::general_purpose::STANDARD as Base64; use base64::Engine; use bitflag...
rust
{ "argument_definitions": [ { "definitions": [ " pub struct KeyboardModes : u8 {\n /// No keyboard protocol mode is set.\n const NO_MODE = 0b0000_0000;\n /// Report `Esc`, `alt` + `key`, `ctrl` + `key`, `ctrl` + `alt` + `key`, `shift`\n /// + `alt` + `k...
{ "class_name": "impl From<KeyboardModes> for TermMode {\n fn from(value: KeyboardModes) -> Self {\n let mut mode = Self::empty();\n\n let disambiguate_esc_codes = value.contains(KeyboardModes::DISAMBIGUATE_ESC_CODES);\n mode.set(TermMode::DISAMBIGUATE_ESC_CODES, disambiguate_esc_codes);\n\n ...
new
alacritty-master/alacritty_terminal/src/term/mod.rs
pub fn new(config: Config, dimensions: &D, event_proxy: T) -> Term<T> { let num_cols = dimensions.columns(); let num_lines = dimensions.screen_lines(); let history_size = config.scrolling_history; let grid = Grid::new(num_lines, num_cols, history_size); let inactive_grid = Grid:...
//! Exports the `Term` type which is a high-level API for the Grid. use std::ops::{Index, IndexMut, Range}; use std::sync::Arc; use std::{cmp, mem, ptr, slice, str}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use base64::engine::general_purpose::STANDARD as Base64; use base64::Engine; use bitflag...
rust
{ "argument_definitions": [], "end_line": 445, "name": "new", "signature": "pub fn new(config: Config, dimensions: &D, event_proxy: T) -> Term<T>", "start_line": 410 }
{ "class_name": "impl<T> Term<T> {\n #[inline]\n pub fn scroll_display(&mut self, scroll: Scroll)\n where\n T: EventListener,\n {\n let old_display_offset = self.grid.display_offset();\n self.grid.scroll_display(scroll);\n self.event_proxy.send_event(Event::MouseCursorDirty);\n...
line_to_string
alacritty-master/alacritty_terminal/src/term/mod.rs
fn line_to_string( &self, line: Line, mut cols: Range<Column>, include_wrapped_wide: bool, ) -> String { let mut text = String::new(); let grid_line = &self.grid[line]; let line_length = cmp::min(grid_line.line_length(), cols.end + 1); // Include wid...
//! Exports the `Term` type which is a high-level API for the Grid. use std::ops::{Index, IndexMut, Range}; use std::sync::Arc; use std::{cmp, mem, ptr, slice, str}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use base64::engine::general_purpose::STANDARD as Base64; use base64::Engine; use bitflag...
rust
{ "argument_definitions": [ { "definitions": [ "impl Line {\n /// Clamp a line to a grid boundary.\n #[must_use]\n pub fn grid_clamp<D: Dimensions>(self, dimensions: &D, boundary: Boundary) -> Self {\n match boundary {\n Boundary::Cursor => max(Line(0), min(dimensions.bott...
{ "class_name": "impl<T> Term<T> {\n #[inline]\n pub fn scroll_display(&mut self, scroll: Scroll)\n where\n T: EventListener,\n {\n let old_display_offset = self.grid.display_offset();\n self.grid.scroll_display(scroll);\n self.event_proxy.send_event(Event::MouseCursorDirty);\n...
expand_wide
alacritty-master/alacritty_terminal/src/term/mod.rs
pub fn expand_wide(&self, mut point: Point, direction: Direction) -> Point { let flags = self.grid[point.line][point.column].flags; match direction { Direction::Right if flags.contains(Flags::LEADING_WIDE_CHAR_SPACER) => { point.column = Column(1); point.line...
//! Exports the `Term` type which is a high-level API for the Grid. use std::ops::{Index, IndexMut, Range}; use std::sync::Arc; use std::{cmp, mem, ptr, slice, str}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use base64::engine::general_purpose::STANDARD as Base64; use base64::Engine; use bitflag...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Point<L = Line, C = Column> {\n pub line: L,\n pub column: C,\n}" ], "name": "point", "type": "Point" }, { "definitions": [ "pub enum Direction {\n Left,\n Right,\n}" ], "name":...
{ "class_name": "impl<T> Term<T> {\n #[inline]\n pub fn scroll_display(&mut self, scroll: Scroll)\n where\n T: EventListener,\n {\n let old_display_offset = self.grid.display_offset();\n self.grid.scroll_display(scroll);\n self.event_proxy.send_event(Event::MouseCursorDirty);\n...
next_match_right
alacritty-master/alacritty_terminal/src/term/search.rs
fn next_match_right( &self, regex: &mut RegexSearch, origin: Point, side: Side, max_lines: Option<usize>, ) -> Option<Match> { let start = self.line_search_left(origin); let mut end = start; // Limit maximum number of lines searched. end = mat...
use std::cmp::max; use std::error::Error; use std::mem; use std::ops::RangeInclusive; use log::{debug, warn}; use regex_automata::hybrid::dfa::{Builder, Cache, Config, DFA}; pub use regex_automata::hybrid::BuildError; use regex_automata::nfa::thompson::Config as ThompsonConfig; use regex_automata::util::syntax::Config...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct RegexSearch {\n left_fdfa: LazyDfa,\n left_rdfa: LazyDfa,\n right_rdfa: LazyDfa,\n right_fdfa: LazyDfa,\n}" ], "name": "regex", "type": "&mut RegexSearch" }, { "definitions": [ "pub struct ...
{ "class_name": "impl<T> Term<T> {\n /// Get next search match in the specified direction.\n pub fn search_next(\n &self,\n regex: &mut RegexSearch,\n mut origin: Point,\n direction: Direction,\n side: Side,\n mut max_lines: Option<usize>,\n ) -> Option<Match> {\n ...
next_match_left
alacritty-master/alacritty_terminal/src/term/search.rs
fn next_match_left( &self, regex: &mut RegexSearch, origin: Point, side: Side, max_lines: Option<usize>, ) -> Option<Match> { let start = self.line_search_right(origin); let mut end = start; // Limit maximum number of lines searched. end = mat...
use std::cmp::max; use std::error::Error; use std::mem; use std::ops::RangeInclusive; use log::{debug, warn}; use regex_automata::hybrid::dfa::{Builder, Cache, Config, DFA}; pub use regex_automata::hybrid::BuildError; use regex_automata::nfa::thompson::Config as ThompsonConfig; use regex_automata::util::syntax::Config...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct RegexSearch {\n left_fdfa: LazyDfa,\n left_rdfa: LazyDfa,\n right_rdfa: LazyDfa,\n right_fdfa: LazyDfa,\n}" ], "name": "regex", "type": "&mut RegexSearch" }, { "definitions": [ "pub struct ...
{ "class_name": "impl<T> Term<T> {\n /// Get next search match in the specified direction.\n pub fn search_next(\n &self,\n regex: &mut RegexSearch,\n mut origin: Point,\n direction: Direction,\n side: Side,\n mut max_lines: Option<usize>,\n ) -> Option<Match> {\n ...
bracket_search
alacritty-master/alacritty_terminal/src/term/search.rs
pub fn bracket_search(&self, point: Point) -> Option<Point> { let start_char = self.grid[point].c; // Find the matching bracket we're looking for let (forward, end_char) = BRACKET_PAIRS.iter().find_map(|(open, close)| { if open == &start_char { Some((true, *close)) ...
use std::cmp::max; use std::error::Error; use std::mem; use std::ops::RangeInclusive; use log::{debug, warn}; use regex_automata::hybrid::dfa::{Builder, Cache, Config, DFA}; pub use regex_automata::hybrid::BuildError; use regex_automata::nfa::thompson::Config as ThompsonConfig; use regex_automata::util::syntax::Config...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Point<L = Line, C = Column> {\n pub line: L,\n pub column: C,\n}" ], "name": "point", "type": "Point" } ], "end_line": 513, "name": "bracket_search", "signature": "pub fn bracket_search(&self, point: Point...
{ "class_name": "impl<T> Term<T> {\n /// Get next search match in the specified direction.\n pub fn search_next(\n &self,\n regex: &mut RegexSearch,\n mut origin: Point,\n direction: Direction,\n side: Side,\n mut max_lines: Option<usize>,\n ) -> Option<Match> {\n ...
new
alacritty-master/alacritty/src/string.rs
pub fn new( text: &'a str, max_width: usize, direction: ShortenDirection, mut shortener: Option<char>, ) -> Self { if text.is_empty() { // If we don't have any text don't produce a shortener for it. let _ = shortener.take(); } if direc...
use std::cmp::Ordering; use std::iter::Skip; use std::str::Chars; use unicode_width::UnicodeWidthChar; /// The action performed by [`StrShortener`]. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TextAction { /// Yield a spacer. Spacer, /// Terminate state reached. Terminate, /// Yield a sh...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum ShortenDirection {\n /// Shorten to the start of the string.\n Left,\n\n /// Shorten to the end of the string.\n Right,\n}" ], "name": "direction", "type": "ShortenDirection" }, { "definitions": [ ...
{ "class_name": "impl<'a> StrShortener<'a> {\n pub fn new(\n text: &'a str,\n max_width: usize,\n direction: ShortenDirection,\n mut shortener: Option<char>,\n ) -> Self {\n if text.is_empty() {\n // If we don't have any text don't produce a shortener for it.\n ...
new
alacritty-master/alacritty/src/event.rs
pub fn new( config: UiConfig, cli_options: CliOptions, event_loop: &EventLoop<Event>, ) -> Processor { let proxy = event_loop.create_proxy(); let scheduler = Scheduler::new(proxy.clone()); let initial_window_options = Some(cli_options.window_options.clone()); ...
//! Process window events. use crate::ConfigMonitor; use glutin::config::GetGlConfig; use std::borrow::Cow; use std::cmp::min; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet, VecDeque}; use std::error::Error; use std::ffi::OsStr; use std::fmt::Debug; #[cfg(not(windows))] use std::os::un...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct UiConfig {\n /// Miscellaneous configuration options.\n pub general: General,\n\n /// Extra environment variables.\n pub env: HashMap<String, String>,\n\n /// How much scrolling history to keep.\n pub scrolling: Scrolling,\...
{ "class_name": "impl Processor {\n /// Create a new event processor.\n pub fn new(\n config: UiConfig,\n cli_options: CliOptions,\n event_loop: &EventLoop<Event>,\n ) -> Processor {\n let proxy = event_loop.create_proxy();\n let scheduler = Scheduler::new(proxy.clone());\n...
semantic_word
alacritty-master/alacritty/src/event.rs
fn semantic_word(&self, point: Point) -> String { let terminal = self.terminal(); let grid = terminal.grid(); // Find the next semantic word boundary to the right. let mut end = terminal.semantic_search_right(point); // Get point at which skipping over semantic characters has l...
//! Process window events. use crate::ConfigMonitor; use glutin::config::GetGlConfig; use std::borrow::Cow; use std::cmp::min; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet, VecDeque}; use std::error::Error; use std::ffi::OsStr; use std::fmt::Debug; #[cfg(not(windows))] use std::os::un...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Point<L = Line, C = Column> {\n pub line: L,\n pub column: C,\n}" ], "name": "point", "type": "Point" } ], "end_line": 1314, "name": "semantic_word", "signature": "fn semantic_word(&self, point: Point) -> ...
{ "class_name": "impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionContext<'a, N, T> {\n #[inline]\n fn write_to_pty<B: Into<Cow<'static, [u8]>>>(&self, val: B) {\n self.notifier.notify(val);\n }\n\n /// Request a redraw.\n #[inline]\n fn mark_dirty(&mut self) {\n ...
create_log_message
alacritty-master/alacritty/src/logging.rs
fn create_log_message(record: &log::Record<'_>, target: &str, start: Instant) -> String { let runtime = start.elapsed(); let secs = runtime.as_secs(); let nanos = runtime.subsec_nanos(); let mut message = format!("[{}.{:0>9}s] [{:<5}] [{}] ", secs, nanos, record.level(), target); // Alignment for t...
//! Logging for Alacritty. //! //! The main executable is supposed to call `initialize()` exactly once during //! startup. All logging messages are written to stdout, given that their //! log-level is sufficient for the level configured in `cli::Options`. use std::fs::{File, OpenOptions}; use std::io::{self, LineWrite...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Record<'a> {\n metadata: Metadata<'a>,\n args: fmt::Arguments<'a>,\n module_path: Option<MaybeStaticStr<'a>>,\n file: Option<MaybeStaticStr<'a>>,\n line: Option<u32>,\n #[cfg(feature = \"kv\")]\n key_values: KeyValues<'a...
{ "class_name": "", "class_signature": "" }
get_program_info_log
alacritty-master/alacritty/src/renderer/shader.rs
fn get_program_info_log(program: GLuint) -> String { // Get expected log length. let mut max_length: GLint = 0; unsafe { gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &mut max_length); } // Read the info log. let mut actual_length: GLint = 0; let mut buf: Vec<u8> = Vec::with_capaci...
use std::ffi::CStr; use std::fmt; use crate::gl; use crate::gl::types::*; /// A wrapper for a shader program id, with automatic lifetime management. #[derive(Debug)] pub struct ShaderProgram(GLuint); #[derive(Copy, Clone, Debug)] pub enum ShaderVersion { /// OpenGL 3.3 core shaders. Glsl3, /// OpenGL ES...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum __GLsync {}" ], "name": "program", "type": "GLuint" } ], "end_line": 158, "name": "get_program_info_log", "signature": "fn get_program_info_log(program: GLuint) -> String", "start_line": 138 }
{ "class_name": "", "class_signature": "" }
get_shader_info_log
alacritty-master/alacritty/src/renderer/shader.rs
fn get_shader_info_log(shader: GLuint) -> String { // Get expected log length. let mut max_length: GLint = 0; unsafe { gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut max_length); } // Read the info log. let mut actual_length: GLint = 0; let mut buf: Vec<u8> = Vec::with_capacity(m...
use std::ffi::CStr; use std::fmt; use crate::gl; use crate::gl::types::*; /// A wrapper for a shader program id, with automatic lifetime management. #[derive(Debug)] pub struct ShaderProgram(GLuint); #[derive(Copy, Clone, Debug)] pub enum ShaderVersion { /// OpenGL 3.3 core shaders. Glsl3, /// OpenGL ES...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum __GLsync {}" ], "name": "shader", "type": "GLuint" } ], "end_line": 180, "name": "get_shader_info_log", "signature": "fn get_shader_info_log(shader: GLuint) -> String", "start_line": 160 }
{ "class_name": "", "class_signature": "" }
create_rect
alacritty-master/alacritty/src/renderer/rects.rs
fn create_rect( size: &SizeInfo, descent: f32, start: Point<usize>, end: Point<usize>, position: f32, mut thickness: f32, color: Rgb, ) -> RenderRect { let start_x = start.column.0 as f32 * size.cell_width(); let end_x = (end.column.0 + 1) as f...
use std::collections::HashMap; use std::mem; use ahash::RandomState; use crossfont::Metrics; use log::info; use alacritty_terminal::grid::Dimensions; use alacritty_terminal::index::{Column, Point}; use alacritty_terminal::term::cell::Flags; use crate::display::color::Rgb; use crate::display::content::RenderableCell;...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct SizeInfo<T = f32> {\n /// Terminal window width.\n width: T,\n\n /// Terminal window height.\n height: T,\n\n /// Width of individual cell.\n cell_width: T,\n\n /// Height of individual cell.\n cell_height: T,\n\n ...
{ "class_name": "impl RenderLine {\n pub fn rects(&self, flag: Flags, metrics: &Metrics, size: &SizeInfo) -> Vec<RenderRect> {\n let mut rects = Vec::new();\n\n let mut start = self.start;\n while start.line < self.end.line {\n let end = Point::new(start.line, size.last_column());\n...
new
alacritty-master/alacritty/src/renderer/text/atlas.rs
pub fn new(size: i32, is_gles_context: bool) -> Self { let mut id: GLuint = 0; unsafe { gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1); gl::GenTextures(1, &mut id); gl::BindTexture(gl::TEXTURE_2D, id); // Use RGBA texture for both normal and emoji glyphs, since ...
use std::borrow::Cow; use std::ptr; use crossfont::{BitmapBuffer, RasterizedGlyph}; use crate::gl; use crate::gl::types::*; use super::Glyph; /// Size of the Atlas. pub const ATLAS_SIZE: i32 = 1024; /// Manages a single texture atlas. /// /// The strategy for filling an atlas looks roughly like this: /// /// ```te...
rust
{ "argument_definitions": [], "end_line": 110, "name": "new", "signature": "pub fn new(size: i32, is_gles_context: bool) -> Self", "start_line": 73 }
{ "class_name": "impl Atlas {\n pub fn new(size: i32, is_gles_context: bool) -> Self {\n let mut id: GLuint = 0;\n unsafe {\n gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);\n gl::GenTextures(1, &mut id);\n gl::BindTexture(gl::TEXTURE_2D, id);\n // Use RGBA textu...
builtin_glyph
alacritty-master/alacritty/src/renderer/text/builtin_font.rs
pub fn builtin_glyph( character: char, metrics: &Metrics, offset: &Delta<i8>, glyph_offset: &Delta<i8>, ) -> Option<RasterizedGlyph> { let mut glyph = match character { // Box drawing characters and block elements. '\u{2500}'..='\u{259f}' | '\u{1fb00}'..='\u{1fb3b}' => { ...
//! Hand-rolled drawing of unicode characters that need to fully cover their character area. use std::{cmp, mem, ops}; use crossfont::{BitmapBuffer, Metrics, RasterizedGlyph}; use crate::config::ui_config::Delta; // Colors which are used for filling shade variants. const COLOR_FILL_ALPHA_STEP_1: Pixel = Pixel { _r:...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Metrics {\n pub average_advance: f64,\n pub line_height: f64,\n pub descent: f32,\n pub underline_position: f32,\n pub underline_thickness: f32,\n pub strikeout_position: f32,\n pub strikeout_thickness: f32,\n}" ],...
{ "class_name": "", "class_signature": "" }
box_drawing
alacritty-master/alacritty/src/renderer/text/builtin_font.rs
fn box_drawing(character: char, metrics: &Metrics, offset: &Delta<i8>) -> RasterizedGlyph { // Ensure that width and height is at least one. let height = (metrics.line_height as i32 + offset.y as i32).max(1) as usize; let width = (metrics.average_advance as i32 + offset.x as i32).max(1) as usize; let st...
//! Hand-rolled drawing of unicode characters that need to fully cover their character area. use std::{cmp, mem, ops}; use crossfont::{BitmapBuffer, Metrics, RasterizedGlyph}; use crate::config::ui_config::Delta; // Colors which are used for filling shade variants. const COLOR_FILL_ALPHA_STEP_1: Pixel = Pixel { _r:...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Metrics {\n pub average_advance: f64,\n pub line_height: f64,\n pub descent: f32,\n pub underline_position: f32,\n pub underline_thickness: f32,\n pub strikeout_position: f32,\n pub strikeout_thickness: f32,\n}" ],...
{ "class_name": "", "class_signature": "" }
powerline_drawing
alacritty-master/alacritty/src/renderer/text/builtin_font.rs
fn powerline_drawing( character: char, metrics: &Metrics, offset: &Delta<i8>, ) -> Option<RasterizedGlyph> { let height = (metrics.line_height as i32 + offset.y as i32) as usize; let width = (metrics.average_advance as i32 + offset.x as i32) as usize; let extra_thickness = calculate_stroke_size(...
//! Hand-rolled drawing of unicode characters that need to fully cover their character area. use std::{cmp, mem, ops}; use crossfont::{BitmapBuffer, Metrics, RasterizedGlyph}; use crate::config::ui_config::Delta; // Colors which are used for filling shade variants. const COLOR_FILL_ALPHA_STEP_1: Pixel = Pixel { _r:...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Metrics {\n pub average_advance: f64,\n pub line_height: f64,\n pub descent: f32,\n pub underline_position: f32,\n pub underline_thickness: f32,\n pub strikeout_position: f32,\n pub strikeout_thickness: f32,\n}" ],...
{ "class_name": "", "class_signature": "" }
get
alacritty-master/alacritty/src/renderer/text/glyph_cache.rs
pub fn get(&mut self, glyph_key: GlyphKey, loader: &mut L, show_missing: bool) -> Glyph { // Try to load glyph from cache. if let Some(glyph) = self.cache.get(&glyph_key) { return *glyph; }; // Rasterize the glyph using the built-in font for special characters or the user's ...
use std::collections::HashMap; use ahash::RandomState; use crossfont::{ Error as RasterizerError, FontDesc, FontKey, GlyphKey, Metrics, Rasterize, RasterizedGlyph, Rasterizer, Size, Slant, Style, Weight, }; use log::{error, info}; use unicode_width::UnicodeWidthChar; use crate::config::font::{Font, FontDescri...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct GlyphKey {\n pub character: char,\n pub font_key: FontKey,\n pub size: Size,\n}" ], "name": "glyph_key", "type": "GlyphKey" } ], "end_line": 245, "name": "get", "signature": "pub fn get(&mut self, glyph...
{ "class_name": "impl GlyphCache {\n pub fn new(mut rasterizer: Rasterizer, font: &Font) -> Result<GlyphCache, crossfont::Error> {\n let (regular, bold, italic, bold_italic) = Self::compute_font_keys(font, &mut rasterizer)?;\n\n let metrics = GlyphCache::load_font_metrics(&mut rasterizer, font, regul...
with_api
alacritty-master/alacritty/src/renderer/text/glsl3.rs
fn with_api(&'b mut self, size_info: &'b SizeInfo, func: F) -> T { unsafe { gl::UseProgram(self.program.id()); self.program.set_term_uniforms(size_info); gl::BindVertexArray(self.vao); gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo); gl::BindBuffer...
use std::mem::size_of; use std::ptr; use crossfont::RasterizedGlyph; use log::info; use alacritty_terminal::term::cell::Flags; use crate::display::content::RenderableCell; use crate::display::SizeInfo; use crate::gl; use crate::gl::types::*; use crate::renderer::shader::{ShaderProgram, ShaderVersion}; use crate::ren...
rust
{ "argument_definitions": [], "end_line": 184, "name": "with_api", "signature": "fn with_api(&'b mut self, size_info: &'b SizeInfo, func: F) -> T", "start_line": 153 }
{ "class_name": "impl<'a> TextRenderer<'a> for Glsl3Renderer {\n type RenderApi = RenderApi<'a>;\n type RenderBatch = Batch;\n type Shader = TextShaderProgram;\n\n fn with_api<'b: 'a, F, T>(&'b mut self, size_info: &'b SizeInfo, func: F) -> T\n where\n F: FnOnce(Self::RenderApi) -> T,\n {\n ...
with_api
alacritty-master/alacritty/src/renderer/text/gles2.rs
fn with_api(&'b mut self, _: &'b SizeInfo, func: F) -> T { unsafe { gl::UseProgram(self.program.id()); gl::BindVertexArray(self.vao); gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo); gl::BindBuffer(gl::ARRAY_BUFFER, self.vbo); gl::ActiveTexture(gl::...
use std::mem::size_of; use std::ptr; use crossfont::RasterizedGlyph; use log::info; use alacritty_terminal::term::cell::Flags; use crate::display::content::RenderableCell; use crate::display::SizeInfo; use crate::gl; use crate::gl::types::*; use crate::renderer::shader::{ShaderProgram, ShaderVersion}; use crate::ren...
rust
{ "argument_definitions": [], "end_line": 210, "name": "with_api", "signature": "fn with_api(&'b mut self, _: &'b SizeInfo, func: F) -> T", "start_line": 180 }
{ "class_name": "impl<'a> TextRenderer<'a> for Gles2Renderer {\n type RenderApi = RenderApi<'a>;\n type RenderBatch = Batch;\n type Shader = TextShaderProgram;\n\n fn program(&self) -> &Self::Shader {\n &self.program\n }\n\n fn with_api<'b: 'a, F, T>(&'b mut self, _: &'b SizeInfo, func: F) ->...
new
alacritty-master/alacritty/src/config/monitor.rs
pub fn new(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) -> Option<Self> { // Don't monitor config if there is no path to watch. if paths.is_empty() { return None; } // Calculate the hash for the unmodified list of paths. let watched_hash = Self::hash_...
use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::path::PathBuf; use std::sync::mpsc::{self, RecvTimeoutError, Sender}; use std::thread::JoinHandle; use std::time::{Duration, Instant}; use log::{debug, error, warn}; use notify::{ Config, Error as NotifyError, Event as NotifyEve...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct PathBuf {\n inner: OsString,\n}" ], "name": "paths", "type": "...
{ "class_name": "impl ConfigMonitor {\n pub fn new(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) -> Option<Self> {\n // Don't monitor config if there is no path to watch.\n if paths.is_empty() {\n return None;\n }\n\n // Calculate the hash for the unmodified li...
load_imports
alacritty-master/alacritty/src/config/mod.rs
fn load_imports( config: &Value, base_path: &Path, config_paths: &mut Vec<PathBuf>, recursion_limit: usize, ) -> Value { // Get paths for all imports. let import_paths = match imports(config, base_path, recursion_limit) { Ok(import_paths) => import_paths, Err(err) => { ...
use std::fmt::{self, Display, Formatter}; use std::path::{Path, PathBuf}; use std::result::Result as StdResult; use std::{env, fs, io}; use log::{debug, error, info, warn}; use serde::Deserialize; use serde_yaml::Error as YamlError; use toml::de::Error as TomlError; use toml::ser::Error as TomlSeError; use toml::{Tabl...
rust
{ "argument_definitions": [ { "definitions": [ "pub enum Value {\n /// Represents a TOML string\n String(String),\n /// Represents a TOML integer\n Integer(i64),\n /// Represents a TOML float\n Float(f64),\n /// Represents a TOML boolean\n Boolean(bool),\n /// Represents a...
{ "class_name": "", "class_signature": "" }
keyboard_input
alacritty-master/alacritty/src/display/hint.rs
pub fn keyboard_input(&mut self, term: &Term<T>, c: char) -> Option<HintMatch> { match c { // Use backspace to remove the last character pressed. '\x08' | '\x1f' => { self.keys.pop(); }, // Cancel hint highlighting on ESC/Ctrl+c. '\x1b'...
use std::borrow::Cow; use std::cmp::Reverse; use std::collections::HashSet; use std::iter; use std::rc::Rc; use ahash::RandomState; use winit::keyboard::ModifiersState; use alacritty_terminal::grid::{BidirectionalIterator, Dimensions}; use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point}; use ala...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "impl HintState {\n /// Initialize an inactive hint state.\n pub fn new<S: Into<String>>(alphabet: S) -> Self {\n Self {\n alphabet: alphabet.into(),\n hint: Default::default(),\n matches: Default::default(),\n labels: Default::default(),\n ...
highlighted_at
alacritty-master/alacritty/src/display/hint.rs
pub fn highlighted_at( term: &Term<T>, config: &UiConfig, point: Point, mouse_mods: ModifiersState, ) -> Option<HintMatch> { let mouse_mode = term.mode().intersects(TermMode::MOUSE_MODE); config.hints.enabled.iter().find_map(|hint| { // Check if all required modifiers are pressed. ...
use std::borrow::Cow; use std::cmp::Reverse; use std::collections::HashSet; use std::iter; use std::rc::Rc; use ahash::RandomState; use winit::keyboard::ModifiersState; use alacritty_terminal::grid::{BidirectionalIterator, Dimensions}; use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point}; use ala...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
hyperlink_at
alacritty-master/alacritty/src/display/hint.rs
fn hyperlink_at(term: &Term<T>, point: Point) -> Option<(Hyperlink, Match)> { let hyperlink = term.grid()[point].hyperlink()?; let grid = term.grid(); let mut match_end = point; for cell in grid.iter_from(point) { if cell.hyperlink().is_some_and(|link| link == hyperlink) { match_en...
use std::borrow::Cow; use std::cmp::Reverse; use std::collections::HashSet; use std::iter; use std::rc::Rc; use ahash::RandomState; use winit::keyboard::ModifiersState; use alacritty_terminal::grid::{BidirectionalIterator, Dimensions}; use alacritty_terminal::index::{Boundary, Column, Direction, Line, Point}; use ala...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "", "class_signature": "" }
intensity_at_instant
alacritty-master/alacritty/src/display/bell.rs
pub fn intensity_at_instant(&self, instant: Instant) -> f64 { // If `duration` is zero, then the VisualBell is disabled; therefore, // its `intensity` is zero. if self.duration == Duration::from_secs(0) { return 0.0; } match self.start_time { // Similarly...
use std::time::{Duration, Instant}; use crate::config::bell::{BellAnimation, BellConfig}; pub struct VisualBell { /// Visual bell animation. animation: BellAnimation, /// Visual bell duration. duration: Duration, /// The last time the visual bell rang, if at all. start_time: Option<Instant>,...
rust
{ "argument_definitions": [ { "definitions": [ "/// use std::time::{Duration, SystemTime};" ], "name": "instant", "type": "Instant" } ], "end_line": 99, "name": "intensity_at_instant", "signature": "pub fn intensity_at_instant(&self, instant: Instant) -> f64", "start_...
{ "class_name": "impl VisualBell {\n /// Ring the visual bell, and return its intensity.\n pub fn ring(&mut self) -> f64 {\n let now = Instant::now();\n self.start_time = Some(now);\n self.intensity_at_instant(now)\n }\n\n /// Get the currently intensity of the visual bell. The bell's...
new
alacritty-master/alacritty/src/display/mod.rs
pub fn new( width: f32, height: f32, cell_width: f32, cell_height: f32, mut padding_x: f32, mut padding_y: f32, dynamic_padding: bool, ) -> SizeInfo { if dynamic_padding { padding_x = Self::dynamic_padding(padding_x.floor(), width, cell_wid...
//! The display subsystem including window management, font rasterization, and //! GPU drawing. use std::cmp; use std::fmt::{self, Formatter}; use std::mem::{self, ManuallyDrop}; use std::num::NonZeroU32; use std::ops::Deref; use std::time::{Duration, Instant}; use glutin::config::GetGlConfig; use glutin::context::{N...
rust
{ "argument_definitions": [], "end_line": 261, "name": "new", "signature": "pub fn new(\n width: f32,\n height: f32,\n cell_width: f32,\n cell_height: f32,\n mut padding_x: f32,\n mut padding_y: f32,\n dynamic_padding: bool,\n ) -> SizeInfo", "start_line": 2...
{ "class_name": "impl SizeInfo<f32> {\n #[allow(clippy::too_many_arguments)]\n pub fn new(\n width: f32,\n height: f32,\n cell_width: f32,\n cell_height: f32,\n mut padding_x: f32,\n mut padding_y: f32,\n dynamic_padding: bool,\n ) -> SizeInfo {\n if dy...
update_highlighted_hints
alacritty-master/alacritty/src/display/mod.rs
pub fn update_highlighted_hints( &mut self, term: &Term<T>, config: &UiConfig, mouse: &Mouse, modifiers: ModifiersState, ) -> bool { // Update vi mode cursor hint. let vi_highlighted_hint = if term.mode().contains(TermMode::VI) { let mods = Modifie...
//! The display subsystem including window management, font rasterization, and //! GPU drawing. use std::cmp; use std::fmt::{self, Formatter}; use std::mem::{self, ManuallyDrop}; use std::num::NonZeroU32; use std::ops::Deref; use std::time::{Duration, Instant}; use glutin::config::GetGlConfig; use glutin::context::{N...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Term<T> {\n /// Terminal focus controlling the cursor shape.\n pub is_focused: bool,\n\n /// Cursor for keyboard selection.\n pub vi_mode_cursor: ViModeCursor,\n\n pub selection: Option<Selection>,\n\n /// Currently active ...
{ "class_name": "impl Display {\n pub fn new(\n window: Window,\n gl_context: NotCurrentContext,\n config: &UiConfig,\n _tabbed: bool,\n ) -> Result<Display, Error> {\n let raw_window_handle = window.raw_window_handle();\n\n let scale_factor = window.scale_factor as f32...
format_search
alacritty-master/alacritty/src/display/mod.rs
fn format_search(search_regex: &str, search_label: &str, max_width: usize) -> String { let label_len = search_label.len(); // Skip `search_regex` formatting if only label is visible. if label_len > max_width { return search_label[..max_width].to_owned(); } // The se...
//! The display subsystem including window management, font rasterization, and //! GPU drawing. use std::cmp; use std::fmt::{self, Formatter}; use std::mem::{self, ManuallyDrop}; use std::num::NonZeroU32; use std::ops::Deref; use std::time::{Duration, Instant}; use glutin::config::GetGlConfig; use glutin::context::{N...
rust
{ "argument_definitions": [], "end_line": 1237, "name": "format_search", "signature": "fn format_search(search_regex: &str, search_label: &str, max_width: usize) -> String", "start_line": 1216 }
{ "class_name": "impl Display {\n pub fn new(\n window: Window,\n gl_context: NotCurrentContext,\n config: &UiConfig,\n _tabbed: bool,\n ) -> Result<Display, Error> {\n let raw_window_handle = window.raw_window_handle();\n\n let scale_factor = window.scale_factor as f32...
compute_timeout
alacritty-master/alacritty/src/display/mod.rs
pub fn compute_timeout(&mut self, refresh_interval: Duration) -> Duration { let now = Instant::now(); // Handle refresh rate change. if self.refresh_interval != refresh_interval { self.base = now; self.last_synced_timestamp = now; self.refresh_interval = refr...
//! The display subsystem including window management, font rasterization, and //! GPU drawing. use std::cmp; use std::fmt::{self, Formatter}; use std::mem::{self, ManuallyDrop}; use std::num::NonZeroU32; use std::ops::Deref; use std::time::{Duration, Instant}; use glutin::config::GetGlConfig; use glutin::context::{N...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Duration {\n secs: u64,\n nanos: Nanoseconds, // Always 0 <= nanos < NANOS_PER_SEC\n}" ], "name": "refresh_interval", "type": "Duration" } ], "end_line": 1598, "name": "compute_timeout", "signature": "pub ...
{ "class_name": "impl FrameTimer {\n pub fn new() -> Self {\n let now = Instant::now();\n Self { base: now, last_synced_timestamp: now, refresh_interval: Duration::ZERO }\n }\n\n /// Compute the delay that we should use to achieve the target frame\n /// rate.\n pub fn compute_timeout(&mut...
new
alacritty-master/alacritty/src/display/content.rs
fn new(content: &mut RenderableContent<'_>, cell: Indexed<&Cell>) -> Self { // Lookup RGB values. let mut fg = Self::compute_fg_rgb(content, cell.fg, cell.flags); let mut bg = Self::compute_bg_rgb(content, cell.bg); let mut bg_alpha = if cell.flags.contains(Flags::INVERSE) { ...
use std::borrow::Cow; use std::num::NonZeroU32; use std::ops::Deref; use std::{cmp, mem}; use alacritty_terminal::event::EventListener; use alacritty_terminal::grid::{Dimensions, Indexed}; use alacritty_terminal::index::{Column, Line, Point}; use alacritty_terminal::selection::SelectionRange; use alacritty_terminal::t...
rust
{ "argument_definitions": [], "end_line": 299, "name": "new", "signature": "fn new(content: &mut RenderableContent<'_>, cell: Indexed<&Cell>) -> Self", "start_line": 209 }
{ "class_name": "impl RenderableCell {\n fn new(content: &mut RenderableContent<'_>, cell: Indexed<&Cell>) -> Self {\n // Lookup RGB values.\n let mut fg = Self::compute_fg_rgb(content, cell.fg, cell.flags);\n let mut bg = Self::compute_bg_rgb(content, cell.bg);\n\n let mut bg_alpha = i...
compute_fg_rgb
alacritty-master/alacritty/src/display/content.rs
fn compute_fg_rgb(content: &RenderableContent<'_>, fg: Color, flags: Flags) -> Rgb { let config = &content.config; match fg { Color::Spec(rgb) => match flags & Flags::DIM { Flags::DIM => { let rgb: Rgb = rgb.into(); rgb * DIM_FACTOR ...
use std::borrow::Cow; use std::num::NonZeroU32; use std::ops::Deref; use std::{cmp, mem}; use alacritty_terminal::event::EventListener; use alacritty_terminal::grid::{Dimensions, Indexed}; use alacritty_terminal::index::{Column, Line, Point}; use alacritty_terminal::selection::SelectionRange; use alacritty_terminal::t...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct RenderableContent<'a> {\n terminal_content: TerminalContent<'a>,\n cursor: RenderableCursor,\n cursor_shape: CursorShape,\n cursor_point: Point<usize>,\n search: Option<HintMatches<'a>>,\n hint: Option<Hint<'a>>,\n confi...
{ "class_name": "impl RenderableCell {\n fn new(content: &mut RenderableContent<'_>, cell: Indexed<&Cell>) -> Self {\n // Lookup RGB values.\n let mut fg = Self::compute_fg_rgb(content, cell.fg, cell.flags);\n let mut bg = Self::compute_bg_rgb(content, cell.bg);\n\n let mut bg_alpha = i...
advance
alacritty-master/alacritty/src/display/content.rs
fn advance( &mut self, viewport_start: Point, num_cols: usize, point: Point, ) -> Option<(Option<char>, bool)> { // Check if we're within a match at all. if !self.matches.advance(point) { return None; } // Match starting position on this l...
use std::borrow::Cow; use std::num::NonZeroU32; use std::ops::Deref; use std::{cmp, mem}; use alacritty_terminal::event::EventListener; use alacritty_terminal::grid::{Dimensions, Indexed}; use alacritty_terminal::index::{Column, Line, Point}; use alacritty_terminal::selection::SelectionRange; use alacritty_terminal::t...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Point<L = Line, C = Column> {\n pub line: L,\n pub column: C,\n}" ], "name": "viewport_start", "type": "Point" }, { "definitions": [ "pub struct Point<L = Line, C = Column> {\n pub line: L,\n ...
{ "class_name": "impl Hint<'_> {\n /// Advance the hint iterator.\n ///\n /// If the point is within a hint, the keyboard shortcut character that should be displayed at\n /// this position will be returned.\n ///\n /// The tuple's [`bool`] will be `true` when the character is the first for this hint...
get_platform_window
alacritty-master/alacritty/src/display/window.rs
pub fn get_platform_window( identity: &Identity, window_config: &WindowConfig, #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] x11_visual: Option< X11VisualInfo, >, ) -> WindowAttributes { #[cfg(feature = "x11")] let icon = { ...
#[cfg(not(any(target_os = "macos", windows)))] use winit::platform::startup_notify::{ self, EventLoopExtStartupNotify, WindowAttributesExtStartupNotify, }; #[cfg(not(any(target_os = "macos", windows)))] use winit::window::ActivationToken; #[cfg(all(not(feature = "x11"), not(any(target_os = "macos", windows))))] us...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct Identity {\n /// Window title.\n pub title: String,\n\n /// Window class.\n pub class: Class,\n}" ], "name": "identity", "type": "&Identity" }, { "definitions": [ "pub struct WindowConfig {...
{ "class_name": "impl Window {\n /// Create a new window.\n ///\n /// This creates a window and fully initializes a window.\n pub fn new(\n event_loop: &ActiveEventLoop,\n config: &UiConfig,\n identity: &Identity,\n options: &mut WindowOptions,\n #[rustfmt::skip]\n ...
should_build_sequence
alacritty-master/alacritty/src/input/keyboard.rs
fn should_build_sequence( key: &KeyEvent, text: &str, mode: TermMode, mods: ModifiersState, ) -> bool { if mode.contains(TermMode::REPORT_ALL_KEYS_AS_ESC) { return true; } let disambiguate = mode.contains(TermMode::DISAMBIGUATE_ESC_CODES) ...
use std::borrow::Cow; use winit::event::{ElementState, KeyEvent}; #[cfg(target_os = "macos")] use winit::keyboard::ModifiersKeyState; use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey}; #[cfg(target_os = "macos")] use winit::platform::macos::OptionAsAlt; use alacritty_terminal::event::EventListener; us...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct KeyEvent {\n /// Represents the position of a key independent of the currently active layout.\n ///\n /// It also uniquely identifies the physical key (i.e. it's mostly synonymous with a scancode).\n /// The most prevalent use ca...
{ "class_name": "impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {\n /// Process key input.\n pub fn key_input(&mut self, key: KeyEvent) {\n // IME input will be applied on commit and shouldn't trigger key bindings.\n if self.ctx.display().ime.preedit().is_some() {\n return;...
build_sequence
alacritty-master/alacritty/src/input/keyboard.rs
fn build_sequence(key: KeyEvent, mods: ModifiersState, mode: TermMode) -> Vec<u8> { let mut modifiers = mods.into(); let kitty_seq = mode.intersects( TermMode::REPORT_ALL_KEYS_AS_ESC | TermMode::DISAMBIGUATE_ESC_CODES | TermMode::REPORT_EVENT_TYPES, ); let kitty_encode_...
use std::borrow::Cow; use winit::event::{ElementState, KeyEvent}; #[cfg(target_os = "macos")] use winit::keyboard::ModifiersKeyState; use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey}; #[cfg(target_os = "macos")] use winit::platform::macos::OptionAsAlt; use alacritty_terminal::event::EventListener; us...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct KeyEvent {\n /// Represents the position of a key independent of the currently active layout.\n ///\n /// It also uniquely identifies the physical key (i.e. it's mostly synonymous with a scancode).\n /// The most prevalent use ca...
{ "class_name": "", "class_signature": "" }
try_build_textual
alacritty-master/alacritty/src/input/keyboard.rs
fn try_build_textual( &self, key: &KeyEvent, associated_text: Option<&str>, ) -> Option<SequenceBase> { let character = match key.logical_key.as_ref() { Key::Character(character) if self.kitty_seq => character, _ => return None, }; if characte...
use std::borrow::Cow; use winit::event::{ElementState, KeyEvent}; #[cfg(target_os = "macos")] use winit::keyboard::ModifiersKeyState; use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey}; #[cfg(target_os = "macos")] use winit::platform::macos::OptionAsAlt; use alacritty_terminal::event::EventListener; us...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct KeyEvent {\n /// Represents the position of a key independent of the currently active layout.\n ///\n /// It also uniquely identifies the physical key (i.e. it's mostly synonymous with a scancode).\n /// The most prevalent use ca...
{ "class_name": "impl SequenceBuilder {\n /// Try building sequence from the event's emitting text.\n fn try_build_textual(\n &self,\n key: &KeyEvent,\n associated_text: Option<&str>,\n ) -> Option<SequenceBase> {\n let character = match key.logical_key.as_ref() {\n Key...
try_build_named_normal
alacritty-master/alacritty/src/input/keyboard.rs
fn try_build_named_normal( &self, key: &KeyEvent, has_associated_text: bool, ) -> Option<SequenceBase> { let named = match key.logical_key { Key::Named(named) => named, _ => return None, }; // The default parameter is 1, so we can omit it. ...
use std::borrow::Cow; use winit::event::{ElementState, KeyEvent}; #[cfg(target_os = "macos")] use winit::keyboard::ModifiersKeyState; use winit::keyboard::{Key, KeyLocation, ModifiersState, NamedKey}; #[cfg(target_os = "macos")] use winit::platform::macos::OptionAsAlt; use alacritty_terminal::event::EventListener; us...
rust
{ "argument_definitions": [ { "definitions": [ "pub struct KeyEvent {\n /// Represents the position of a key independent of the currently active layout.\n ///\n /// It also uniquely identifies the physical key (i.e. it's mostly synonymous with a scancode).\n /// The most prevalent use ca...
{ "class_name": "impl SequenceBuilder {\n /// Try building sequence from the event's emitting text.\n fn try_build_textual(\n &self,\n key: &KeyEvent,\n associated_text: Option<&str>,\n ) -> Option<SequenceBase> {\n let character = match key.logical_key.as_ref() {\n Key...
cell_side
alacritty-master/alacritty/src/input/mod.rs
fn cell_side(&self, x: usize) -> Side { let size_info = self.ctx.size_info(); let cell_x = x.saturating_sub(size_info.padding_x() as usize) % size_info.cell_width() as usize; let half_cell_width = (size_info.cell_width() / 2.0) as usize; let additional_padding = ...
//! Handle input from winit. //! //! Certain key combinations should send some escape sequence back to the PTY. //! In order to figure that out, state about which modifier keys are pressed //! needs to be tracked. Additionally, we need a bit of a state machine to //! determine what to do when a non-modifier key is pres...
rust
{ "argument_definitions": [], "end_line": 537, "name": "cell_side", "signature": "fn cell_side(&self, x: usize) -> Side", "start_line": 518 }
{ "class_name": "impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {\n pub fn new(ctx: A) -> Self {\n Self { ctx, _phantom: Default::default() }\n }\n\n #[inline]\n pub fn mouse_moved(&mut self, position: PhysicalPosition<f64>) {\n let size_info = self.ctx.size_info();\n\n l...
gelu
burn-main/crates/burn-autodiff/src/ops/activation.rs
fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Gelu; retro_unary!(RetroGelu, B::gelu); impl<B: Backend> Backward<B, 1> for Gelu { type State = NodeID; fn backward( self, ops: Ops<Self::State, 1>...
use core::marker::PhantomData; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, retro_forward::RetroForward, state::BackwardStates, strategy::CheckpointStrategy, }, grads::Gradients, graph::NodeID, ops::{Backward, Ops, OpsKind, unary}, retro_unary, }; use burn_tensor...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n ...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n impl<B: Backend> Backward<B, 1> for Gelu {\...
relu
burn-main/crates/burn-autodiff/src/ops/activation.rs
fn relu(tensor: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Relu; retro_unary!(RetroRelu, B::relu); impl<B: Backend> Backward<B, 1> for Relu { type State = NodeID; fn backward( self, ops: Ops<Self::State, 1>...
use core::marker::PhantomData; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, retro_forward::RetroForward, state::BackwardStates, strategy::CheckpointStrategy, }, grads::Gradients, graph::NodeID, ops::{Backward, Ops, OpsKind, unary}, retro_unary, }; use burn_tensor...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n ...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n impl<B: Backend> Backward<B, 1> for Gelu {\...
sigmoid
burn-main/crates/burn-autodiff/src/ops/activation.rs
fn sigmoid(tensor: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Sigmoid; retro_unary!(RetroSigmoid, B::sigmoid); impl<B: Backend> Backward<B, 1> for Sigmoid { type State = NodeID; fn backward( self, ops: Ops<...
use core::marker::PhantomData; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, retro_forward::RetroForward, state::BackwardStates, strategy::CheckpointStrategy, }, grads::Gradients, graph::NodeID, ops::{Backward, Ops, OpsKind, unary}, retro_unary, }; use burn_tensor...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n ...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n impl<B: Backend> Backward<B, 1> for Gelu {\...
log_sigmoid
burn-main/crates/burn-autodiff/src/ops/activation.rs
fn log_sigmoid(tensor: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct LogSigmoid; retro_unary!(RetroLogSigmoid, B::log_sigmoid); impl<B: Backend> Backward<B, 1> for LogSigmoid { type State = NodeID; fn backward( self, ...
use core::marker::PhantomData; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, retro_forward::RetroForward, state::BackwardStates, strategy::CheckpointStrategy, }, grads::Gradients, graph::NodeID, ops::{Backward, Ops, OpsKind, unary}, retro_unary, }; use burn_tensor...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n ...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> ActivationOps<Autodiff<B, C>> for Autodiff<B, C> {\n fn gelu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {\n #[derive(Debug)]\n struct Gelu;\n\n retro_unary!(RetroGelu, B::gelu);\n\n impl<B: Backend> Backward<B, 1> for Gelu {\...
float_to_device
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_to_device(tensor: FloatTensor<Self>, device: &Device<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct ToDevice; impl<B: Backend> Backward<B, 1> for ToDevice { type State = B::Device; fn backward( self, ops: Ops<Self::State, ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_add
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_add(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Add; retro_binary!(RetroAdd, B::float_add); impl<B: Backend> Backward<B, 2> for Add { type State = (Shape, Shape); fn backward( self, ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_add_scalar
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_add_scalar(lhs: FloatTensor<Self>, rhs: FloatElem<B>) -> FloatTensor<Self> { #[derive(Debug)] struct AddScalar; retro_unary_scalar!(RetroAddScalar, B::float_add_scalar); impl<B: Backend> Backward<B, 1> for AddScalar { type State = (); fn backward( ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_sub
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_sub(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Sub; retro_binary!(RetroSub, B::float_sub); impl<B: Backend> Backward<B, 2> for Sub { type State = (Shape, Shape); fn backward( self, ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_sub_scalar
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_sub_scalar(lhs: FloatTensor<Self>, rhs: FloatElem<B>) -> FloatTensor<Self> { #[derive(Debug)] struct SubScalar; retro_unary_scalar!(RetroSubScalar, B::float_sub_scalar); impl<B: Backend> Backward<B, 1> for SubScalar { type State = (); fn backward( ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_mul
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_mul(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Mul; retro_binary!(RetroMul, B::float_mul); impl<B: Backend> Backward<B, 2> for Mul { type State = (Option<NodeID>, Option<NodeID>, BinaryOpsBroadcast); ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_mul_scalar
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_mul_scalar(lhs: FloatTensor<Self>, rhs: FloatElem<B>) -> FloatTensor<Self> { #[derive(Debug)] struct MulScalar; retro_unary_scalar!(RetroMulScalar, B::float_mul_scalar); impl<B: Backend> Backward<B, 1> for MulScalar { type State = FloatElem<B>; fn back...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_div
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_div(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Div; retro_binary!(RetroDiv, B::float_div); impl<B: Backend> Backward<B, 2> for Div { type State = (Option<NodeID>, Option<NodeID>, BinaryOpsBroadcast); ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_div_scalar
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_div_scalar(lhs: FloatTensor<Self>, rhs: FloatElem<B>) -> FloatTensor<Self> { #[derive(Debug)] struct DivScalar; retro_unary_scalar!(RetroDivScalar, B::float_div_scalar); impl<B: Backend> Backward<B, 1> for DivScalar { type State = FloatElem<B>; fn back...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_remainder
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_remainder(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Rem; retro_binary!(RetroRem, B::float_remainder); impl<B: Backend> Backward<B, 2> for Rem { type State = (Option<NodeID>, Option<NodeID>, BinaryOpsBroadcast); ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_remainder_scalar
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_remainder_scalar(lhs: FloatTensor<Self>, rhs: FloatElem<B>) -> FloatTensor<Self> { #[derive(Debug)] struct RemainderScalar; retro_unary_scalar!(RetroRemainderScalar, B::float_remainder_scalar); impl<B: Backend> Backward<B, 1> for RemainderScalar { type State = (); ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...
float_matmul
burn-main/crates/burn-autodiff/src/ops/tensor.rs
fn float_matmul(lhs: FloatTensor<Self>, rhs: FloatTensor<Self>) -> FloatTensor<Self> { #[derive(Debug)] struct Matmul; impl<B: Backend> Backward<B, 2> for Matmul { type State = (Option<NodeID>, Option<NodeID>, BinaryOpsBroadcast); fn backward( self, ...
use alloc::{boxed::Box, vec, vec::Vec}; use core::marker::PhantomData; #[cfg(not(feature = "std"))] #[allow(unused_imports, reason = "required on aarch64, unused on x86_64")] use num_traits::float::Float; use crate::{ Autodiff, checkpoint::{ base::Checkpointer, builder::CheckpointerBuilder, retro_forw...
rust
{ "argument_definitions": [ { "definitions": [ "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn fl...
{ "class_name": "impl<B: Backend, C: CheckpointStrategy> FloatTensorOps<Self> for Autodiff<B, C> {\n fn float_from_data(data: TensorData, device: &Device<Self>) -> FloatTensor<Self> {\n AutodiffTensor::new(B::float_from_data(data, device))\n }\n\n fn float_random(\n shape: Shape,\n distr...