Reducing the cost of multiplications in numbers

68 Views Asked by At

I want to reduce the cost of number multiplication in the Matrix Multiplication. Is the multiplication of a number by $10^n$ or $2^n$ enforces a surplus cost in computer operations or it is just adding zeros at the end of the numbers? If there is not so cost, then an $O(n^2)$ algorithm for MM is available.

1

There are 1 best solutions below

2
On BEST ANSWER

Let us assume the standard IEEE binary floating point representation, that is a positive (machine) number is given by $$ x = 2^n \left( 1 + \sum_{i=1}^m x_i 2^{-i} \right) $$ for $x_i\in\{0, 1\}$, $n\in\mathbb Z$ with $|n| \le N$, and some fixed $m, N\in\mathbb N$. Then, $x$ is represented by $(x_1,\dotsc, x_m, n)$.

Multiplying $x$ by a 2-power, say $2^p$, results in a signed addition of $n$ and $p$ (with possible over-/underflow). So it is surely not just "moving numbers". Multiplying $x$ by a 10-power results in a full floating multiplication.

I am not sure if any CPU checks for 2-powers and exploits that. Multiplication with numbers of higher precision is more expensive. But, it is always constant given fixed precision.