Adding applyMatrix#4200
Conversation
|
why not add a method to |
apply is defined in the D-level, so any additions to apply would need to be done there. I'm not sure of a clean way to access a matrix in the D-level, but perhaps there's a way to do that (if anyone knows, please send suggestions). Alternately, one could wrap the apply from the D-level to make a top level function that calls the D-code, except on matrices. This also unprotects apply, so, we'd also have to protect it. |
|
while I'm not a big fan of the whole D-level-function-wrapper, we've done it so many times already that why not here... |
I don't have anything against this alternate approach. I just picked an easy one to start the conversation. |
mahrud
left a comment
There was a problem hiding this comment.
This seems a little redundant with applyTable, but could be useful. Could you add docs and ideally a test though, perhaps near those of applyTable?
I think the reason this isn't already existing is that with matrices fixing the source and target is usually necessary, so I usually use map(tar, src, applyTable(entries m, blah)) instead. However, for mutable matrices we don't care about source and target, so it would be great if you could also add support for MutableMatrix input.
|
Also, could you edit the PR title? |
Adding applyMatrix to apply a function to all entries of a matrix at once.