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

Scalar arithmetic #75

Open
carsonfarmer opened this issue May 22, 2017 · 0 comments
Open

Scalar arithmetic #75

carsonfarmer opened this issue May 22, 2017 · 0 comments

Comments

@carsonfarmer
Copy link

I may be missing something obvious, but is there a 'trick' to performing arithmetic on Matrices with scalars? Simple things like 1.0 + exp(A) seems to require working with a matrix's elements directly (which isn't very aesthetically pleasing), and a very specific ordering of arguments:

let A = Matrix<Double>([[1,  1], [1, -1]])
let B = A.copy()
A.elements = exp(A.elements) + 1.0  // works
A.elements = 1.0 + exp(A.elements)  // build error
print(1.0 + exp(A))  // build error
print(A)

Am I missing something obvious here? I can always add functions myself (e.g., exp), but I'd rather not if there is a 'right' way to do things here. I'm also interested in arithmetic on Tensors, which seem to have the same 'issues'. The Surge library from which Upsurge is forked had a few functions for things like exp on matrices, but these don't seem to be part of Upsurge, so I figured there must be an alternative?

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

No branches or pull requests

2 participants