-
Notifications
You must be signed in to change notification settings - Fork 109
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
172 vector function #233
172 vector function #233
Conversation
|
||
@Override | ||
public void eachNonZeroInRow(int i, VectorProcedure procedure) { | ||
// FIXME |
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.
Please, remove FIXME.
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.
Of course, I just put these in to remind myself what I need to test. They will be removed.
Thanks @DWiechert! So, the rule is pretty simple:
|
We also need to refactor
|
Why does
|
Right. We have to change all of them. The problem is the same. |
So, is EVERY method in |
Not really, only those methods that works with columns/rows (those whose name is endding with Look, there is method w/o that postfix, like Matrix a =???
a.foldInRow(i, Vectors.asSumAccumulator(0.0)); // should be equivalent to
a.getRow(i).fold(Vectors.asSumAccumulator(0.0)); // a.getRow(i) returns Vector, then we cal fold on Vector |
@vkostyukov, I think I'm fully understanding this issue now and have made some changes. When you get a chance, can you look over the methods I deprecated and the new versions added in |
@DWiechert this looks good! I've totally forgot about |
Thanks for taking a quick look at the interface changes and verifying they're ok. Once I understood the changes that needed to be done it was pretty trivial. I'll get started on the implementation/testing later today and will update this issue when it's ready for the final review. |
* @param i the row index | ||
* @param function the vector function | ||
*/ | ||
void updateRow(int i, VectorFunction function); |
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.
@vkostyukov, I'm unsure about the implementation of this method and updateColumn
. The reason why I'm confused is because for the one that takes in a MatrixFunction
, it updates a single point, not a specific row/column. I was wondering if you could explain how you think this updateRow/Column
should work. Or if these are not to be updated, let me know.
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.
I see what you mean. We have a function updateRow
that should take a VectorFunction
, but it calls update
that takes MatrixFunction
. You need some sort of converters between vector function and matrix function. In my head it looks like following:
class RowVectorToMatrixFunction(VectorFunction underlying) implements MatrixFunction {
double evaluate(int i, int j, double value) {
return underlying.evaluate(j, value);
}
}
class ColumnVectorToMatrixFunction(VectorFunction underlying) implements MatrixFunction
@Override
public void updateRow(int i, VectorFunction function) {
Matrix function underlying = new RowVectorToMatrixFunction(function);
for (int j = 0; j < columns; j++) {
update(i, j, underlying);
}
}
We have two converters here RowVectorToMatrixFunction
that only consider to work with row-vector (only care about j-index) and an opposite case ColumnVectorToMatrixFunction
.
@vkostyukov, I've added the implementations to all of the new interface methods. I noticed there weren't a ton of original tests and I just copied the original ones and pointed to the new methods. Is that sufficient or would you like me to add tests for each individual method? |
@Override | ||
public void eachInRow(int i, VectorProcedure procedure) { | ||
for (int j = 0; j < columns; j++) { | ||
procedure.apply(j, get(i, j)); |
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.
Something wrong with indentation.
|
||
@Override | ||
public void updateColumn(int j, VectorFunction function) { | ||
// FIXME |
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.
Why fixme?
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.
Whoops, looks like I missed removing this one once I did the implementation. I'll remove this.
Thanks @DWiechert! This looks good. Could you please check the indentation and remove the FIXME notes? |
@vkostyukov, I've made those code review changes about indentation and removing the |
Thanks @DWiechert! This looks great! |
Preliminary code review of new functions. Tests will be added once I know the implementation is correct.