@@ -374,8 +374,8 @@ function schurpow(A::AbstractMatrix, p)
374
374
retmat = A ^ floor (p)
375
375
# Real part
376
376
if p - floor (p) == 0.5
377
- # special case: A^0.5 === sqrtm (A)
378
- retmat = retmat * sqrtm (A)
377
+ # special case: A^0.5 === sqrt (A)
378
+ retmat = retmat * sqrt (A)
379
379
else
380
380
retmat = retmat * powm! (UpperTriangular (float .(A)), real (p - floor (p)))
381
381
end
@@ -385,8 +385,8 @@ function schurpow(A::AbstractMatrix, p)
385
385
R = S ^ floor (p)
386
386
# Real part
387
387
if p - floor (p) == 0.5
388
- # special case: A^0.5 === sqrtm (A)
389
- R = R * sqrtm (S)
388
+ # special case: A^0.5 === sqrt (A)
389
+ R = R * sqrt (S)
390
390
else
391
391
R = R * powm! (UpperTriangular (float .(S)), real (p - floor (p)))
392
392
end
622
622
logm (a:: Complex ) = log (a)
623
623
624
624
"""
625
- sqrtm(A )
625
+ sqrt(A::AbstractMatrix )
626
626
627
627
If `A` has no negative real eigenvalues, compute the principal matrix square root of `A`,
628
628
that is the unique matrix ``X`` with eigenvalues having positive real part such that
@@ -646,40 +646,38 @@ julia> A = [4 0; 0 4]
646
646
4 0
647
647
0 4
648
648
649
- julia> sqrtm (A)
649
+ julia> sqrt (A)
650
650
2×2 Array{Float64,2}:
651
651
2.0 0.0
652
652
0.0 2.0
653
653
```
654
654
"""
655
- function sqrtm (A:: StridedMatrix{<:Real} )
655
+ function sqrt (A:: StridedMatrix{<:Real} )
656
656
if issymmetric (A)
657
- return full (sqrtm (Symmetric (A)))
657
+ return full (sqrt (Symmetric (A)))
658
658
end
659
659
n = checksquare (A)
660
660
if istriu (A)
661
- return full (sqrtm (UpperTriangular (A)))
661
+ return full (sqrt (UpperTriangular (A)))
662
662
else
663
663
SchurF = schurfact (complex (A))
664
- R = full (sqrtm (UpperTriangular (SchurF[:T ])))
664
+ R = full (sqrt (UpperTriangular (SchurF[:T ])))
665
665
return SchurF[:vectors ] * R * SchurF[:vectors ]'
666
666
end
667
667
end
668
- function sqrtm (A:: StridedMatrix{<:Complex} )
668
+ function sqrt (A:: StridedMatrix{<:Complex} )
669
669
if ishermitian (A)
670
- return full (sqrtm (Hermitian (A)))
670
+ return full (sqrt (Hermitian (A)))
671
671
end
672
672
n = checksquare (A)
673
673
if istriu (A)
674
- return full (sqrtm (UpperTriangular (A)))
674
+ return full (sqrt (UpperTriangular (A)))
675
675
else
676
676
SchurF = schurfact (A)
677
- R = full (sqrtm (UpperTriangular (SchurF[:T ])))
677
+ R = full (sqrt (UpperTriangular (SchurF[:T ])))
678
678
return SchurF[:vectors ] * R * SchurF[:vectors ]'
679
679
end
680
680
end
681
- sqrtm (a:: Number ) = (b = sqrt (complex (a)); imag (b) == 0 ? real (b) : b)
682
- sqrtm (a:: Complex ) = sqrt (a)
683
681
684
682
function inv (A:: StridedMatrix{T} ) where T
685
683
checksquare (A)
0 commit comments