|
LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
|
#include "../../../include/lammp/impl/mparam.h"#include "../../../include/lammp/impl/tmp_alloc.h"#include "../../../include/lammp/impl/inlines.h"#include "../../../include/lammp/lmmpn.h"#include "../../../include/lammp/numth.h"
sqrt.c 的引用(Include)关系图:函数 | |
| static void | lmmp_invsqrt_newton_ (mp_ptr dstis, mp_size_t ns, mp_srcptr numa, mp_size_t na) |
| 计算逆平方根 [dstis,ns+1]=floor(sqrt(B^(2*ns+na)/[numa,na]))-[0|1], dstis[ns]=1 | |
| void | lmmp_sqrt_ (mp_ptr dsts, mp_ptr dstr, mp_srcptr numa, mp_size_t na, mp_size_t nf) |
| 计算 [numa,na] * B^(2*nf) 的平方根和余数 | |
| static mp_limb_t | lmmp_sqrt_divide_ (mp_ptr dsts, mp_ptr numa, mp_size_t ns, int nsh) |
| Copyright (C) 2026 HJimmyK(Jericho Knox) | |
| static void | lmmp_sqrt_newton_ (mp_ptr dsts, mp_srcptr numa, mp_size_t na, mp_size_t nf) |
| 计算近似平方根 [dsts,nf+na/2+1]=[floor|round](sqrt([numa,na]*B^(2*nf))) | |
|
static |
计算逆平方根 [dstis,ns+1]=floor(sqrt(B^(2*ns+na)/[numa,na]))-[0|1], dstis[ns]=1
| dstis | 目标数组 |
| ns | dsts数组的 limb 长度为 ns+1 |
| numa | 输入数组 |
| na | numa数组的 limb 长度 |
引用了 LIMB_B_4, LIMB_BITS, LIMB_MAX, lmmp_add_(), lmmp_copy, lmmp_dec, lmmp_dec_1, lmmp_div_s_(), lmmp_fft_next_size_(), lmmp_inc, lmmp_inc_1, LMMP_MIN, lmmp_mul_(), lmmp_mul_mersenne_(), lmmp_mul_n_, lmmp_not_(), lmmp_param_assert, lmmp_shlnot_(), lmmp_shr_(), lmmp_sqr_, lmmp_sqrt_divide_(), lmmp_zero, lmmp_zero_q_(), n, SQRT_NEWTON_MODM_THRESHOLD, TALLOC_TYPE, TEMP_DECL , 以及 TEMP_FREE.
被这些函数引用 lmmp_sqrt_newton_().
函数调用图:
这是这个函数的调用关系图:计算 [numa,na] * B^(2*nf) 的平方根和余数
| dsts | 平方根结果输出指针 |
| dstr | 余数结果输出指针(NULL表示不计算余数) |
| numa | 源操作数指针 |
| na | 操作数的 limb 长度 |
| nf | 精度因子 |
引用了 LIMB_BITS, lmmp_addmul_1_(), lmmp_copy, lmmp_debug_assert, lmmp_leading_zeros_, lmmp_shl_(), lmmp_shr_(), lmmp_sqrt_1_(), lmmp_sqrt_divide_(), lmmp_sqrt_newton_(), lmmp_sub_1_(), lmmp_submul_1_(), lmmp_zero, n, SQRT_NEWTON_THRESHOLD, TALLOC_TYPE, TEMP_DECL , 以及 TEMP_FREE.
被这些函数引用 lmmp_perfsqr_().
函数调用图:
这是这个函数的调用关系图: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/.
分治法计算整数平方根
| dsts | 输出:平方根的整数部分,长度为 ns。 |
| numa | 输入/输出:被开方数,长度为 2*ns。
|
| ns | 平方根占用的 limb 数。 |
| nsh | 右移位数(0 <= nsh < LIMB_BITS),仅顶层调用时有效。表示最终结果需要右移 nsh 位。 |
引用了 LIMB_B_4, LIMB_BITS, lmmp_add_1_(), lmmp_add_n_(), lmmp_addshl1_n_(), lmmp_div_s_(), lmmp_param_assert, lmmp_shr_c_(), lmmp_sqr_, lmmp_sqrt_2_(), lmmp_sqrt_divide_(), lmmp_sub_1_(), lmmp_sub_n_(), lo , 以及 n.
被这些函数引用 lmmp_invsqrt_newton_(), lmmp_sqrt_() , 以及 lmmp_sqrt_divide_().
函数调用图:
这是这个函数的调用关系图:计算近似平方根 [dsts,nf+na/2+1]=[floor|round](sqrt([numa,na]*B^(2*nf)))
| dsts | 目标数组 |
| numa | 输入数组 |
| na | numa数组的 limb 长度 |
| nf | 精度因子 |
引用了 LIMB_BITS, lmmp_copy, lmmp_inc, lmmp_invsqrt_newton_(), lmmp_leading_zeros_, lmmp_mul_(), lmmp_param_assert, lmmp_shl_(), lmmp_shr_(), n, TALLOC_TYPE, TEMP_DECL, TEMP_FREE , 以及 tp.
被这些函数引用 lmmp_sqrt_().
函数调用图:
这是这个函数的调用关系图: