projects
/
nmutil.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
604a325
)
whitespace in docstrings
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 18 Aug 2022 09:25:01 +0000
(10:25 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 18 Aug 2022 09:25:01 +0000
(10:25 +0100)
src/nmutil/prefix_sum.py
patch
|
blob
|
history
diff --git
a/src/nmutil/prefix_sum.py
b/src/nmutil/prefix_sum.py
index 65f2b33eaf079889590d5aa13ffb6fdb28f1628c..bd13219eb3f0f3d0a027aeb9dc3c83e804a14ce2 100644
(file)
--- a/
src/nmutil/prefix_sum.py
+++ b/
src/nmutil/prefix_sum.py
@@
-19,21
+19,14
@@
class Op:
__slots__ = "out", "lhs", "rhs", "row"
def __init__(self, out, lhs, rhs, row):
__slots__ = "out", "lhs", "rhs", "row"
def __init__(self, out, lhs, rhs, row):
- self.out = out
- """index of the item to output to"""
-
- self.lhs = lhs
- """index of the item the left-hand-side input comes from"""
-
- self.rhs = rhs
- """index of the item the right-hand-side input comes from"""
-
- self.row = row
- """row in the prefix-sum diagram"""
+ self.out = out; "index of the item to output to"
+ self.lhs = lhs; "index of the item the left-hand-side input comes from"
+ self.rhs = rhs; "index of the item the right-hand-side input comes from"
+ self.row = row; "row in the prefix-sum diagram"
def prefix_sum_ops(item_count, *, work_efficient=False):
def prefix_sum_ops(item_count, *, work_efficient=False):
- """
Get the associative operations needed to compute a parallel prefix-sum
+ """Get the associative operations needed to compute a parallel prefix-sum
of `item_count` items.
The operations aren't assumed to be commutative.
of `item_count` items.
The operations aren't assumed to be commutative.
@@
-79,7
+72,7
@@
def prefix_sum_ops(item_count, *, work_efficient=False):
def prefix_sum(items, fn=operator.add, *, work_efficient=False):
def prefix_sum(items, fn=operator.add, *, work_efficient=False):
- """
Compute the parallel prefix-sum of `items`, using associative operator
+ """Compute the parallel prefix-sum of `items`, using associative operator
`fn` instead of addition.
This has a depth of `O(log(N))` and an operation count of `O(N)` if
`fn` instead of addition.
This has a depth of `O(log(N))` and an operation count of `O(N)` if
@@
-285,7
+278,7
@@
def tree_reduction(items, fn=operator.add):
def pop_count(v, *, width=None, process_temporary=lambda v: v):
def pop_count(v, *, width=None, process_temporary=lambda v: v):
- """
return the population count (number of 1 bits) of `v`.
+ """return the population count (number of 1 bits) of `v`.
Arguments:
v: nmigen.Value | int
the value to calculate the pop-count of.
Arguments:
v: nmigen.Value | int
the value to calculate the pop-count of.