DEFAULT_UNARCHIVE(matrix)
//////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
//////////
// public
const matrix &other_matrix = ex_to<matrix>(other->op(0));
if (self->nops() == 2) {
- unsigned self_dim = (self_matrix.col == 1) ? self_matrix.row : self_matrix.col;
if (other->nops() == 2) { // vector * vector (scalar product)
- unsigned other_dim = (other_matrix.col == 1) ? other_matrix.row : other_matrix.col;
if (self_matrix.col == 1) {
if (other_matrix.col == 1) {
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 from right
+ // to left(!) and multiplies the factors whenever needed. Note
+ // that this is not entirely optimal but close to optimal and
+ // "better" algorithms are much harder to implement. (See Knuth,
+ // TAoCP2, section "Evaluation of Powers" for a good discussion.)
while (b.compare(k)<=0) {
b *= numeric(2);
numeric r(mod(k,b));