LAMMP 4.1.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
not.c
浏览该文件的文档.
1/*
2 * LAMMP - Copyright (C) 2025-2026 HJimmyK(Jericho Knox)
3 * This file is part of lammp, under the GNU LGPL v2 license.
4 * See LICENSE in the project root for the full license text.
5 */
6
7#include "../../../include/lammp/lmmpn.h"
8
9void lmmp_not_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t na) {
10 if (dst == numa) {
11 for (mp_size_t i = 0; i < na; i++) {
12 dst[i] = ~dst[i];
13 }
14 } else {
15 for (mp_size_t i = 0; i < na; i++) {
16 dst[i] = ~numa[i];
17 }
18 }
19}
20
21mp_limb_t lmmp_shlnot_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t na, mp_size_t shl) {
22 if (shl == 0) {
23 lmmp_not_(dst, numa, na);
24 return 0;
25 } else if (dst == numa) {
26 mp_limb_t t, m, n;
27 t = dst[0] << shl;
28 m = dst[0] >> (LIMB_BITS - shl);
29 dst[0] = ~t;
30 for (mp_size_t i = 1; i < na; i++) {
31 t = dst[i] << shl;
32 n = dst[i] >> (LIMB_BITS - shl);
33 dst[i] = ~(t | m);
34 m = n;
35 }
36 return m;
37 } else {
38 /* seq(dst,numa) */
39 mp_limb_t t, m, n;
40 t = numa[0] << shl;
41 m = numa[0] >> (LIMB_BITS - shl);
42 dst[0] = ~t;
43 for (mp_size_t i = 1; i < na; i++) {
44 t = numa[i] << shl;
45 n = numa[i] >> (LIMB_BITS - shl);
46 dst[i] = ~(t | m);
47 m = n;
48 }
49 return m;
50 }
51}
mp_limb_t * mp_ptr
Definition lmmp.h:215
uint64_t mp_size_t
Definition lmmp.h:212
const mp_limb_t * mp_srcptr
Definition lmmp.h:216
uint64_t mp_limb_t
Definition lmmp.h:211
#define LIMB_BITS
Definition lmmp.h:221
mp_limb_t lmmp_shlnot_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t na, mp_size_t shl)
Definition not.c:21
void lmmp_not_(mp_ptr restrict dst, mp_srcptr restrict numa, mp_size_t na)
Definition not.c:9