Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6385b8

Browse files
committed
Fixed wrong rare point
1 parentf4fd0da commita6385b8

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

‎GPU/GPUMath.h‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ __device__ __constant__ uint64_t _beta2[] = { 0x3EC693D68E6AFA40ULL,0x630FB68AED
9292
UADDO1(r[0], _P[0]); \
9393
UADDC1(r[1], _P[1]); \
9494
UADDC1(r[2], _P[2]); \
95-
UADD1(r[3], _P[3]); \
96-
r[4]= 0ULL;}
95+
UADDC1(r[3], _P[3]); \
96+
UADD1(r[4], _P[4]);}
97+
9798

9899
// ---------------------------------------------------------------------------------------
99100

@@ -445,14 +446,12 @@ __device__ __noinline__ void _ModInv(uint64_t *R) {
445446
return;
446447
}
447448

448-
if (_IsNegative(s)) {
449+
// In very rare case |s|>2P
450+
while(_IsNegative(s))
449451
AddP(s);
450-
}
451-
else {
452-
Sub1(s,_P);
453-
if (_IsNegative(s))
454-
AddP(s);
455-
}
452+
while(!_IsNegative(s))
453+
Sub1(s,_P);
454+
AddP(s);
456455

457456
Load(R,s);
458457

‎IntMod.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ void Int::ModInv() {
498498
return;
499499
}
500500

501-
if (s.IsNegative())
501+
// In very rare case |s|>2P
502+
while(s.IsNegative())
502503
s.Add(&_P);
503-
504-
if (s.IsGreaterOrEqual(&_P))
504+
while(s.IsGreaterOrEqual(&_P))
505505
s.Sub(&_P);
506506

507507
Set(&s);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp