Skip to content
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

A way to apply transformations on sub-dimensions #142

Closed
9SMTM6 opened this issue Aug 12, 2022 · 2 comments
Closed

A way to apply transformations on sub-dimensions #142

9SMTM6 opened this issue Aug 12, 2022 · 2 comments

Comments

@9SMTM6
Copy link

9SMTM6 commented Aug 12, 2022

I read the closed issue on broadcasting support, but while that link linked to broadcasting, it seemed to me that the OP was asking for something different.

But, more importantly, broadcasting has specific semantics attched to it, which I can see why you would not /could not support them in Kotlin. But a general way to apply some transformation to one dimension, eg. subtracting a vector from all entries in a matrix, seems warranted to me.

What I currently do is less efficient and only works on the first dimension:

fun <T>D2Array<T>.broadcastInplace(operation: (input: MultiArray<T, D1>) -> D1Array<T>) {
    for (idx in 0 until this.shape[0]) {
        this[idx] = operation(this[idx])
    }
}

At the very least a way to loop through different dimensions would be appreciated.

@devcrocod
Copy link
Collaborator

I'm still thinking about it. So far, I'm only considering the option of broadcasting with copying, because any inplace operations cause a lot of problems.

@9SMTM6
Copy link
Author

9SMTM6 commented Aug 12, 2022

Yeah, I'd be able to live with that. This particular bit was just to closer match numpy, in which I had written the reference implementation of that algorithm, but at least I'd have found a way to live with copying. At least for now, performance isnt THAT critical yet.

Feel free to keep this open or close it how you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants