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

deprecate sqrtm in favor of sqrt #23504

Merged
merged 1 commit into from
Aug 31, 2017
Merged

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Aug 29, 2017

This pull request deprecates the spelling sqrtm for matrix square root in favor of sqrt. Followup to the much-debated #23233. Also ref. #19598 and #8450. Best!

@Sacha0 Sacha0 added deprecation This change introduces or involves a deprecation linear algebra Linear algebra labels Aug 29, 2017
@@ -676,7 +676,7 @@ end
a = rand(elty)
@test exp(a) == exp(a)
@test isposdef(one(elty))
@test sqrtm(a) == sqrt(a)
@test sqrt(a) == sqrt(a)
Copy link
Member

Choose a reason for hiding this comment

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

Could probably drop this test

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

might as well drop the exp(a) == exp(a) one too while at it.

Copy link
Member

Choose a reason for hiding this comment

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

If those tests fail, we know something more fundamentally, existentially wrong.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Well, we do also test @test true and @test !false, etc.

@andreasnoack andreasnoack merged commit 44fe78c into JuliaLang:master Aug 31, 2017
@garrison
Copy link
Sponsor Member

garrison commented Sep 1, 2017

One thing that bothers me about the new behavior is a way in which functions with a branch cut now behave differently between scalars and matrices. For instance,

julia> sqrt(diagm([-4]))
1×1 Array{Complex{Float64},2}:
 0.0 + 2.0im

julia> sqrt(-4)
ERROR: DomainError with -4.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

I did not see any mention of this in the discussion (though I have may missed it -- there is a lot of discussion, but much is for exp [#23233], a function with no branch cut).

This seems pretty minor to me, but I'm trying to think whether this behavior difference might have any meaningful consequences when writing generic code.

@fredrikekre
Copy link
Member

#4006

@StefanKarpinski
Copy link
Sponsor Member

It would definitely be good to see if we can get the branch cuts to match between scalars and matrices. That's the kind of attention to detail that we're into around here :)

@Sacha0 Sacha0 deleted the depsqrtm branch September 1, 2017 18:59
@Sacha0
Copy link
Member Author

Sacha0 commented Sep 1, 2017

Thanks all! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants