repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git]
/
mpow.cpp
blob
328af89f67f872f90ca6bd72afcba106958c72d2
1
// Bignum power
2
3
#include
"stdafx.h"
4
#include
"defs.h"
5
6
unsigned int
*
7
mpow
(
unsigned int
*
a
,
unsigned int
n
)
8
{
9
unsigned int
*
aa
, *
t
;
10
11
a
=
mcopy
(
a
);
12
13
aa
=
mint
(
1
);
14
15
for
(;;) {
16
17
if
(
n
&
1
) {
18
t
=
mmul
(
aa
,
a
);
19
mfree
(
aa
);
20
aa
=
t
;
21
}
22
23
n
>>=
1
;
24
25
if
(
n
==
0
)
26
break
;
27
28
t
=
mmul
(
a
,
a
);
29
mfree
(
a
);
30
a
=
t
;
31
}
32
33
mfree
(
a
);
34
35
return
aa
;
36
}