git://www.ginac.de
/
ginac.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0abede6
)
- matrix::pow(): omit last big multiplication if it's not needed.
author
Richard Kreckel
<Richard.Kreckel@uni-mainz.de>
Thu, 7 Jun 2001 22:26:16 +0000
(22:26 +0000)
committer
Richard Kreckel
<Richard.Kreckel@uni-mainz.de>
Thu, 7 Jun 2001 22:26:16 +0000
(22:26 +0000)
ginac/matrix.cpp
patch
|
blob
|
history
diff --git
a/ginac/matrix.cpp
b/ginac/matrix.cpp
index
9998a39
..
872b8e0
100644
(file)
--- a/
ginac/matrix.cpp
+++ b/
ginac/matrix.cpp
@@
-638,8
+638,8
@@
matrix matrix::pow(const ex & expn) const
for (unsigned r=0; r<row; ++r)
result(r,r) = _ex1();
numeric b(1);
- // this loop computes the representation of k in base 2 and
multiplies
- // the factors whenever needed:
+ // this loop computes the representation of k in base 2 and
+ //
multiplies
the factors whenever needed:
while (b.compare(k)<=0) {
b *= numeric(2);
numeric r(mod(k,b));
@@
-647,7
+647,8
@@
matrix matrix::pow(const ex & expn) const
k -= r;
result = result.mul(prod);
}
- prod = prod.mul(prod);
+ if (b.compare(k)<=0)
+ prod = prod.mul(prod);
}
return result;
}