Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Add (binary) operations for mutable variants #73

Open
japaric opened this issue May 11, 2015 · 0 comments
Open

Add (binary) operations for mutable variants #73

japaric opened this issue May 11, 2015 · 0 comments

Comments

@japaric
Copy link
Contributor

japaric commented May 11, 2015

Something like this:

impl Add<f32> for SubMatMut<f32> {
    type Output = SubMatMut<f32>;

    fn add(self, rhs: f32) -> SubMatMut<f32> {
        self.add_assign(rhs);
        self
    }
}

This would improve chaining, for instance one could cleanly write the sigmoid function as:

fn sigmoid(z: SubMatMut<f32>) -> SubMatMut<f32> {
    1. / (1. + (-z).exp())
}

// Assuming
// SubMatMut: Neg<Output=SubMatMut>
// exp: fn(SubMatMut) -> SubMatMut
// f32: Add<SubMatMut, Output=SubMatMut>
// f32: Div<SubMatMut, Output=SubMatMut>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant