Skip to content
Snippets Groups Projects
Commit 08644e1e authored by Martin Bauer's avatar Martin Bauer
Browse files

Python tools: function for block decomposition

parent 8199280e
Branches
Tags
No related merge requests found
from .prm_files import toPrm, fromPrm
from .setup import block_decomposition
__all__ = ['toPrm', 'fromPrm', 'block_decomposition']
def _factors(n):
while n > 1:
for i in range(2, n + 1):
if n % i == 0:
n //= i
yield i
break
def block_decomposition(processes):
"""Compute a 3D factorization of 'processes' in a 3 factors returned as tuple"""
result = [1, 1, 1]
for factor in _factors(processes):
min_idx = result.index(min(result))
result[min_idx] *= factor
assert result[0] * result[1] * result[2] == processes
return tuple(result)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment