-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
adding a matrix equalization algorithm #11360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Add On!
Thank you, Sanko! @cclauss, if possible, could you please check this pr out and approve a merge? Would be much appreciated :)) |
Please add a URL to a Wikipedia article or other source that explains what the algorithm does and why it is useful. |
Thank you, @cclauss, just did that! |
OK... Now that I know what the algorithm does, why would anyone ever want to use it? |
matrix/matrix_equalization.py
Outdated
import sys | ||
|
||
|
||
def array_equalization(vector: list[int], k: int) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-documenting variable names, please.
def array_equalization(vector: list[int], k: int) -> int: | |
def array_equalization(vector: list[int], step_size: int) -> int: |
matrix/matrix_equalization.py
Outdated
0 | ||
>>> array_equalization([22, 22, 22, 33, 33, 33], 2) | ||
2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need tests that have the same vector
but different values for step-size
including -1, 0, 1.3, and maxsize
.
matrix/matrix_equalization.py
Outdated
@@ -0,0 +1,47 @@ | |||
import sys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import sys | |
from sys import maxsize |
Just added an explanation in the description of this commit:
And thank you very much for the review, @cclauss , just implemented all recommendations suggested :)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With https://en.wikipedia.org/wiki/Single_instruction,_multiple_data and vectorization techniques being so prevalent these daze I doubt this would ever be used but here we go...
* adding a matrix equalization algorithm * Adding url for more details * Implementing suggestions
Describe your change:
Adding a matrix equalization algorithm, which equalizes all elements of the input vector to a common value, by making the minimal number of "updates" under the constraint of a step size (k).
This algorithm has practical use in scenarios where you need to achieve uniformity across elements of an array under specific constraints and with minimal changes. For example:
Checklist: