Skip to content

deprecate sqrtm in favor of sqrt#23504

Merged
andreasnoack merged 1 commit into
JuliaLang:masterfrom
Sacha0:depsqrtm
Aug 31, 2017
Merged

deprecate sqrtm in favor of sqrt#23504
andreasnoack merged 1 commit into
JuliaLang:masterfrom
Sacha0:depsqrtm

Conversation

@Sacha0

@Sacha0 Sacha0 commented Aug 29, 2017

Copy link
Copy Markdown
Member

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
Comment thread test/linalg/dense.jl Outdated
@test exp(a) == exp(a)
@test isposdef(one(elty))
@test sqrtm(a) == sqrt(a)
@test sqrt(a) == sqrt(a)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@Sacha0 Sacha0 added this to the 1.0 milestone Aug 31, 2017
@andreasnoack andreasnoack merged commit 44fe78c into JuliaLang:master Aug 31, 2017
@garrison

garrison commented Sep 1, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@StefanKarpinski

Copy link
Copy Markdown
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

Sacha0 commented Sep 1, 2017

Copy link
Copy Markdown
Member Author

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