Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/**2 * This file does conversion between units. In particular, it provides3 * calculateSize to convert other units into ems.4 */5 6import ParseError from "./ParseError";7import Options from "./Options";8 9// This table gives the number of TeX pts in one of each *absolute* TeX unit.10// Thus, multiplying a length by this number converts the length from units11// into pts. Dividing the result by ptPerEm gives the number of ems12// *assuming* a font size of ptPerEm (normal size, normal style).13const ptPerUnit: Record<string, number> = {14 // https://en.wikibooks.org/wiki/LaTeX/Lengths and15 // https://tex.stackexchange.com/a/826316 "pt": 1, // TeX point17 "mm": 7227 / 2540, // millimeter18 "cm": 7227 / 254, // centimeter19 "in": 72.27, // inch20 "bp": 803 / 800, // big (PostScript) points21 "pc": 12, // pica22 "dd": 1238 / 1157, // didot23 "cc": 14856 / 1157, // cicero (12 didot)24 "nd": 685 / 642, // new didot25 "nc": 1370 / 107, // new cicero (12 new didot)26 "sp": 1 / 65536, // scaled point (TeX's internal smallest unit)27 // https://tex.stackexchange.com/a/4137128 "px": 803 / 800, // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX29};30 31// Dictionary of relative units, for fast validity testing.32const relativeUnit = {33 "ex": true,34 "em": true,35 "mu": true,36};37 38export type Measurement = { number: number, unit: string };39 40/**41 * Determine whether the specified unit (either a string defining the unit42 * or a "size" parse node containing a unit field) is valid.43 */44export const validUnit = function(unit: string | Measurement): boolean {45 if (typeof unit !== "string") {46 unit = unit.unit;47 }48 return (unit in ptPerUnit || unit in relativeUnit || unit === "ex");49};50 51/*52 * Convert a "size" parse node (with numeric "number" and string "unit" fields,53 * as parsed by functions.js argType "size") into a CSS em value for the54 * current style/scale. `options` gives the current options.55 */56export const calculateSize = function(57 sizeValue: Measurement, options: Options): number {58 let scale;59 if (sizeValue.unit in ptPerUnit) {60 // Absolute units61 scale = ptPerUnit[sizeValue.unit] // Convert unit to pt62 / options.fontMetrics().ptPerEm // Convert pt to CSS em63 / options.sizeMultiplier; // Unscale to make absolute units64 } else if (sizeValue.unit === "mu") {65 // `mu` units scale with scriptstyle/scriptscriptstyle.66 scale = options.fontMetrics().cssEmPerMu;67 } else {68 // Other relative units always refer to the *textstyle* font69 // in the current size.70 let unitOptions;71 if (options.style.isTight()) {72 // isTight() means current style is script/scriptscript.73 unitOptions = options.havingStyle(options.style.text());74 } else {75 unitOptions = options;76 }77 // TODO: In TeX these units are relative to the quad of the current78 // *text* font, e.g. cmr10. KaTeX instead uses values from the79 // comparably-sized *Computer Modern symbol* font. At 10pt, these80 // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;81 // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.82 // TeX \showlists shows a kern of 1.13889 * fontsize;83 // KaTeX shows a kern of 1.171 * fontsize.84 if (sizeValue.unit === "ex") {85 scale = unitOptions.fontMetrics().xHeight;86 } else if (sizeValue.unit === "em") {87 scale = unitOptions.fontMetrics().quad;88 } else {89 throw new ParseError("Invalid unit: '" + sizeValue.unit + "'");90 }91 if (unitOptions !== options) {92 scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;93 }94 }95 return Math.min(sizeValue.number * scale, options.maxSize);96};97 98/**99 * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See100 * https://github.com/KaTeX/KaTeX/pull/2460.101 */102export const makeEm = function(n: number): string {103 return +n.toFixed(4) + "em";104};105 