LUP

행 순열만 있는 LU 분해를 나타내는 부분 피벗을 사용한 LUP 분해: PA=LU.

bool  LUP(
  matrix&  L,     // 하부 삼각 행렬
  matrix&  U,     // 상부 삼각 행렬
  matrix&  P     // 순열 행렬
   );

매개 변수

L key

[out】 하부 삼각 행렬.

U

【out】 상부 삼각 행렬.

P

[out]  순열 행렬

반환값

성공하면 true를 반환하고 그렇지 않으면 false를 반환.

   matrix matrix_a={{1,2,3,4},
                    {5,2,6,7},
                    {8,9,3,10},
                    {11,12,14,4}};
   matrix matrix_l,matrix_u,matrix_p;
//--- LUP 분해
   matrix_a.LUP(matrix_l,matrix_u,matrix_p);
   Print("matrix_l\n",matrix_l);
   Print("matrix_u\n",matrix_u);
   Print("matrix_p\n",matrix_p);
//--- P * A = L * U 인지 체크
   Print("P * A\n",matrix_p.MatMul(matrix_a));
   Print("L * U\n",matrix_l.MatMul(matrix_u));
 
   /*
   matrix_l
   [[1,0,0,0]
    [0.4545454545454545,1,0,0]
    [0.7272727272727273,-0.07894736842105282,1,0]
    [0.09090909090909091,-0.2631578947368421,-0.2262773722627738,1]]
   matrix_u
   [[11,12,14,4]
    [0,-3.454545454545454,-0.3636363636363633,5.181818181818182]
    [0,0,-7.210526315789473,7.500000000000001]
    [0,0,0,6.697080291970803]]
   matrix_p
   [[0,0,0,1]
    [0,1,0,0]
    [0,0,1,0]
    [1,0,0,0]]
   P * A
   [[11,12,14,4]
    [5,2,6,7]
    [8,9,3,10]
    [1,2,3,4]]
   L * U
   [[11,12,14,4]
    [5,2,6,7]
    [8,9,3.000000000000001,10]
    [1,2,3,4]]
   */

LU
QR