LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
factorial.c 文件参考
#include "support/perf.h"
#include "lmmp/lmmpn.h"
#include "lmmp/numth.h"
factorial.c 的引用(Include)关系图:

浏览该文件的源代码.

函数

static double bench_factorial (uint n, const bench_options *o)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
int main (void)
static void run_factorial (void)

函数说明

◆ bench_factorial()

double bench_factorial ( uint n,
const bench_options * o )
static

Copyright (C) 2026 HJimmyK (Jericho Knox)

This file is part of LMMP.

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

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SPDX-License-Identifier: LGPL-3.0-or-later

在文件 factorial.c 第 27 行定义.

27 {
28 mp_bitcnt_t bits = 0;
29 mp_size_t need = lmmp_factorial_size_(n, &bits);
30 mp_ptr d = alloc_limbs(need + 2);
31 double us;
32 BENCH_MEASURE(us, o, lmmp_factorial_(d, bits, need, n); bench_sink += d[0];);
33 lmmp_free(d);
34 return us;
35}
mp_limb_t * mp_ptr
定义 lmmp.h:96
size_t mp_bitcnt_t
定义 lmmp.h:98
uint64_t mp_size_t
定义 lmmp.h:93
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
#define n
mp_size_t lmmp_factorial_size_(uint n, mp_bitcnt_t *bits)
计算 n!
mp_size_t lmmp_factorial_(mp_ptr dst, mp_bitcnt_t bits, mp_size_t rn, uint n)
计算 n!
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93

引用了 bench_factorial(), BENCH_MEASURE, lmmp_factorial_(), lmmp_factorial_size_(), lmmp_free() , 以及 n.

被这些函数引用 bench_factorial() , 以及 run_factorial().

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

◆ main()

int main ( void )

在文件 factorial.c 第 47 行定义.

47 {
48 setvbuf(stdout, NULL, _IONBF, 0);
50 puts("[numth/factorial/factorial]");
53 return 0;
54}
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
static void run_factorial(void)

引用了 lmmp_global_deinit(), lmmp_global_init(), main() , 以及 run_factorial().

函数调用图:

◆ run_factorial()

void run_factorial ( void )
static

在文件 factorial.c 第 37 行定义.

37 {
38 const uint SZ[] = {100, 1000, 10000};
39 for (size_t i = 0; i < ARRAY_SIZE(SZ); ++i) {
40 uint n = SZ[i];
41 char buf[64];
42 snprintf(buf, sizeof(buf), "factorial(%u)", n);
43 report(buf, bench_factorial(n, &bench_default), 0);
44 }
45}
uint32_t uint
定义 numth.h:38
static double bench_factorial(uint n, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 perf.h:40

引用了 ARRAY_SIZE, bench_factorial(), n , 以及 run_factorial().

被这些函数引用 main() , 以及 run_factorial().

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