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 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 Ana06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

lib/matrix.rb Outdated
@@ -1254,6 +1254,15 @@ def vstack(*matrices)
self.class.vstack(self, *matrices)
end

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about component instead of entry? 🤔

lib/matrix.rb Outdated
# => Matrix[[2.718281828459045, 1.0], [1.0, 2.718281828459045]]

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

lib/matrix.rb Outdated
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

lib/matrix.rb Outdated
# Matrix[[1, 0], [0, 1]].entrywise_exp
# => Matrix[[2.718281828459045, 1.0], [1.0, 2.718281828459045]]

def entrywise_exp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it is not very explicit

@grzegorz-jakubiak
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.

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