LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
log2_exp2.h 文件参考
#include <stdint.h>
+ log2_exp2.h 的引用(Include)关系图:
+ 此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

函数

void exp2_fixed_128 (uint64_t *dst, uint64_t high, uint64_t low)
 floor(exp2(x/B)*B-B), B=2^128
 
uint64_t exp2_fixed_64 (uint64_t x)
 floor(exp2(x/B)*B-B), B=2^64
 
void log2_fixed_128 (uint64_t *dst, uint64_t high, uint64_t low)
 floor(log2(1+x/B)*B), B=2^128
 
uint64_t log2_fixed_64 (uint64_t x)
 Copyright (C) 2026 HJimmyK(Jericho Knox)
 

函数说明

◆ exp2_fixed_128()

void exp2_fixed_128 ( uint64_t *  dst,
uint64_t  high,
uint64_t  low 
)

floor(exp2(x/B)*B-B), B=2^128

参数
high输入的小数部分高64位
low输入的小数部分低64位
dst输出数组(2个元素):dst[0] 为低64位,dst[1] 为高64位
注解
x = high * 2^64 + low

在文件 log2_exp2.c409 行定义.

409 {
410 uint64_t res[3];
411 uint64_t x[2] = {low, high};
412 uint64_t coeff[3];
413 res[0] = exp2_coeffs[EXP2_COEFFS_SIZE - 1][0];
414 res[1] = exp2_coeffs[EXP2_COEFFS_SIZE - 1][1];
415 res[2] = exp2_coeffs[EXP2_COEFFS_SIZE - 1][2];
416 for (int i = 1; i < EXP2_COEFFS_SIZE; i++) {
417 coeff[0] = exp2_coeffs[EXP2_COEFFS_SIZE - 1 - i][0];
418 coeff[1] = exp2_coeffs[EXP2_COEFFS_SIZE - 1 - i][1];
419 coeff[2] = exp2_coeffs[EXP2_COEFFS_SIZE - 1 - i][2];
422 }
423 dst[0] = res[1];
424 dst[1] = res[2];
425}
static const float coeff[16][3]
Definition cbrt_1.c:23
#define EXP2_COEFFS_SIZE
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition log2_exp2.c:43
static const uint64_t exp2_coeffs[][3]
Definition log2_exp2.c:44
static void umul192x128_tohi192(uint64_t dst[3], const uint64_t i192[3], const uint64_t i128[2])
Definition log2_exp2.c:216
#define _u192add(i192, j192)
Definition longlong.h:377
#define n

引用了 _u192add, coeff, exp2_coeffs, EXP2_COEFFS_SIZE, n , 以及 umul192x128_tohi192().

被这些函数引用 lmmp_cbrtapprox_6_().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ exp2_fixed_64()

uint64_t exp2_fixed_64 ( uint64_t  x)

floor(exp2(x/B)*B-B), B=2^64

参数
x输入的小数部分
返回
floor(exp2(x/B)*B-B)

在文件 log2_exp2.c485 行定义.

485 {
486 uint64_t res[2];
487 uint64_t coeff[2];
490 for (int i = 1; i < EXP2_COEFFS_SIZE_64BIT; i++) {
495 }
496 return res[1];
497}
static void umul128x64_tohi128(uint64_t dst[2], const uint64_t i128[2], uint64_t i64)
Definition log2_exp2.c:264
#define EXP2_COEFFS_SIZE_64BIT
Definition log2_exp2.c:448
static const uint64_t exp2_coeffs_64bit[][2]
Definition log2_exp2.c:449
#define _u128add(r, x, y)
Definition longlong.h:346

引用了 _u128add, coeff, exp2_coeffs_64bit, EXP2_COEFFS_SIZE_64BIT, n , 以及 umul128x64_tohi128().

被这些函数引用 lmmp_cbrtapprox_3_().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ log2_fixed_128()

void log2_fixed_128 ( uint64_t *  dst,
uint64_t  high,
uint64_t  low 
)

floor(log2(1+x/B)*B), B=2^128

参数
high输入的小数部分高64位
low输入的小数部分低64位
dst输出数组(2个元素):dst[0] 为低64位,dst[1] 为高64位
注解
x = high * 2^64 + low

在文件 log2_exp2.c292 行定义.

292 {
293 uint64_t res[3];
294 uint64_t x[3] = {0, low, high};
295 uint64_t coeff[3];
296 if (high < 0x4000000000000000ULL) {
298 bool coeff_sign;
302 for (int i = 1; i < LOG2_COEFFS_SIZE_1; i++) {
307
309 if (sign == coeff_sign) {
311 } else {
312 if (leq_192(res, coeff)) {
314 res[0] = coeff[0];
315 res[1] = coeff[1];
316 res[2] = coeff[2];
318 } else {
320 }
321 }
322 }
323 } else if (high < 0x8000000000000000ULL) {
325 bool coeff_sign;
329 for (int i = 1; i < LOG2_COEFFS_SIZE_2; i++) {
334
336 if (sign == coeff_sign) {
338 } else {
339 if (leq_192(res, coeff)) {
341 res[0] = coeff[0];
342 res[1] = coeff[1];
343 res[2] = coeff[2];
345 } else {
347 }
348 }
349 }
350 } else if (high < 0xC000000000000000ULL) {
352 bool coeff_sign;
356 for (int i = 1; i < LOG2_COEFFS_SIZE_3; i++) {
361
363 if (sign == coeff_sign) {
365 } else {
366 if (leq_192(res, coeff)) {
368 res[0] = coeff[0];
369 res[1] = coeff[1];
370 res[2] = coeff[2];
372 } else {
374 }
375 }
376 }
377 } else {
379 bool coeff_sign;
383 for (int i = 1; i < LOG2_COEFFS_SIZE_4; i++) {
388
390 if (sign == coeff_sign) {
392 } else {
393 if (leq_192(res, coeff)) {
395 res[0] = coeff[0];
396 res[1] = coeff[1];
397 res[2] = coeff[2];
399 } else {
401 }
402 }
403 }
404 }
405 dst[0] = (res[1] << 1) | (res[0] >> 63);
406 dst[1] = (res[2] << 1) | (res[1] >> 63);
407}
#define LOG2_COEFFS_SIZE_2
Definition log2_exp2.c:212
static const bool log2_coeffs_bool_3[]
Definition log2_exp2.c:173
static const bool log2_coeffs_bool_1[]
Definition log2_exp2.c:102
static const uint64_t log2_coeffs_4[][3]
Definition log2_exp2.c:177
static const uint64_t log2_coeffs_2[][3]
Definition log2_exp2.c:106
#define LOG2_COEFFS_SIZE_4
Definition log2_exp2.c:214
static const uint64_t log2_coeffs_3[][3]
Definition log2_exp2.c:143
static bool leq_192(const uint64_t A[3], const uint64_t B[3])
Definition log2_exp2.c:284
#define LOG2_COEFFS_SIZE_3
Definition log2_exp2.c:213
static const bool log2_coeffs_bool_4[]
Definition log2_exp2.c:207
static const uint64_t log2_coeffs_1[][3]
Definition log2_exp2.c:69
static const bool log2_coeffs_bool_2[]
Definition log2_exp2.c:139
#define LOG2_COEFFS_SIZE_1
Definition log2_exp2.c:211
#define _u192sub(i192, j192)
Definition longlong.h:388

引用了 _u192add, _u192sub, coeff, leq_192(), log2_coeffs_1, log2_coeffs_2, log2_coeffs_3, log2_coeffs_4, log2_coeffs_bool_1, log2_coeffs_bool_2, log2_coeffs_bool_3, log2_coeffs_bool_4, LOG2_COEFFS_SIZE_1, LOG2_COEFFS_SIZE_2, LOG2_COEFFS_SIZE_3, LOG2_COEFFS_SIZE_4, n , 以及 umul192x128_tohi192().

被这些函数引用 lmmp_cbrtapprox_6_().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ log2_fixed_64()

uint64_t log2_fixed_64 ( uint64_t  x)

Copyright (C) 2026 HJimmyK(Jericho Knox)

This file is part of LAMMP.

LAMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed WITHOUT ANY WARRANTY.

See https://www.gnu.org/licenses/.

floor(log2(1+x/B)*B), B=2^64

参数
x输入的小数部分
返回
floor(log2(1+x/B)*B)

在文件 log2_exp2.c458 行定义.

458 {
459 uint64_t res[2];
460 uint64_t coeff[2];
462 bool coeff_sign;
465 for (int i = 1; i < LOG2_COEFFS_SIZE_64BIT; i++) {
470
471 if (sign == coeff_sign) {
473 } else {
474 if (_u128cmp(res, coeff)) {
477 } else {
479 }
480 }
481 }
482 return (res[1] << 1) | (res[0] >> 63);
483}
static const bool log2_coeffs_bool_64bit[]
Definition log2_exp2.c:444
static const uint64_t log2_coeffs_64bit[][2]
Definition log2_exp2.c:428
#define LOG2_COEFFS_SIZE_64BIT
Definition log2_exp2.c:427
#define _u128sub(r, x, y)
Definition longlong.h:368
#define _u128cmp(x, y)
Definition longlong.h:366

引用了 _u128add, _u128cmp, _u128sub, coeff, log2_coeffs_64bit, log2_coeffs_bool_64bit, LOG2_COEFFS_SIZE_64BIT, n , 以及 umul128x64_tohi128().

被这些函数引用 lmmp_cbrtapprox_3_().

+ 函数调用图:
+ 这是这个函数的调用关系图: