702 | | TEST (LQGU_PMSM_test){ |
703 | | bdm_assert(0, "Test not implemented."); |
| 702 | /*TEST (LQGU_PMSM_test){ |
| 703 | |
| 704 | int K = 10; |
| 705 | int Kt = 100; |
| 706 | int N = 50; |
| 707 | |
| 708 | double a = 0.9898; |
| 709 | double b = 0.0072; |
| 710 | double c = 0.0361; |
| 711 | double d = 1; |
| 712 | double e = 0.0149; |
| 713 | |
| 714 | double OMEGAt = 2.15; |
| 715 | double DELTAt = 0.000125; |
| 716 | |
| 717 | double v = 0.0001; |
| 718 | double w = 1; |
| 719 | |
| 720 | mat A(5,5); |
| 721 | A.zeros(); |
| 722 | A(0,0) = a; |
| 723 | A(1,1) = a; |
| 724 | A(2,2) = d; |
| 725 | A(3,3) = 1.0; |
| 726 | A(4,4) = 1.0; |
| 727 | A(2,4) = d-1.0; |
| 728 | A(3,2) = DELTAt; |
| 729 | A(3,4) = DELTAt; |
| 730 | |
| 731 | mat B(5,2); |
| 732 | B.zeros(); |
| 733 | B(0,0) = c; |
| 734 | B(1,1) = c; |
| 735 | |
| 736 | mat C(2,5); |
| 737 | C.zeros(); |
| 738 | C(0,0) = c; |
| 739 | C(1,1) = c; |
| 740 | |
| 741 | mat X(5,5); |
| 742 | X.zeros(); |
| 743 | X(2,2) = w; |
| 744 | |
| 745 | mat Y(2,2); |
| 746 | Y.zeros(); |
| 747 | Y(0,0) = v; |
| 748 | Y(1,1) = v; |
| 749 | |
| 750 | mat Q(5,5); |
| 751 | Q.zeros(); |
| 752 | Q(0,0) = 0.0013; |
| 753 | Q(1,1) = 0.0013; |
| 754 | Q(2,2) = 5e-6; |
| 755 | Q(3,3) = 1e-10; |
| 756 | |
| 757 | mat R(2,2); |
| 758 | R.zeros(); |
| 759 | R(0,0) = 0.0006; |
| 760 | R(0,0) = 0.0006; |
| 761 | |
| 762 | vec x0(5); |
| 763 | x0.zeros(); |
| 764 | x0(2) = 1.0-OMEGAt; |
| 765 | x0(3) = itpp::pi / 2; |
| 766 | x0(4) = OMEGAt; |
| 767 | |
| 768 | mat P(5,5); |
| 769 | P.zeros(); |
| 770 | P(0,0) = 0.01; |
| 771 | P(1,1) = 0.01; |
| 772 | P(2,2) = 0.01; |
| 773 | P(3,3) = 0.01; |
| 774 | |
| 775 | |
| 776 | //vec u0(Kt+K); |
| 777 | //vec u1(Kt+K); |
| 778 | //mat u(2,Kt+K) |
| 779 | vec u(2); |
| 780 | |
| 781 | //vec x0(Kt+K); |
| 782 | //vec x1(Kt+K); |
| 783 | //vec x2(Kt+K); |
| 784 | //vec x3(Kt+K); |
| 785 | //vec x4(Kt+K); |
| 786 | mat x(5,Kt+K); |
| 787 | |
| 788 | //vec y0(Kt+K); |
| 789 | //vec y1(Kt+K); |
| 790 | mat y(2, Kt+K); |
| 791 | |
| 792 | mat Pk(5, 5); |
| 793 | |
| 794 | mat KK(5, 2); |
| 795 | |
| 796 | mat L(2, 5); |
| 797 | mat L0(5, Kt); |
| 798 | mat L1(5, Kt); |
| 799 | |
| 800 | int i,n,k,kt; |
| 801 | vec x00(5); |
| 802 | vec randvec(2); |
| 803 | |
| 804 | LQG_universal lq; |
| 805 | lq.rv = RV("u", 2, 0); |
| 806 | lq.set_rvc(RV("x", 5, 0)); |
| 807 | lq.horizon = K; |
| 808 | |
| 809 | Array<linfnEx> model(2); |
| 810 | model(0).A = A; |
| 811 | model(0).B = vec("0 0 0 0 0"); |
| 812 | model(0).rv = RV("x", 5, 0); |
| 813 | model(0).rv_ret = RV("x", 5, 1); |
| 814 | model(1).A = B; |
| 815 | model(1).B = vec("0 0"); |
| 816 | model(1).rv = RV("u", 2, 0); |
| 817 | model(1).rv_ret = RV("x", 5, 1); |
| 818 | lq.Models = model; |
| 819 | |
| 820 | Array<quadraticfn> qloss(2); |
| 821 | qloss(0).Q.setCh(X); |
| 822 | qloss(0).rv = RV("x", 5, 1); |
| 823 | qloss(1).Q.setCh(Y); |
| 824 | qloss(1).rv = RV("u", 2, 0); |
| 825 | lq.Losses = qloss; |
| 826 | |
| 827 | lq.finalLoss.Q.setCh(X); |
| 828 | lq.finalLoss.rv = RV("x", 5, 1); |
| 829 | |
| 830 | lq.validate(); |
| 831 | |
| 832 | vec losses(N); |
| 833 | losses.zeros(); |
| 834 | |
| 835 | double loss; |
| 836 | |
| 837 | for(n = 0; n < N; n++) { |
| 838 | L0.zeros(); |
| 839 | L1.zeros(); |
| 840 | Pk.zeros(); |
| 841 | |
| 842 | for(i=0;i<4;i++) x00(i) = x0(i) + sqrt(P(i,i))*randn(); |
| 843 | |
| 844 | for(kt = 0; kt < Kt; kt++){ |
| 845 | x.set_col(0, x00); |
| 846 | y.set_col(0, x.get_col(0).get(0,1)); |
| 847 | for(k = 0; k < kt+K-1; k++){ |
| 848 | L.set_size(2,5); |
| 849 | L.set_row(0, L0.get_col(kt)); |
| 850 | L.set_row(1, L1.get_col(kt)); |
| 851 | u = L*x.get_col(k); |
| 852 | |
| 853 | /*if(k > 2){ |
| 854 | cout << "Pk " << Pk << endl; |
| 855 | cout << "C " << C << endl; |
| 856 | cout << "R " << R << endl; |
| 857 | cout << "Pk * C.transpose() " << Pk * C.transpose() << endl; |
| 858 | cout << "inv(C * Pk * C.transpose() + R) " << inv(C * Pk * C.transpose() + R) << endl; |
| 859 | cout << "Pk * C.transpose() * inv(C * Pk * C.transpose() + R) " << Pk * C.transpose() * inv(C * Pk * C.transpose() + R) << endl; |
| 860 | }*/ |
| 861 | /*KK = Pk * C.transpose() * inv(C * Pk * C.transpose() + R); |
| 862 | |
| 863 | x(0, k+1) = a*x(0, k) + b*(x(2, k) + x(4, k))*sin(x(3, k)) + c*u(0) + sqrt(Q(0, 0))*randn(); |
| 864 | x(1, k+1) = a*x(1, k) - b*(x(2, k) + x(4, k))*cos(x(3, k)) + c*u(1) + sqrt(Q(1, 1))*randn(); |
| 865 | x(2, k+1) = d*x(2, k) + (d-1)*x(4, k) + e*(x(1, k)*cos(x(3, k)) - x(0, k)*sin(x(3, k))) + sqrt(Q(2, 2))*randn(); |
| 866 | x(3, k+1) = x(3, k) + (x(2, k) + x(4, k))*DELTAt + sqrt(Q(3, 3))*randn(); |
| 867 | x(4, k+1) = x(4, k); |
| 868 | |
| 869 | x.set_col(k+1, x.get_col(k+1) - KK * (y.get_col(k) - x.get_col(k).get(0,1))); |
| 870 | randvec(0) = randn(); |
| 871 | randvec(1) = randn(); |
| 872 | y.set_col(k+1, x.get_col(k+1).get(0,1) + R * randvec); |
| 873 | |
| 874 | A(2, 0) = -e*sin(x(3, k)); |
| 875 | A(2, 1) = e*cos(x(3, k)); |
| 876 | A(0, 2) = b*sin(x(3, k)); |
| 877 | A(1, 2) = -b*cos(x(3, k)); |
| 878 | A(0, 3) = b*(x(2, k) + x(4, k))*cos(x(3, k)); |
| 879 | A(1, 3) = b*(x(2, k) + x(4, k))*sin(x(3, k)); |
| 880 | A(2, 3) = -e*(x(1, k)*sin(x(3, k) + x(0, k)*cos(x(3, k)))); |
| 881 | A(0, 4) = b*sin(x(3, k)); |
| 882 | A(1, 4) = -b*cos(x(3, k)); |
| 883 | //cout << "A(" << k << "): " << endl << A << endl; |
| 884 | Pk = A * (Pk - Pk * C.transpose() * inv(C * Pk * C.transpose() + R) * C * Pk) * A.transpose() + Q; |
| 885 | cout << "Pk(" << k << "): " << endl << Pk << endl; |
| 886 | } |
| 887 | |
| 888 | lq.resetTime(); |
| 889 | lq.redesign(); |
| 890 | for(k = K-1; k > 0; k--){ |
| 891 | A(2, 0) = -e*sin(x(3, k+kt-1)); |
| 892 | A(2, 1) = e*cos(x(3, k+kt-1)); |
| 893 | A(0, 2) = b*sin(x(3, k+kt-1)); |
| 894 | A(1, 2) = -b*cos(x(3, k+kt-1)); |
| 895 | A(0, 3) = b*(x(2, k+kt-1) + x(4, k+kt-1))*cos(x(3, k+kt-1)); |
| 896 | A(1, 3) = b*(x(2, k+kt-1) + x(4, k+kt-1))*sin(x(3, k+kt-1)); |
| 897 | A(2, 3) = -e*(x(1, k+kt-1)*sin(x(3, k+kt-1) + x(0,k+kt-1)*cos(x(3, k+kt-1)))); |
| 898 | A(0, 4) = b*sin(x(3, k+kt-1)); |
| 899 | A(1, 4) = -b*cos(x(3, k+kt-1)); |
| 900 | lq.Models(0).A = A; |
| 901 | lq.redesign(); |
| 902 | } |
| 903 | L = lq.getL(); |
| 904 | L0.set_col(kt, L.get_row(0).get(0,4)); |
| 905 | L1.set_col(kt, L.get_row(1).get(0,4)); |
| 906 | } |
| 907 | |
| 908 | x.set_col(0, x00); |
| 909 | y.set_col(0, x.get_col(0).get(0,1)); |
| 910 | |
| 911 | loss = 0; |
| 912 | |
| 913 | for(k = 0; k < Kt; k++){ |
| 914 | L.set_row(0, L0.get_col(k)); |
| 915 | L.set_row(1, L1.get_col(k)); |
| 916 | u = L*x.get_col(k); |
| 917 | |
| 918 | KK = Pk * C.transpose() * inv(C * Pk * C.transpose() + R); |
| 919 | |
| 920 | x(0, k+1) = a*x(0, k) + b*(x(2, k) + x(4, k))*sin(x(3, k)) + c*u(0) + sqrt(Q(0, 0))*randn(); |
| 921 | x(1, k+1) = a*x(1, k) - b*(x(2, k) + x(4, k))*cos(x(3, k)) + c*u(1) + sqrt(Q(1, 1))*randn(); |
| 922 | x(2, k+1) = d*x(2, k) + (d-1)*x(4, k) + e*(x(1, k)*cos(x(3, k)) - x(0, k)*sin(x(3, k))) + sqrt(Q(2, 2))*randn(); |
| 923 | x(3, k+1) = x(3, k) + (x(2, k) + x(4, k))*DELTAt + sqrt(Q(3, 3))*randn(); |
| 924 | x(4, k+1) = x(4, k); |
| 925 | |
| 926 | loss += (x.get_col(k+1).transpose() * X * x.get_col(k+1).transpose())(0,0); |
| 927 | loss += (u.transpose() * Y * u)(0); |
| 928 | |
| 929 | x.set_col(k+1, x.get_col(k+1) - KK * (y.get_col(k) - x.get_col(k).get(0,1))); |
| 930 | randvec(0) = randn(); |
| 931 | randvec(1) = randn(); |
| 932 | y.set_col(k+1, x.get_col(k+1).get(0,1) + R * randvec); |
| 933 | |
| 934 | A(2, 0) = -e*sin(x(3, k)); |
| 935 | A(2, 1) = e*cos(x(3, k)); |
| 936 | A(0, 2) = b*sin(x(3, k)); |
| 937 | A(1, 2) = -b*cos(x(3, k)); |
| 938 | A(0, 3) = b*(x(2, k) + x(4, k))*cos(x(3, k)); |
| 939 | A(1, 3) = b*(x(2, k) + x(4, k))*sin(x(3, k)); |
| 940 | A(2, 3) = -e*(x(1, k)*sin(x(3, k) + x(0, k)*cos(x(3, k)))); |
| 941 | A(0, 4) = b*sin(x(3, k)); |
| 942 | A(1, 4) = -b*cos(x(3, k)); |
| 943 | |
| 944 | Pk = A * (Pk - Pk * C.transpose() * inv(C * Pk * C.transpose() + R) * C * Pk) * A.transpose() + Q; |
| 945 | } |
| 946 | |
| 947 | losses(n) = loss; |
| 948 | |
| 949 | } |
| 950 | |
| 951 | cout << "Ztrata: " << sum(losses)/n << endl; |
706 | | TEST (LQGU_large_test){ |
707 | | bdm_assert(0, "Test not implemented."); |
708 | | } |
709 | | |
710 | | TEST (validation_test){ |
| 954 | //TEST (LQGU_large_test){ |
| 955 | /* |
| 956 | loss = /Q1*x(+1) + /Q2*y + /Q3*z + /Q4*u + /Q5*[x(+1); y; 1] + /Q6*[z; u; 1] + /Q7*[x(+1); y; z; u; 1] |
| 957 | u = rv |
| 958 | x = rvc |
| 959 | y = A1*[x; 1] + B1 |
| 960 | z = A2*[x; u; 1] + B2 |
| 961 | x(+1) = A3*[x; 1] + B3 |
| 962 | */ |
| 963 | //uniform random generator |
| 964 | /*Uniform_RNG urng; |
| 965 | int max_size = 10; |
| 966 | double maxmult = 10.0; |
| 967 | |
| 968 | urng.setup(2.0, max_size); |
| 969 | int xsize = round(urng()); |
| 970 | int usize = round(urng()); |
| 971 | int ysize = round(urng()); |
| 972 | int zsize = round(urng()); |
| 973 | cout << "CFG: " << xsize << " " << ysize << " " << zsize << " " << usize << " " << endl; |
| 974 | urng.setup(-maxmult, maxmult); |
| 975 | mat tmpmat; |
| 976 | mat A1,A2,A3,Q1,Q2,Q3,Q4,Q5,Q6,Q7; |
| 977 | vec B1,B2,B3; |
| 978 | |
| 979 | A1 = urng(ysize,xsize+1); |
| 980 | B1 = urng(ysize); |
| 981 | A2 = urng(zsize,xsize+usize+1); |
| 982 | B2 = urng(zsize); |
| 983 | A3 = urng(xsize,xsize+1); |
| 984 | B3 = urng(xsize); |
| 985 | |
| 986 | tmpmat = urng(xsize,xsize); |
| 987 | Q1 = tmpmat*tmpmat.transpose(); |
| 988 | tmpmat = urng(ysize,ysize); |
| 989 | Q2 = tmpmat*tmpmat.transpose(); |
| 990 | tmpmat = urng(zsize,zsize); |
| 991 | Q3 = tmpmat*tmpmat.transpose(); |
| 992 | tmpmat = urng(usize,usize); |
| 993 | Q4 = tmpmat*tmpmat.transpose(); |
| 994 | tmpmat = urng(xsize+ysize+1,xsize+ysize+1); |
| 995 | Q5 = tmpmat*tmpmat.transpose(); |
| 996 | tmpmat = urng(zsize+usize+1,zsize+usize+1); |
| 997 | Q6 = tmpmat*tmpmat.transpose(); |
| 998 | tmpmat = urng(xsize+ysize+zsize+usize+1,xsize+ysize+zsize+usize+1); |
| 999 | Q7 = tmpmat*tmpmat.transpose(); |
| 1000 | |
| 1001 | |
| 1002 | //starting configuration |
| 1003 | vec x0; |
| 1004 | x0 = urng(xsize); |
| 1005 | |
| 1006 | //test of universal LQG controller |
| 1007 | LQG_universal lq; |
| 1008 | lq.rv = RV("u", usize, 0); |
| 1009 | lq.set_rvc(RV("x", xsize, 0)); |
| 1010 | lq.horizon = 100; |
| 1011 | |
| 1012 | RV tmprv; |
| 1013 | |
| 1014 | //model |
| 1015 | Array<linfnEx> model(3); |
| 1016 | model(0).A = A1; |
| 1017 | model(0).B = B1; |
| 1018 | tmprv = RV("x", xsize, 0); |
| 1019 | tmprv.add(RV("1",1,0)); |
| 1020 | model(0).rv = tmprv; |
| 1021 | model(0).rv_ret = RV("y", ysize, 0); |
| 1022 | model(1).A = A2; |
| 1023 | model(1).B = B2; |
| 1024 | tmprv = RV("x", xsize, 0); |
| 1025 | tmprv.add(RV("u", usize, 0)); |
| 1026 | tmprv.add(RV("1",1,0)); |
| 1027 | model(1).rv = tmprv; |
| 1028 | model(1).rv_ret = RV("z", zsize, 0); |
| 1029 | model(2).A = A3; |
| 1030 | model(2).B = B3; |
| 1031 | tmprv = RV("x", xsize, 0); |
| 1032 | tmprv.add(RV("1",1,0)); |
| 1033 | model(2).rv = tmprv; |
| 1034 | model(2).rv_ret = RV("x", xsize, 1); |
| 1035 | //setup |
| 1036 | lq.Models = model; |
| 1037 | |
| 1038 | //loss |
| 1039 | Array<quadraticfn> loss(7); |
| 1040 | loss(0).Q.setCh(Q1); |
| 1041 | loss(0).rv = RV("x", xsize, 1); |
| 1042 | loss(1).Q.setCh(Q2); |
| 1043 | loss(1).rv = RV("y", ysize, 0); |
| 1044 | loss(2).Q.setCh(Q3); |
| 1045 | loss(2).rv = RV("z", zsize, 0); |
| 1046 | loss(3).Q.setCh(Q4); |
| 1047 | loss(3).rv = RV("u", usize, 0); |
| 1048 | loss(4).Q.setCh(Q5); |
| 1049 | tmprv = RV("x", xsize, 1); |
| 1050 | tmprv.add(RV("y", ysize, 0)); |
| 1051 | tmprv.add(RV("1",1,0)); |
| 1052 | loss(4).rv = tmprv; |
| 1053 | loss(5).Q.setCh(Q6); |
| 1054 | tmprv = RV("z", zsize, 0); |
| 1055 | tmprv.add(RV("u", usize, 0)); |
| 1056 | tmprv.add(RV("1",1,0)); |
| 1057 | loss(5).rv = tmprv; |
| 1058 | loss(6).Q.setCh(Q7); |
| 1059 | tmprv = RV("x", xsize, 1); |
| 1060 | tmprv.add(RV("y", ysize, 0)); |
| 1061 | tmprv.add(RV("z", zsize, 0)); |
| 1062 | tmprv.add(RV("u", usize, 0)); |
| 1063 | tmprv.add(RV("1",1,0)); |
| 1064 | loss(6).rv = tmprv; |
| 1065 | //setup |
| 1066 | lq.Losses = loss; |
| 1067 | |
| 1068 | //finalloss setup |
| 1069 | tmpmat = urng(xsize,xsize); |
| 1070 | lq.finalLoss.Q.setCh(tmpmat*tmpmat.transpose()); |
| 1071 | lq.finalLoss.rv = RV("x", xsize, 1); |
| 1072 | |
| 1073 | lq.validate(); |
| 1074 | |
| 1075 | //produce last control matrix L |
| 1076 | lq.redesign(); |
| 1077 | cout << lq.getL() << endl; |
| 1078 | |
| 1079 | int i; |
| 1080 | for(i = 0; i < lq.horizon - 1; i++) { |
| 1081 | lq.redesign(); |
| 1082 | } |
| 1083 | cout << lq.getL() << endl; |
| 1084 | |
| 1085 | mat K; |
| 1086 | K = A3.get_cols(0, xsize-1).transpose()*Q1.transpose()*Q1*A3.get_cols(0, xsize-1) |
| 1087 | + A1.get_cols(0, xsize-1).transpose()*Q2.transpose()*Q2*A1.get_cols(0, xsize-1) |
| 1088 | + A2.get_cols(0, xsize-1).transpose()*Q3.transpose()*Q3*A2.get_cols(0, xsize-1) |
| 1089 | + A3.get_cols(0, xsize-1).transpose()*Q5.get_cols(0, xsize-1).transpose()*Q5.get_cols(0, xsize-1)*A3.get_cols(0, xsize-1) |
| 1090 | + A1.get_cols(0, xsize-1).transpose()*Q5.get_cols(xsize, xsize+ysize-1).transpose()*Q5.get_cols(xsize, xsize+ysize-1)*A1.get_cols(0, xsize-1) |
| 1091 | + A2.get_cols(0, xsize-1).transpose()*Q6.get_cols(0, zsize-1).transpose()*Q6.get_cols(0, zsize-1)*A2.get_cols(0, xsize-1) |
| 1092 | + A3.get_cols(0, xsize-1).transpose()*Q7.get_cols(0, xsize-1).transpose()*Q7.get_cols(0, xsize-1)*A3.get_cols(0, xsize-1) |
| 1093 | + A1.get_cols(0, xsize-1).transpose()*Q7.get_cols(xsize, xsize+ysize-1).transpose()*Q7.get_cols(xsize, xsize+ysize-1)*A1.get_cols(0, xsize-1) |
| 1094 | + A2.get_cols(0, xsize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1)*A2.get_cols(0, xsize-1); |
| 1095 | |
| 1096 | mat L; |
| 1097 | L = A2.get_cols(xsize, xsize+usize-1).transpose()*Q3.transpose()*Q3*A2.get_cols(xsize, xsize+usize-1) |
| 1098 | + Q4.transpose()*Q4 |
| 1099 | + A2.get_cols(xsize, xsize+usize-1).transpose()*Q6.get_cols(0, zsize-1).transpose()*Q6.get_cols(0, zsize-1)*A2.get_cols(xsize, xsize+usize-1) |
| 1100 | + Q6.get_cols(zsize, zsize+usize-1).transpose()*Q6.get_cols(zsize, zsize+usize-1) |
| 1101 | + A2.get_cols(xsize, xsize+usize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1)*A2.get_cols(xsize, xsize+usize-1) |
| 1102 | + Q7.get_cols(xsize+ysize+zsize, xsize+ysize+zsize+usize-1).transpose()*Q7.get_cols(xsize+ysize+zsize, xsize+ysize+zsize+usize-1); |
| 1103 | |
| 1104 | double M; |
| 1105 | M = (A3.get_cols(xsize,xsize).transpose()*Q1.transpose()*Q1*A3.get_cols(xsize,xsize))(0,0) |
| 1106 | + (B3.transpose()*Q1.transpose()*Q1*B3)(0) |
| 1107 | + (A1.get_cols(xsize,xsize).transpose()*Q2.transpose()*Q2*A1.get_cols(xsize,xsize))(0,0) |
| 1108 | + (B1.transpose()*Q2.transpose()*Q2*B1)(0) |
| 1109 | + (A2.get_cols(xsize+usize,xsize+usize).transpose()*Q3.transpose()*Q3*A2.get_cols(xsize+usize,xsize+usize))(0,0) |
| 1110 | + (B2.transpose()*Q3.transpose()*Q3*B2)(0) |
| 1111 | + (A3.get_cols(xsize,xsize).transpose()*Q5.get_cols(0, xsize-1).transpose()*Q5.get_cols(0, xsize-1)*A3.get_cols(xsize,xsize))(0,0) |
| 1112 | + (B3.transpose()*Q5.get_cols(0, xsize-1).transpose()*Q5.get_cols(0, xsize-1)*B3)(0) |
| 1113 | + (A1.get_cols(xsize,xsize).transpose()*Q5.get_cols(xsize, xsize+ysize-1).transpose()*Q5.get_cols(xsize, xsize+ysize-1)*A1.get_cols(xsize,xsize))(0,0) |
| 1114 | + (B1.transpose()*Q5.get_cols(xsize, xsize+ysize-1).transpose()*Q5.get_cols(xsize, xsize+ysize-1)*B1)(0) |
| 1115 | + (Q5.get_cols(xsize+ysize,xsize+ysize).transpose()*Q5.get_cols(xsize+ysize,xsize+ysize))(0,0) |
| 1116 | + (A2.get_cols(xsize+usize,xsize+usize).transpose()*Q6.get_cols(0, zsize-1).transpose()*Q6.get_cols(0, zsize-1)*A2.get_cols(xsize+usize,xsize+usize))(0,0) |
| 1117 | + (B2.transpose()*Q6.get_cols(0, zsize-1).transpose()*Q6.get_cols(0, zsize-1)*B2)(0) |
| 1118 | + (Q6.get_cols(zsize+usize,zsize+usize).transpose()*Q6.get_cols(zsize+usize,zsize+usize))(0,0) |
| 1119 | + (A3.get_cols(xsize,xsize).transpose()*Q7.get_cols(0, xsize-1).transpose()*Q7.get_cols(0, xsize-1)*A3.get_cols(xsize,xsize))(0,0) |
| 1120 | + (B3.transpose()*Q7.get_cols(0, xsize-1).transpose()*Q7.get_cols(0, xsize-1)*B3)(0) |
| 1121 | + (A1.get_cols(xsize,xsize).transpose()*Q7.get_cols(xsize, xsize+ysize-1).transpose()*Q7.get_cols(xsize, xsize+ysize-1)*A1.get_cols(xsize,xsize))(0,0) |
| 1122 | + (B1.transpose()*Q7.get_cols(xsize, xsize+ysize-1).transpose()*Q7.get_cols(xsize, xsize+ysize-1)*B1)(0) |
| 1123 | + (A2.get_cols(xsize+usize,xsize+usize).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1)*A2.get_cols(xsize+usize,xsize+usize))(0,0) |
| 1124 | + (B2.transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1).transpose()*Q7.get_cols(xsize+ysize, xsize+ysize+zsize-1)*B2)(0) |
| 1125 | + (Q7.get_cols(xsize+ysize+zsize+usize,xsize+ysize+zsize+usize).transpose()*Q7.get_cols(xsize+ysize+zsize+usize,xsize+ysize+zsize+usize))(0,0); |
| 1126 | |
| 1127 | |
| 1128 | /*mat res; |
| 1129 | res = -inv(sqrtm(L))*sqrtm(K);*/ |
| 1130 | |
| 1131 | /*cout << -inv(sqrtm(L))*sqrtm(K).get_cols(0,L.rows()).get_rows(0,L.cols()) << endl; |
| 1132 | }*/ |
| 1133 | |
| 1134 | /*TEST (validation_test){ |