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

Added powc, powf, log and expf methods for complex numbers #137

Merged
merged 1 commit into from
Apr 17, 2016
Merged

Added powc, powf, log and expf methods for complex numbers #137

merged 1 commit into from
Apr 17, 2016

Conversation

liebharc
Copy link

I would like to have a few functions added for complex numbers (powf, log and exp function with arbitrary base). I've provided an implementation with this commit. However it requires more work and discussion and I've added comments to point out the parts which I'm especially unhappy with. Would be nice to get some feedback so that we can improve this pull request first.

#[inline]
pub fn powf(&self, value: T) -> Complex<T> {
let (r, theta) = self.to_polar();
Complex::from_polar(&(r.powf(value)), &(theta*value))
Copy link
Member

Choose a reason for hiding this comment

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

There are unneeded parens around r.powf(value).

@homu
Copy link
Contributor

homu commented Apr 13, 2016

☔ The latest upstream changes (presumably #164) made this pull request unmergeable. Please resolve the merge conflicts.

@liebharc
Copy link
Author

Thanks for your comment. I saw the merge failure, but there are also
open questions where I would be happy to get some guidance (what is a
good way to get Euler's constant of type T and what would be a good name
for the expb function?). Do you have any inputs on those questions so
that I can incorporate all comments in one push?

Am 4/13/2016 um 1:31 PM schrieb Homu:

☔ The latest upstream changes (presumably #164
#164) made this pull request
unmergeable. Please resolve the merge conflicts.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#137 (comment)

@hauleth
Copy link
Member

hauleth commented Apr 14, 2016

@liebharc It is nice that you have started discussion with @homu but this is only bot and I do not think that it will respond.

@liebharc
Copy link
Author

liebharc commented Apr 14, 2016 via email

@liebharc
Copy link
Author

Removing pull request since of missing feedback and I don't want to keep this around as a dead entry any longer.

@liebharc liebharc closed this Apr 14, 2016
@hauleth
Copy link
Member

hauleth commented Apr 14, 2016

It is not bad PR. Main reason why there was no feedback is that our work was focused on #164. Reopening.

Just rebase it on top of current master.

@hauleth hauleth reopened this Apr 14, 2016
@liebharc
Copy link
Author

I really appreciate your feedback! Thanks! I'm working on your review comments and will update the pull request as soon as I'm done.

#[inline]
pub fn log(&self, base: T) -> Complex<T> {
let (r, theta) = self.to_polar();
Complex::new(r.log(base), theta * T::one() / base.ln())
Copy link
Member

Choose a reason for hiding this comment

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

You don't need the one here, just theta / base.ln().

Please do write a formula comment for consistency on powf and log, as trivial as they may be.

Copy link
Author

Choose a reason for hiding this comment

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

You don't need the one here, just theta / base.ln().

There are times I feel stupid and sometimes this feeling is well justified. Thanks for the note I will update it soon!

@cuviper
Copy link
Member

cuviper commented Apr 15, 2016

Please update the PR title and message (first comment) as you go too, because these get immortalized in the merge commit.

@liebharc liebharc changed the title Added powf, log and expb functions for complex numbers Added powc, powf, log and expf methods for complex numbers Apr 15, 2016
@liebharc
Copy link
Author

Oh and this is the resource I used to figure out the powc formula: http://www.abecedarical.com/zenosamples/zs_complexnumbers.html

I double checked it by comparing some test cases against results obtained with GNU Octave.

@cuviper
Copy link
Member

cuviper commented Apr 17, 2016

Thanks!

@homu r+ 24fcc15

@homu homu merged commit 24fcc15 into rust-num:master Apr 17, 2016
homu added a commit that referenced this pull request Apr 17, 2016
Added powc, powf, log and expf methods for complex numbers

I would like to have a few functions added for complex numbers (powf, log and exp function with arbitrary base). I've provided an implementation with this commit. However it requires more work and discussion and I've added comments to point out the parts which I'm especially unhappy with. Would be nice to get some feedback so that we can improve this pull request first.
@homu
Copy link
Contributor

homu commented Apr 17, 2016

⚡ Test exempted - status

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

Successfully merging this pull request may close these issues.

4 participants