LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
not.c
浏览该文件的文档.
1/**
2 * Copyright (C) 2026 HJimmyK (Jericho Knox)
3 *
4 * This file is part of LMMP.
5 *
6 * LMMP is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <https://www.gnu.org/licenses/>.
19 *
20 * SPDX-License-Identifier: LGPL-3.0-or-later
21 */
22
23#include "lmmp/lmmpn.h"
24
25
26void lmmp_not_(mp_ptr dst, mp_srcptr numa, mp_size_t na) {
27 for (mp_size_t i = 0; i < na; i++) {
28 dst[i] = ~numa[i];
29 }
30}
31
33 if (shl == 0) {
34 lmmp_not_(dst, numa, na);
35 return 0;
36 } else if (dst == numa) {
37 mp_limb_t t, m, n;
38 t = dst[0] << shl;
39 m = dst[0] >> (LIMB_BITS - shl);
40 dst[0] = ~t;
41 for (mp_size_t i = 1; i < na; i++) {
42 t = dst[i] << shl;
43 n = dst[i] >> (LIMB_BITS - shl);
44 dst[i] = ~(t | m);
45 m = n;
46 }
47 return m;
48 } else {
49 /* seq(dst,numa) */
50 mp_limb_t t, m, n;
51 t = numa[0] << shl;
52 m = numa[0] >> (LIMB_BITS - shl);
53 dst[0] = ~t;
54 for (mp_size_t i = 1; i < na; i++) {
55 t = numa[i] << shl;
56 n = numa[i] >> (LIMB_BITS - shl);
57 dst[i] = ~(t | m);
58 m = n;
59 }
60 return m;
61 }
62}
mp_limb_t * mp_ptr
定义 lmmp.h:96
uint64_t mp_size_t
定义 lmmp.h:93
const mp_limb_t * mp_srcptr
定义 lmmp.h:97
uint64_t mp_limb_t
定义 lmmp.h:92
#define LIMB_BITS
定义 lmmp.h:102
mp_limb_t lmmp_shlnot_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_size_t shl)
左移后按位取反操作 [dst,na] = ~([numa,na] << shl),dst的低shl位填充1
void lmmp_not_(mp_ptr dst, mp_srcptr numa, mp_size_t na)
按位取反操作 [dst,na] = ~[numa,na] (对每个limb执行按位非操作)
定义 not.c:26
#define t
#define n
#define restrict
Copyright (C) 2026 HJimmyK (Jericho Knox)