Mercurial > hg > octave-lyh
comparison src/DLD-FUNCTIONS/lu.cc @ 10080:cf70ee43077c
add tests for LU updating
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 11 Jan 2010 09:45:35 +0100 |
parents | f22bbc5d56e9 |
children | ab1101011a6d |
comparison
equal
deleted
inserted
replaced
10079:bf8b43fd4159 | 10080:cf70ee43077c |
---|---|
759 | 759 |
760 return retval; | 760 return retval; |
761 } | 761 } |
762 | 762 |
763 /* | 763 /* |
764 %!shared A, u, v, Ac, uc, vc | |
765 %! A = [0.091364 0.613038 0.999083; | |
766 %! 0.594638 0.425302 0.603537; | |
767 %! 0.383594 0.291238 0.085574; | |
768 %! 0.265712 0.268003 0.238409; | |
769 %! 0.669966 0.743851 0.445057 ]; | |
770 %! | |
771 %! u = [0.85082; | |
772 %! 0.76426; | |
773 %! 0.42883; | |
774 %! 0.53010; | |
775 %! 0.80683 ]; | |
776 %! | |
777 %! v = [0.98810; | |
778 %! 0.24295; | |
779 %! 0.43167 ]; | |
780 %! | |
781 %! Ac = [0.620405 + 0.956953i 0.480013 + 0.048806i 0.402627 + 0.338171i; | |
782 %! 0.589077 + 0.658457i 0.013205 + 0.279323i 0.229284 + 0.721929i; | |
783 %! 0.092758 + 0.345687i 0.928679 + 0.241052i 0.764536 + 0.832406i; | |
784 %! 0.912098 + 0.721024i 0.049018 + 0.269452i 0.730029 + 0.796517i; | |
785 %! 0.112849 + 0.603871i 0.486352 + 0.142337i 0.355646 + 0.151496i ]; | |
786 %! | |
787 %! uc = [0.20351 + 0.05401i; | |
788 %! 0.13141 + 0.43708i; | |
789 %! 0.29808 + 0.08789i; | |
790 %! 0.69821 + 0.38844i; | |
791 %! 0.74871 + 0.25821i ]; | |
792 %! | |
793 %! vc = [0.85839 + 0.29468i; | |
794 %! 0.20820 + 0.93090i; | |
795 %! 0.86184 + 0.34689i ]; | |
796 %! | |
797 | |
798 %!test | |
799 %! [L,U,P] = lu(A); | |
800 %! [L,U] = luupdate(L,U,P*u,v); | |
801 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
802 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
803 %! assert(norm(vec(P'*L*U - A - u*v.'),Inf) < norm(A)*1e1*eps) | |
804 %! | |
805 %!test | |
806 %! [L,U,P] = lu(Ac); | |
807 %! [L,U] = luupdate(L,U,P*uc,vc); | |
808 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
809 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
810 %! assert(norm(vec(P'*L*U - Ac - uc*vc.'),Inf) < norm(Ac)*1e1*eps) | |
811 | |
812 %!test | |
813 %! [L,U,P] = lu(single(A)); | |
814 %! [L,U] = luupdate(L,U,P*single(u),single(v)); | |
815 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
816 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
817 %! assert(norm(vec(P'*L*U - single(A) - single(u)*single(v).'),Inf) < norm(single(A))*1e1*eps('single')) | |
818 %! | |
819 %!test | |
820 %! [L,U,P] = lu(single(Ac)); | |
821 %! [L,U] = luupdate(L,U,P*single(uc),single(vc)); | |
822 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
823 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
824 %! assert(norm(vec(P'*L*U - single(Ac) - single(uc)*single(vc).'),Inf) < norm(single(Ac))*1e1*eps('single')) | |
825 | |
826 %!test | |
827 %! [L,U,P] = lu(A); | |
828 %! [L,U,P] = luupdate(L,U,P,u,v); | |
829 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
830 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
831 %! assert(norm(vec(P'*L*U - A - u*v.'),Inf) < norm(A)*1e1*eps) | |
832 %! | |
833 %!test | |
834 %! [L,U,P] = lu(Ac); | |
835 %! [L,U,P] = luupdate(L,U,P,uc,vc); | |
836 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
837 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
838 %! assert(norm(vec(P'*L*U - Ac - uc*vc.'),Inf) < norm(Ac)*1e1*eps) | |
839 | |
840 %!test | |
841 %! [L,U,P] = lu(single(A)); | |
842 %! [L,U,P] = luupdate(L,U,P,single(u),single(v)); | |
843 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
844 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
845 %! assert(norm(vec(P'*L*U - single(A) - single(u)*single(v).'),Inf) < norm(single(A))*1e1*eps('single')) | |
846 %! | |
847 %!test | |
848 %! [L,U,P] = lu(single(Ac)); | |
849 %! [L,U,P] = luupdate(L,U,P,single(uc),single(vc)); | |
850 %! assert(norm(vec(tril(L)-L),Inf) == 0) | |
851 %! assert(norm(vec(triu(U)-U),Inf) == 0) | |
852 %! assert(norm(vec(P'*L*U - single(Ac) - single(uc)*single(vc).'),Inf) < norm(single(Ac))*1e1*eps('single')) | |
853 */ | |
854 | |
855 /* | |
764 ;;; Local Variables: *** | 856 ;;; Local Variables: *** |
765 ;;; mode: C++ *** | 857 ;;; mode: C++ *** |
766 ;;; End: *** | 858 ;;; End: *** |
767 */ | 859 */ |