A wrapper around numpy that does lazy evaluations to optimize for chained matrix multiplication
Project description
lazynumpy
a lazy evaluated wrapper around numpy
What is gained?
- Chained matrix multiplication will be minimized by keeping the values of the other arrays in memory and solving the associative problem that minimizes the number of computations.
- only keeps one copy of each matrix [Memory optimization in progress]
- Allow partial matrix returns withou calculating the entire matrix [In Progress]
If you have three matrices with dimensions as below there are two ways to do the matrix multiplication to find the answer:
Either:
or
[1] will take 1000 * 1 * 1000
operations to calculate A * B
plus 1000 * 1000 * 1000
operations to calculate (A * B) * C
. The total sum to calculate A * B * C
is equal to 1000^3 + 1000^2
.
[2] will take 1 * 1000 * 1000
operations to calculate B * C
plus 1000 * 1 * 1000
operations to calculate A * (B * C)
. The total sum to calculate A * B * C
is equal to 1000^2 + 1000^2
which means the optimal multiplication order will be ~500 faster.
If you run the simple example you should see a significant speed up. On my computer there is a 50x speedup with only three matrix calculations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lazynumpy-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be3bc493a48ed1e580f60ffaf1579da58f3fd27934952b80bfc053e9c6758458 |
|
MD5 | a96d43eb047bea30b9cfd5795e4416e0 |
|
BLAKE2b-256 | f55871b57c8d75bd4a95d882fe4e64e1d69d16aa34bd77c763e88ecd40718ae3 |