Commit 6913f9c
authored
Compute real matrix logarithm and matrix square root using real arithmetic (JuliaLang#39973)
* Add failing test
* Add sylvester methods for small matrices
* Add 2x2 real matrix square root
* Add real square root of quasitriangular matrix
* Simplify 2x2 real square root
* Rename functions to use quasitriu
* Avoid NaNs when eigenvalues are all zero
* Reuse ranges
* Add clarifying comments
* Unify real and complex matrix square root
* Add reference for real sqrt
* Move quasitriu auxiliary functions to triangular.jl
* Ensure loops are type-stable and use simd
* Remove duplicate computation
* Correctly promote for dimensionful A
* Use simd directive
* Test that UpperTriangular is returned by sqrt
* Test sqrt for UnitUpperTriangular
* Test that return type is complex when input type is
* Test that output is complex when input is
* Add failing test
* Separate type-stable from type-unstable part
* Use generic sqrt_quasitriu for sqrt triu
* Avoid redundant matmul
* Clarify comment
* Return complex output for complex input
* Call log_quasitriu
* Add failing test for log type-inferrability
* Realify or complexify as necessary
* Call sqrt_quasitriu directly
* Refactor sqrt_diag!
* Simplify utility function
* Add comment
* Compute accurate block-diagonal
* Compute superdiagonal for quasi triu A0
* Compute accurate block superdiagonal
* Avoid full LU decomposition in inner loop
* Avoid promotion to improve type-stability
* Modify return type if necessary
* Clarify comment
* Add comments
* Call log_quasitriu on quasitriu matrices
* Document quasi-triangular algorithm
* Remove test
This matrix has eigenvalues to close to zero that its eltype is not stable
* Rearrange definition
* Add compatibility for unit triangular matrices
* Release constraints on tests
* Separate copying of A from log computation
* Revert "Separate copying of A from log computation"
This reverts commit 23becc5.
* Use Givens rotations
* Compute Schur in-place when possible
* Always allocate a copy
* Fix block indexing
* Compute sqrt in-place
* Overwrite AmI
* Reduce allocations in Pade approximation
* Use T
* Don't unnecessarily unwrap
* Test remaining log branches
* Add additional matrix square root tests
* Separate type-unstable from type-stable part
This substantially reduces allocations for some reason
* Use Ref instead of a Vector
* Eliminate allocation in checksquare
* Refactor param choosing code to own function
* Comment section
* Use more descriptive variable name
* Reuse temporaries
* Add reference
* More accurately describe condition1 parent e20c3da commit 6913f9c
File tree
5 files changed
+743
-187
lines changed- stdlib/LinearAlgebra
- src
- test
5 files changed
+743
-187
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | | - | |
| 682 | + | |
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
692 | | - | |
693 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
694 | 695 | | |
695 | 696 | | |
696 | 697 | | |
| |||
713 | 714 | | |
714 | 715 | | |
715 | 716 | | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
726 | 724 | | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
736 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
737 | 739 | | |
738 | 740 | | |
739 | 741 | | |
| |||
755 | 757 | | |
756 | 758 | | |
757 | 759 | | |
| 760 | + | |
| 761 | + | |
758 | 762 | | |
759 | 763 | | |
760 | 764 | | |
761 | 765 | | |
762 | 766 | | |
763 | 767 | | |
764 | 768 | | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
765 | 775 | | |
766 | 776 | | |
767 | 777 | | |
| |||
775 | 785 | | |
776 | 786 | | |
777 | 787 | | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 788 | + | |
792 | 789 | | |
793 | 790 | | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
| 791 | + | |
| 792 | + | |
798 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
799 | 811 | | |
800 | 812 | | |
801 | | - | |
802 | | - | |
| 813 | + | |
803 | 814 | | |
804 | 815 | | |
805 | 816 | | |
| |||
1526 | 1537 | | |
1527 | 1538 | | |
1528 | 1539 | | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
1529 | 1568 | | |
1530 | 1569 | | |
1531 | 1570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6449 | 6449 | | |
6450 | 6450 | | |
6451 | 6451 | | |
6452 | | - | |
| 6452 | + | |
6453 | 6453 | | |
6454 | 6454 | | |
6455 | 6455 | | |
6456 | 6456 | | |
6457 | 6457 | | |
6458 | 6458 | | |
6459 | 6459 | | |
6460 | | - | |
| 6460 | + | |
6461 | 6461 | | |
6462 | 6462 | | |
6463 | 6463 | | |
| |||
6467 | 6467 | | |
6468 | 6468 | | |
6469 | 6469 | | |
6470 | | - | |
| 6470 | + | |
6471 | 6471 | | |
6472 | 6472 | | |
6473 | 6473 | | |
| |||
0 commit comments