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

Add Matrix#exponentiate method as Matlab's exp method #1762

Closed
wants to merge 0 commits into from

Conversation

@grzegorz-jakubiak
Copy link

grzegorz-jakubiak commented Nov 19, 2017

I prepared a pull request that includes exponentiate method which results in returning a new matrix with each element being an exponent of the number e. This is used e.g in machine learning and other types of calculations. #14116

@grzegorz-jakubiak grzegorz-jakubiak changed the title Add exponentiate method Add Matrix#exponentiate method Nov 19, 2017
@grzegorz-jakubiak grzegorz-jakubiak changed the title Add Matrix#exponentiate method Add Matrix#exponentiate method as Matlab's exp method Nov 19, 2017
@marcandre marcandre self-assigned this Nov 20, 2017
Copy link

Ana06 left a comment

I really like the idea 👍 I may choose a different name for the method 🤔

@@ -1254,6 +1254,15 @@ def vstack(*matrices)
self.class.vstack(self, *matrices)
end

#
# Returns a matrix with every entry being an exponent of e

This comment has been minimized.

Copy link
@Ana06

Ana06 Nov 20, 2017

what about component instead of entry? 🤔

# => Matrix[[2.718281828459045, 1.0], [1.0, 2.718281828459045]]

def entrywise_exp
collect{|e| Math.exp(e)}

This comment has been minimized.

Copy link
@Ana06

Ana06 Nov 20, 2017

what about calling the variable component? e is normally the letter used for the exponential and it may be confused.

@@ -1254,6 +1254,15 @@ def vstack(*matrices)
self.class.vstack(self, *matrices)
end

#
# Returns a matrix with every entry being an exponent of e
# Matrix[[1, 0], [0, 1]].entrywise_exp

This comment has been minimized.

Copy link
@Ana06

Ana06 Nov 20, 2017

You need to add some spaces here this so it is interpreted as code

# Matrix[[1, 0], [0, 1]].entrywise_exp
# => Matrix[[2.718281828459045, 1.0], [1.0, 2.718281828459045]]

def entrywise_exp

This comment has been minimized.

Copy link
@Ana06

Ana06 Nov 20, 2017

I would say it is not very explicit

@grzegorz-jakubiak

This comment has been minimized.

Copy link
Author

grzegorz-jakubiak commented Nov 20, 2017

@Ana06 Thanks for support! 😃 I've made changes according to what you pointed out. The name of the method was proposed at Ruby Redmine and I simply adopted it but if you've got better name I can change it.

@grzegorz-jakubiak grzegorz-jakubiak force-pushed the grzegorz-jakubiak:trunk branch from d8f0b4b to 530514f Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.