LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
log2_exp2.h
浏览该文件的文档.
1/**
2 * Copyright (C) 2026 HJimmyK(Jericho Knox)
3 *
4 * This file is part of LAMMP.
5 *
6 * LAMMP is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License (LGPL) as published
8 * by the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed WITHOUT ANY WARRANTY.
12 *
13 * See <https://www.gnu.org/licenses/>.
14 */
15
16#ifndef __LAMMP_LOG2_EXP2_H__
17#define __LAMMP_LOG2_EXP2_H__
18
19#include <stdint.h>
20
21/**
22 * @brief floor(log2(1+x/B)*B), B=2^64
23 * @param x 输入的小数部分
24 * @return floor(log2(1+x/B)*B)
25 */
26uint64_t log2_fixed_64(uint64_t x);
27
28/**
29 * @brief floor(exp2(x/B)*B-B), B=2^64
30 * @param x 输入的小数部分
31 * @return floor(exp2(x/B)*B-B)
32 */
33uint64_t exp2_fixed_64(uint64_t x);
34
35/**
36 * @brief floor(log2(1+x/B)*B), B=2^128
37 * @param high 输入的小数部分高64位
38 * @param low 输入的小数部分低64位
39 * @param dst 输出数组(2个元素):dst[0] 为低64位,dst[1] 为高64位
40 * @note x = high * 2^64 + low
41 */
42void log2_fixed_128(uint64_t* dst, uint64_t high, uint64_t low);
43
44/**
45 * @brief floor(exp2(x/B)*B-B), B=2^128
46 * @param high 输入的小数部分高64位
47 * @param low 输入的小数部分低64位
48 * @param dst 输出数组(2个元素):dst[0] 为低64位,dst[1] 为高64位
49 * @note x = high * 2^64 + low
50 */
51void exp2_fixed_128(uint64_t* dst, uint64_t high, uint64_t low);
52
53#endif // __LAMMP_LOG2_EXP2_H__
void exp2_fixed_128(uint64_t *dst, uint64_t high, uint64_t low)
floor(exp2(x/B)*B-B), B=2^128
Definition log2_exp2.c:409
void log2_fixed_128(uint64_t *dst, uint64_t high, uint64_t low)
floor(log2(1+x/B)*B), B=2^128
Definition log2_exp2.c:292
uint64_t exp2_fixed_64(uint64_t x)
floor(exp2(x/B)*B-B), B=2^64
Definition log2_exp2.c:485
uint64_t log2_fixed_64(uint64_t x)
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition log2_exp2.c:458