35#ifndef _BLAZE_MATH_DENSE_LSE_H_
36#define _BLAZE_MATH_DENSE_LSE_H_
105template<
typename MT1
111void solve0x0(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
129 resize( *X, 0UL, (*B).columns() );
172void solve1x1(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
188 CompositeType_t<MT> Atmp( *A );
197 (*x)[0] /= Atmp(0,0);
226template<
typename MT1
232void solve1x1(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
248 CompositeType_t<MT1> Atmp( *A );
254 resize( *X, 1UL, (*B).columns() );
257 const ElementType_t<MT1> invD(
inv( Atmp(0,0) ) );
259 for(
size_t j=0UL; j<(*B).columns(); ++j ) {
304 , EnableIf_t< IsGeneral_v<MT> || ( IsHermitian_v<MT> && !IsSymmetric_v<MT> ) >* =
nullptr >
305void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
321 using ET = ElementType_t<MT>;
323 CompositeType_t<MT> A_( *A );
329 const ET D( A_(0,0)*A_(1,1) - A_(0,1)*A_(1,0) );
335 const ET invD(
inv( D ) );
337 x_[0] = ( A_(1,1)*b_[0] - A_(0,1)*b_[1] ) * invD;
338 x_[1] = ( A_(0,0)*b_[1] - A_(1,0)*b_[0] ) * invD;
371 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
372void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
388 using ET = ElementType_t<MT>;
390 CompositeType_t<MT> A_( *A );
396 const ET D( A_(0,0)*A_(1,1) - A_(0,1)*A_(0,1) );
402 const ET invD(
inv( D ) );
404 x_[0] = ( A_(1,1)*b_[0] - A_(0,1)*b_[1] ) * invD;
405 x_[1] = ( A_(0,0)*b_[1] - A_(0,1)*b_[0] ) * invD;
439 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
440void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
456 CompositeType_t<MT> A_( *A );
466 x_[0] = ( b_[0] ) / A_(0,0);
467 x_[1] = ( b_[1] - A_(1,0)*x_[0] ) / A_(1,1);
501 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
502void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
518 CompositeType_t<MT> A_( *A );
525 x_[1] = ( b_[1] - A_(1,0)*x_[0] );
559 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
560void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
576 CompositeType_t<MT> A_( *A );
586 x_[1] = ( b_[1] ) / A_(1,1);
587 x_[0] = ( b_[0] - A_(0,1)*x_[1] ) / A_(0,0);
621 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
622void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
638 CompositeType_t<MT> A_( *A );
645 x_[0] = ( b_[0] - A_(0,1)*x_[1] );
678 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
679void solve2x2(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
695 CompositeType_t<MT> A_( *A );
705 x_[1] = b_[1] / A_(1,1);
706 x_[0] = b_[0] / A_(0,0);
733template<
typename MT1
739 ,
EnableIf_t< ( IsGeneral_v<MT1> || IsSymmetric_v<MT1> || IsHermitian_v<MT1> ) && !IsDiagonal_v<MT1> >* =
nullptr >
740void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
756 resize( *X, (*B).rows(), (*B).columns() );
757 const ResultType_t<MT1> invA(
inv( *A ) );
786template<
typename MT1
792 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
793void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
809 using ET = ElementType_t<MT1>;
811 CompositeType_t<MT1> A_( *A );
819 const size_t M( B_.rows() );
820 const size_t N( B_.columns() );
824 const ET invD0(
inv( A_(0,0) ) );
825 const ET invD1(
inv( A_(1,1) ) );
827 for(
size_t j=0UL; j<N; ++j ) {
828 X_(0,j) = ( B_(0,j) ) * invD0;
829 X_(1,j) = ( B_(1,j) - A_(1,0)*X_(0,j) ) * invD1;
858template<
typename MT1
864 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
865void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
881 CompositeType_t<MT1> A_( *A );
885 const size_t M( B_.rows() );
886 const size_t N( B_.columns() );
890 for(
size_t j=0UL; j<N; ++j ) {
892 X_(1,j) = B_(1,j) - A_(1,0)*X_(0,j);
921template<
typename MT1
927 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
928void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
944 using ET = ElementType_t<MT1>;
946 CompositeType_t<MT1> A_( *A );
954 const size_t M( B_.rows() );
955 const size_t N( B_.columns() );
959 const ET invD0(
inv( A_(0,0) ) );
960 const ET invD1(
inv( A_(1,1) ) );
962 for(
size_t j=0UL; j<N; ++j ) {
963 X_(1,j) = ( B_(1,j) ) * invD1;
964 X_(0,j) = ( B_(0,j) - A_(0,1)*X_(1,j) ) * invD0;
993template<
typename MT1
999 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
1000void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1016 CompositeType_t<MT1> A_( *A );
1018 const MT3& B_( *B );
1020 const size_t M( B_.rows() );
1021 const size_t N( B_.columns() );
1025 for(
size_t j=0UL; j<N; ++j ) {
1027 X_(0,j) = B_(0,j) - A_(0,1)*X_(1,j);
1055template<
typename MT1
1061 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
1062void solve2x2(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1078 using ET = ElementType_t<MT1>;
1080 CompositeType_t<MT1> A_( *A );
1082 const MT3& B_( *B );
1088 const size_t M( B_.rows() );
1089 const size_t N( B_.columns() );
1093 const ET invD0(
inv( A_(0,0) ) );
1094 const ET invD1(
inv( A_(1,1) ) );
1096 for(
size_t j=0UL; j<N; ++j ) {
1097 X_(0,j) = B_(0,j) * invD0;
1098 X_(1,j) = B_(1,j) * invD1;
1134template<
typename MT
1140 , EnableIf_t< IsGeneral_v<MT> || ( IsHermitian_v<MT> && !IsSymmetric_v<MT> ) >* =
nullptr >
1141void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1157 using ET = ElementType_t<MT>;
1159 CompositeType_t<MT> A_( *A );
1161 const VT2& b_( *b );
1165 const ET tmp1( A_(0,0)*A_(1,1) - A_(1,0)*A_(0,1) );
1166 const ET tmp2( A_(1,0)*A_(0,2) - A_(0,0)*A_(1,2) );
1167 const ET tmp3( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
1169 const ET D( tmp1*A_(2,2) + tmp2*A_(2,1) + tmp3*A_(2,0) );
1175 const ET invD(
inv( D ) );
1177 const ET tmp4( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
1178 const ET tmp5( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
1179 const ET tmp6( A_(0,0)*b_[1] - A_(1,0)*b_[0] );
1181 x_[0] = ( tmp4*A_(2,2) + tmp5*A_(2,1) + tmp3*b_[2] ) * invD;
1182 x_[1] = ( tmp6*A_(2,2) + tmp2*b_[2] - tmp5*A_(2,0) ) * invD;
1183 x_[2] = ( tmp1*b_[2] - tmp4*A_(2,0) - tmp6*A_(2,1) ) * invD;
1210template<
typename MT
1216 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
1217void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1233 using ET = ElementType_t<MT>;
1235 CompositeType_t<MT> A_( *A );
1237 const VT2& b_( *b );
1241 const ET tmp1( A_(0,0)*A_(1,1) - A_(0,1)*A_(0,1) );
1242 const ET tmp2( A_(0,1)*A_(0,2) - A_(0,0)*A_(1,2) );
1243 const ET tmp3( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
1245 const ET D( tmp1*A_(2,2) + tmp2*A_(1,2) + tmp3*A_(0,2) );
1251 const ET invD(
inv( D ) );
1253 const ET tmp4( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
1254 const ET tmp5( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
1255 const ET tmp6( A_(0,0)*b_[1] - A_(0,1)*b_[0] );
1257 x_[0] = ( tmp4*A_(2,2) + tmp5*A_(1,2) + tmp3*b_[2] ) * invD;
1258 x_[1] = ( tmp6*A_(2,2) + tmp2*b_[2] - tmp5*A_(0,2) ) * invD;
1259 x_[2] = ( tmp1*b_[2] - tmp4*A_(0,2) - tmp6*A_(1,2) ) * invD;
1287template<
typename MT
1293 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
1294void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1310 CompositeType_t<MT> A_( *A );
1312 const VT2& b_( *b );
1314 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1320 x_[0] = ( b_[0] ) / A_(0,0);
1321 x_[1] = ( b_[1] - A_(1,0)*x_[0] ) / A_(1,1);
1322 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] ) / A_(2,2);
1350template<
typename MT
1356 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
1357void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1373 CompositeType_t<MT> A_( *A );
1375 const VT2& b_( *b );
1380 x_[1] = ( b_[1] - A_(1,0)*x_[0] );
1381 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] );
1409template<
typename MT
1415 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
1416void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1432 CompositeType_t<MT> A_( *A );
1434 const VT2& b_( *b );
1436 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1442 x_[2] = ( b_[2] ) / A_(2,2);
1443 x_[1] = ( b_[1] - A_(1,2)*x_[2] ) / A_(1,1);
1444 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] ) / A_(0,0);
1472template<
typename MT
1478 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
1479void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1495 CompositeType_t<MT> A_( *A );
1497 const VT2& b_( *b );
1502 x_[1] = ( b_[1] - A_(1,2)*x_[2] );
1503 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] );
1530template<
typename MT
1536 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
1537void solve3x3(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
1553 CompositeType_t<MT> A_( *A );
1555 const VT2& b_( *b );
1557 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1563 x_[0] = b_[0] / A_(0,0);
1564 x_[1] = b_[1] / A_(1,1);
1565 x_[2] = b_[2] / A_(2,2);
1592template<
typename MT1
1598 ,
EnableIf_t< ( IsGeneral_v<MT1> || IsSymmetric_v<MT1> || IsHermitian_v<MT1> ) && !IsDiagonal_v<MT1> >* =
nullptr >
1599void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1615 resize( *X, (*B).rows(), (*B).columns() );
1616 const ResultType_t<MT1> invA(
inv( *A ) );
1645template<
typename MT1
1651 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
1652void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1668 using ET = ElementType_t<MT1>;
1670 CompositeType_t<MT1> A_( *A );
1672 const MT3& B_( *B );
1674 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1678 const size_t M( B_.rows() );
1679 const size_t N( B_.columns() );
1683 const ET invD0(
inv( A_(0,0) ) );
1684 const ET invD1(
inv( A_(1,1) ) );
1685 const ET invD2(
inv( A_(2,2) ) );
1687 for(
size_t j=0UL; j<N; ++j ) {
1688 X_(0,j) = ( B_(0,j) ) * invD0;
1689 X_(1,j) = ( B_(1,j) - A_(1,0)*X_(0,j) ) * invD1;
1690 X_(2,j) = ( B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j) ) * invD2;
1719template<
typename MT1
1725 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
1726void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1742 CompositeType_t<MT1> A_( *A );
1744 const MT3& B_( *B );
1746 const size_t M( B_.rows() );
1747 const size_t N( B_.columns() );
1751 for(
size_t j=0UL; j<N; ++j ) {
1753 X_(1,j) = B_(1,j) - A_(1,0)*X_(0,j);
1754 X_(2,j) = B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j);
1783template<
typename MT1
1789 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
1790void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1806 using ET = ElementType_t<MT1>;
1808 CompositeType_t<MT1> A_( *A );
1810 const MT3& B_( *B );
1812 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1816 const size_t M( B_.rows() );
1817 const size_t N( B_.columns() );
1821 const ET invD0(
inv( A_(0,0) ) );
1822 const ET invD1(
inv( A_(1,1) ) );
1823 const ET invD2(
inv( A_(2,2) ) );
1825 for(
size_t j=0UL; j<N; ++j ) {
1826 X_(2,j) = ( B_(2,j) ) * invD2;
1827 X_(1,j) = ( B_(1,j) - A_(1,2)*X_(2,j) ) * invD1;
1828 X_(0,j) = ( B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) ) * invD0;
1857template<
typename MT1
1863 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
1864void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1880 CompositeType_t<MT1> A_( *A );
1882 const MT3& B_( *B );
1884 const size_t M( B_.rows() );
1885 const size_t N( B_.columns() );
1889 for(
size_t j=0UL; j<N; ++j ) {
1891 X_(1,j) = B_(1,j) - A_(1,2)*X_(2,j);
1892 X_(0,j) = B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j);
1920template<
typename MT1
1926 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
1927void solve3x3(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
1943 using ET = ElementType_t<MT1>;
1945 CompositeType_t<MT1> A_( *A );
1947 const MT3& B_( *B );
1949 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2) ) ) {
1953 const size_t M( B_.rows() );
1954 const size_t N( B_.columns() );
1958 const ET invD0(
inv( A_(0,0) ) );
1959 const ET invD1(
inv( A_(1,1) ) );
1960 const ET invD2(
inv( A_(2,2) ) );
1962 for(
size_t j=0UL; j<N; ++j ) {
1963 X_(0,j) = B_(0,j) * invD0;
1964 X_(1,j) = B_(1,j) * invD1;
1965 X_(2,j) = B_(2,j) * invD2;
2001template<
typename MT
2007 , EnableIf_t< IsGeneral_v<MT> || ( IsHermitian_v<MT> && !IsSymmetric_v<MT> ) >* =
nullptr >
2008void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2024 using ET = ElementType_t<MT>;
2026 CompositeType_t<MT> A_( *A );
2028 const VT2& b_( *b );
2032 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(1,0)*A_(0,1) );
2033 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(1,0)*A_(0,2) );
2034 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(1,0)*A_(0,3) );
2035 const ET tmp4 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
2036 const ET tmp5 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
2037 const ET tmp6 ( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
2039 const ET tmp7 ( tmp1*A_(2,2) - tmp2*A_(2,1) + tmp4*A_(2,0) );
2040 const ET tmp8 ( tmp1*A_(2,3) - tmp3*A_(2,1) + tmp5*A_(2,0) );
2041 const ET tmp9 ( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp6*A_(2,0) );
2042 const ET tmp10( tmp4*A_(2,3) - tmp5*A_(2,2) + tmp6*A_(2,1) );
2044 const ET D( tmp7*A_(3,3) - tmp8*A_(3,2) + tmp9*A_(3,1) - tmp10*A_(3,0) );
2050 const ET invD(
inv( D ) );
2052 const ET tmp11( A_(0,0)*b_[1] - A_(1,0)*b_[0] );
2053 const ET tmp12( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
2054 const ET tmp13( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
2055 const ET tmp14( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
2056 const ET tmp15( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
2057 const ET tmp16( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
2059 const ET tmp17( tmp14*A_(2,2) - tmp15*A_(2,1) + tmp4*b_[2] );
2060 const ET tmp18( tmp14*A_(2,3) - tmp16*A_(2,1) + tmp5*b_[2] );
2061 const ET tmp19( tmp15*A_(2,3) - tmp16*A_(2,2) + tmp6*b_[2] );
2063 const ET tmp20( tmp11*A_(2,2) - tmp2*b_[2] + tmp15*A_(2,0) );
2064 const ET tmp21( tmp11*A_(2,3) - tmp3*b_[2] + tmp16*A_(2,0) );
2065 const ET tmp22( tmp12*A_(2,3) - tmp5*b_[2] + tmp16*A_(2,1) );
2067 const ET tmp23( tmp1*b_[2] - tmp11*A_(2,1) + tmp12*A_(2,0) );
2068 const ET tmp24( tmp2*b_[2] - tmp11*A_(2,2) + tmp13*A_(2,0) );
2069 const ET tmp25( tmp4*b_[2] - tmp12*A_(2,2) + tmp13*A_(2,1) );
2071 x_[0] = ( tmp17*A_(3,3) - tmp18*A_(3,2) + tmp19*A_(3,1) - tmp10*b_[3] ) * invD;
2072 x_[1] = ( tmp20*A_(3,3) - tmp21*A_(3,2) + tmp9*b_[3] - tmp19*A_(3,0) ) * invD;
2073 x_[2] = ( tmp23*A_(3,3) - tmp8*b_[3] + tmp21*A_(3,1) - tmp22*A_(3,0) ) * invD;
2074 x_[3] = ( tmp7*b_[3] - tmp23*A_(3,2) + tmp24*A_(3,1) - tmp25*A_(3,0) ) * invD;
2101template<
typename MT
2107 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
2108void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2124 using ET = ElementType_t<MT>;
2126 CompositeType_t<MT> A_( *A );
2128 const VT2& b_( *b );
2132 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(0,1)*A_(0,1) );
2133 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(0,1)*A_(0,2) );
2134 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(0,1)*A_(0,3) );
2135 const ET tmp4 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
2136 const ET tmp5 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
2137 const ET tmp6 ( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
2139 const ET tmp7 ( tmp1*A_(2,2) - tmp2*A_(1,2) + tmp4*A_(0,2) );
2140 const ET tmp8 ( tmp1*A_(2,3) - tmp3*A_(1,2) + tmp5*A_(0,2) );
2141 const ET tmp9 ( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp6*A_(0,2) );
2142 const ET tmp10( tmp4*A_(2,3) - tmp5*A_(2,2) + tmp6*A_(1,2) );
2144 const ET D( tmp7*A_(3,3) - tmp8*A_(2,3) + tmp9*A_(1,3) - tmp10*A_(0,3) );
2150 const ET invD(
inv( D ) );
2152 const ET tmp11( A_(0,0)*b_[1] - A_(0,1)*b_[0] );
2153 const ET tmp12( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
2154 const ET tmp13( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
2155 const ET tmp14( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
2156 const ET tmp15( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
2157 const ET tmp16( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
2159 const ET tmp17( tmp14*A_(2,2) - tmp15*A_(1,2) + tmp4*b_[2] );
2160 const ET tmp18( tmp14*A_(2,3) - tmp16*A_(1,2) + tmp5*b_[2] );
2161 const ET tmp19( tmp15*A_(2,3) - tmp16*A_(2,2) + tmp6*b_[2] );
2163 const ET tmp20( tmp11*A_(2,2) - tmp2*b_[2] + tmp15*A_(0,2) );
2164 const ET tmp21( tmp11*A_(2,3) - tmp3*b_[2] + tmp16*A_(0,2) );
2165 const ET tmp22( tmp12*A_(2,3) - tmp5*b_[2] + tmp16*A_(1,2) );
2167 const ET tmp23( tmp1*b_[2] - tmp11*A_(1,2) + tmp12*A_(0,2) );
2168 const ET tmp24( tmp2*b_[2] - tmp11*A_(2,2) + tmp13*A_(0,2) );
2169 const ET tmp25( tmp4*b_[2] - tmp12*A_(2,2) + tmp13*A_(1,2) );
2171 x_[0] = ( tmp17*A_(3,3) - tmp18*A_(2,3) + tmp19*A_(1,3) - tmp10*b_[3] ) * invD;
2172 x_[1] = ( tmp20*A_(3,3) - tmp21*A_(2,3) + tmp9*b_[3] - tmp19*A_(0,3) ) * invD;
2173 x_[2] = ( tmp23*A_(3,3) - tmp8*b_[3] + tmp21*A_(1,3) - tmp22*A_(0,3) ) * invD;
2174 x_[3] = ( tmp7*b_[3] - tmp23*A_(2,3) + tmp24*A_(1,3) - tmp25*A_(0,3) ) * invD;
2202template<
typename MT
2208 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
2209void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2225 CompositeType_t<MT> A_( *A );
2227 const VT2& b_( *b );
2229 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2235 x_[0] = ( b_[0] ) / A_(0,0);
2236 x_[1] = ( b_[1] - A_(1,0)*x_[0] ) / A_(1,1);
2237 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] ) / A_(2,2);
2238 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] ) / A_(3,3);
2266template<
typename MT
2272 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
2273void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2289 CompositeType_t<MT> A_( *A );
2291 const VT2& b_( *b );
2296 x_[1] = ( b_[1] - A_(1,0)*x_[0] );
2297 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] );
2298 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] );
2326template<
typename MT
2332 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
2333void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2349 CompositeType_t<MT> A_( *A );
2351 const VT2& b_( *b );
2353 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2359 x_[3] = ( b_[3] ) / A_(3,3);
2360 x_[2] = ( b_[2] - A_(2,3)*x_[3] ) / A_(2,2);
2361 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] ) / A_(1,1);
2362 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] ) / A_(0,0);
2390template<
typename MT
2396 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
2397void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2413 CompositeType_t<MT> A_( *A );
2415 const VT2& b_( *b );
2420 x_[2] = ( b_[2] - A_(2,3)*x_[3] );
2421 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] );
2422 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] );
2449template<
typename MT
2455 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
2456void solve4x4(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2472 CompositeType_t<MT> A_( *A );
2474 const VT2& b_( *b );
2476 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2482 x_[0] = b_[0] / A_(0,0);
2483 x_[1] = b_[1] / A_(1,1);
2484 x_[2] = b_[2] / A_(2,2);
2485 x_[3] = b_[3] / A_(3,3);
2512template<
typename MT1
2518 ,
EnableIf_t< ( IsGeneral_v<MT1> || IsSymmetric_v<MT1> || IsHermitian_v<MT1> ) && !IsDiagonal_v<MT1> >* =
nullptr >
2519void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2535 resize( *X, (*B).rows(), (*B).columns() );
2536 const ResultType_t<MT1> invA(
inv( *A ) );
2565template<
typename MT1
2571 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
2572void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2588 using ET = ElementType_t<MT1>;
2590 CompositeType_t<MT1> A_( *A );
2592 const MT3& B_( *B );
2594 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2598 const size_t M( B_.rows() );
2599 const size_t N( B_.columns() );
2603 const ET invD0(
inv( A_(0,0) ) );
2604 const ET invD1(
inv( A_(1,1) ) );
2605 const ET invD2(
inv( A_(2,2) ) );
2606 const ET invD3(
inv( A_(3,3) ) );
2608 for(
size_t j=0UL; j<N; ++j ) {
2609 X_(0,j) = ( B_(0,j) ) * invD0;
2610 X_(1,j) = ( B_(1,j) - A_(1,0)*X_(0,j) ) * invD1;
2611 X_(2,j) = ( B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j) ) * invD2;
2612 X_(3,j) = ( B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j) ) * invD3;
2641template<
typename MT1
2647 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
2648void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2664 CompositeType_t<MT1> A_( *A );
2666 const MT3& B_( *B );
2668 const size_t M( B_.rows() );
2669 const size_t N( B_.columns() );
2673 for(
size_t j=0UL; j<N; ++j ) {
2675 X_(1,j) = B_(1,j) - A_(1,0)*X_(0,j);
2676 X_(2,j) = B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j);
2677 X_(3,j) = B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j);
2706template<
typename MT1
2712 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
2713void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2729 using ET = ElementType_t<MT1>;
2731 CompositeType_t<MT1> A_( *A );
2733 const MT3& B_( *B );
2735 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2739 const size_t M( B_.rows() );
2740 const size_t N( B_.columns() );
2744 const ET invD0(
inv( A_(0,0) ) );
2745 const ET invD1(
inv( A_(1,1) ) );
2746 const ET invD2(
inv( A_(2,2) ) );
2747 const ET invD3(
inv( A_(3,3) ) );
2749 for(
size_t j=0UL; j<N; ++j ) {
2750 X_(3,j) = ( B_(3,j) ) * invD3;
2751 X_(2,j) = ( B_(2,j) - A_(2,3)*X_(3,j) ) * invD2;
2752 X_(1,j) = ( B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j) ) * invD1;
2753 X_(0,j) = ( B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j) ) * invD0;
2782template<
typename MT1
2788 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
2789void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2805 CompositeType_t<MT1> A_( *A );
2807 const MT3& B_( *B );
2809 const size_t M( B_.rows() );
2810 const size_t N( B_.columns() );
2814 for(
size_t j=0UL; j<N; ++j ) {
2816 X_(2,j) = B_(2,j) - A_(2,3)*X_(3,j);
2817 X_(1,j) = B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j);
2818 X_(0,j) = B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j);
2846template<
typename MT1
2852 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
2853void solve4x4(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
2869 using ET = ElementType_t<MT1>;
2871 CompositeType_t<MT1> A_( *A );
2873 const MT3& B_( *B );
2875 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3) ) ) {
2879 const size_t M( B_.rows() );
2880 const size_t N( B_.columns() );
2884 const ET invD0(
inv( A_(0,0) ) );
2885 const ET invD1(
inv( A_(1,1) ) );
2886 const ET invD2(
inv( A_(2,2) ) );
2887 const ET invD3(
inv( A_(3,3) ) );
2889 for(
size_t j=0UL; j<N; ++j ) {
2890 X_(0,j) = B_(0,j) * invD0;
2891 X_(1,j) = B_(1,j) * invD1;
2892 X_(2,j) = B_(2,j) * invD2;
2893 X_(3,j) = B_(3,j) * invD3;
2929template<
typename MT
2935 , EnableIf_t< IsGeneral_v<MT> || ( IsHermitian_v<MT> && !IsSymmetric_v<MT> ) >* =
nullptr >
2936void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
2952 using ET = ElementType_t<MT>;
2954 CompositeType_t<MT> A_( *A );
2956 const VT2& b_( *b );
2960 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(1,0)*A_(0,1) );
2961 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(1,0)*A_(0,2) );
2962 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(1,0)*A_(0,3) );
2963 const ET tmp4 ( A_(0,0)*A_(1,4) - A_(1,0)*A_(0,4) );
2964 const ET tmp5 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
2965 const ET tmp6 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
2966 const ET tmp7 ( A_(0,1)*A_(1,4) - A_(1,1)*A_(0,4) );
2967 const ET tmp8 ( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
2968 const ET tmp9 ( A_(0,2)*A_(1,4) - A_(1,2)*A_(0,4) );
2969 const ET tmp10( A_(0,3)*A_(1,4) - A_(1,3)*A_(0,4) );
2971 const ET tmp11( A_(0,0)*b_[1] - A_(1,0)*b_[0] );
2972 const ET tmp12( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
2973 const ET tmp13( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
2974 const ET tmp14( A_(0,3)*b_[1] - A_(1,3)*b_[0] );
2976 const ET tmp15( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
2977 const ET tmp16( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
2978 const ET tmp17( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
2979 const ET tmp18( A_(1,4)*b_[0] - A_(0,4)*b_[1] );
2981 const ET tmp19( tmp1*A_(2,2) - tmp2*A_(2,1) + tmp5*A_(2,0) );
2982 const ET tmp20( tmp1*A_(2,3) - tmp3*A_(2,1) + tmp6*A_(2,0) );
2983 const ET tmp21( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp8*A_(2,0) );
2984 const ET tmp22( tmp5*A_(2,3) - tmp6*A_(2,2) + tmp8*A_(2,1) );
2985 const ET tmp23( tmp1*A_(2,4) - tmp4*A_(2,1) + tmp7*A_(2,0) );
2986 const ET tmp24( tmp2*A_(2,4) - tmp4*A_(2,2) + tmp9*A_(2,0) );
2987 const ET tmp25( tmp5*A_(2,4) - tmp7*A_(2,2) + tmp9*A_(2,1) );
2988 const ET tmp26( tmp3*A_(2,4) - tmp4*A_(2,3) + tmp10*A_(2,0) );
2989 const ET tmp27( tmp6*A_(2,4) - tmp7*A_(2,3) + tmp10*A_(2,1) );
2990 const ET tmp28( tmp8*A_(2,4) - tmp9*A_(2,3) + tmp10*A_(2,2) );
2992 const ET tmp29( tmp19*A_(3,3) - tmp20*A_(3,2) + tmp21*A_(3,1) - tmp22*A_(3,0) );
2993 const ET tmp30( tmp19*A_(3,4) - tmp23*A_(3,2) + tmp24*A_(3,1) - tmp25*A_(3,0) );
2994 const ET tmp31( tmp20*A_(3,4) - tmp23*A_(3,3) + tmp26*A_(3,1) - tmp27*A_(3,0) );
2995 const ET tmp32( tmp21*A_(3,4) - tmp24*A_(3,3) + tmp26*A_(3,2) - tmp28*A_(3,0) );
2996 const ET tmp33( tmp22*A_(3,4) - tmp25*A_(3,3) + tmp27*A_(3,2) - tmp28*A_(3,1) );
2998 const ET D( tmp29*A_(4,4) - tmp30*A_(4,3) + tmp31*A_(4,2) - tmp32*A_(4,1) + tmp33*A_(4,0) );
3004 const ET invD(
inv( D ) );
3006 const ET tmp34( tmp15*A_(2,2) - tmp16*A_(2,1) + tmp5*b_[2] );
3007 const ET tmp35( tmp15*A_(2,3) - tmp17*A_(2,1) + tmp6*b_[2] );
3008 const ET tmp36( tmp16*A_(2,3) - tmp17*A_(2,2) + tmp8*b_[2] );
3009 const ET tmp37( tmp15*A_(2,4) - tmp18*A_(2,1) + tmp7*b_[2] );
3010 const ET tmp38( tmp16*A_(2,4) - tmp18*A_(2,2) + tmp9*b_[2] );
3011 const ET tmp39( tmp17*A_(2,4) - tmp18*A_(2,3) + tmp10*b_[2] );
3013 const ET tmp40( tmp11*A_(2,2) - tmp2*b_[2] + tmp16*A_(2,0) );
3014 const ET tmp41( tmp11*A_(2,3) - tmp3*b_[2] + tmp17*A_(2,0) );
3015 const ET tmp42( tmp12*A_(2,3) - tmp6*b_[2] + tmp17*A_(2,1) );
3016 const ET tmp43( tmp11*A_(2,4) - tmp4*b_[2] + tmp18*A_(2,0) );
3017 const ET tmp44( tmp12*A_(2,4) - tmp7*b_[2] + tmp18*A_(2,1) );
3018 const ET tmp45( tmp13*A_(2,4) - tmp9*b_[2] + tmp18*A_(2,2) );
3020 const ET tmp46( tmp1*b_[2] - tmp11*A_(2,1) + tmp12*A_(2,0) );
3021 const ET tmp47( tmp2*b_[2] - tmp11*A_(2,2) + tmp13*A_(2,0) );
3022 const ET tmp48( tmp5*b_[2] - tmp12*A_(2,2) + tmp13*A_(2,1) );
3023 const ET tmp49( tmp3*b_[2] - tmp11*A_(2,3) + tmp14*A_(2,0) );
3024 const ET tmp50( tmp6*b_[2] - tmp12*A_(2,3) + tmp14*A_(2,1) );
3025 const ET tmp51( tmp8*b_[2] - tmp13*A_(2,3) + tmp14*A_(2,2) );
3027 const ET tmp52( tmp34*A_(3,3) - tmp35*A_(3,2) + tmp36*A_(3,1) - tmp22*b_[3] );
3028 const ET tmp53( tmp34*A_(3,4) - tmp37*A_(3,2) + tmp38*A_(3,1) - tmp25*b_[3] );
3029 const ET tmp54( tmp35*A_(3,4) - tmp37*A_(3,3) + tmp39*A_(3,1) - tmp27*b_[3] );
3030 const ET tmp55( tmp36*A_(3,4) - tmp38*A_(3,3) + tmp39*A_(3,2) - tmp28*b_[3] );
3032 const ET tmp56( tmp40*A_(3,3) - tmp41*A_(3,2) + tmp21*b_[3] - tmp36*A_(3,0) );
3033 const ET tmp57( tmp40*A_(3,4) - tmp43*A_(3,2) + tmp24*b_[3] - tmp38*A_(3,0) );
3034 const ET tmp58( tmp41*A_(3,4) - tmp43*A_(3,3) + tmp26*b_[3] - tmp39*A_(3,0) );
3035 const ET tmp59( tmp42*A_(3,4) - tmp44*A_(3,3) + tmp27*b_[3] - tmp39*A_(3,1) );
3037 const ET tmp60( tmp46*A_(3,3) - tmp20*b_[3] + tmp41*A_(3,1) - tmp42*A_(3,0) );
3038 const ET tmp61( tmp46*A_(3,4) - tmp23*b_[3] + tmp43*A_(3,1) - tmp44*A_(3,0) );
3039 const ET tmp62( tmp47*A_(3,4) - tmp24*b_[3] + tmp43*A_(3,2) - tmp45*A_(3,0) );
3040 const ET tmp63( tmp48*A_(3,4) - tmp25*b_[3] + tmp44*A_(3,2) - tmp45*A_(3,1) );
3042 const ET tmp64( tmp19*b_[3] - tmp46*A_(3,2) + tmp47*A_(3,1) - tmp48*A_(3,0) );
3043 const ET tmp65( tmp20*b_[3] - tmp46*A_(3,3) + tmp49*A_(3,1) - tmp50*A_(3,0) );
3044 const ET tmp66( tmp21*b_[3] - tmp47*A_(3,3) + tmp49*A_(3,2) - tmp51*A_(3,0) );
3045 const ET tmp67( tmp22*b_[3] - tmp48*A_(3,3) + tmp50*A_(3,2) - tmp51*A_(3,1) );
3047 x_[0] = ( tmp52*A_(4,4) - tmp53*A_(4,3) + tmp54*A_(4,2) - tmp55*A_(4,1) + tmp33*b_[4] ) * invD;
3048 x_[1] = ( tmp56*A_(4,4) - tmp57*A_(4,3) + tmp58*A_(4,2) - tmp32*b_[4] + tmp55*A_(4,0) ) * invD;
3049 x_[2] = ( tmp60*A_(4,4) - tmp61*A_(4,3) + tmp31*b_[4] - tmp58*A_(4,1) + tmp59*A_(4,0) ) * invD;
3050 x_[3] = ( tmp64*A_(4,4) - tmp30*b_[4] + tmp61*A_(4,2) - tmp62*A_(4,1) + tmp63*A_(4,0) ) * invD;
3051 x_[4] = ( tmp29*b_[4] - tmp64*A_(4,3) + tmp65*A_(4,2) - tmp66*A_(4,1) + tmp67*A_(4,0) ) * invD;
3078template<
typename MT
3084 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
3085void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3101 using ET = ElementType_t<MT>;
3103 CompositeType_t<MT> A_( *A );
3105 const VT2& b_( *b );
3109 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(0,1)*A_(0,1) );
3110 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(0,1)*A_(0,2) );
3111 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(0,1)*A_(0,3) );
3112 const ET tmp4 ( A_(0,0)*A_(1,4) - A_(0,1)*A_(0,4) );
3113 const ET tmp5 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
3114 const ET tmp6 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
3115 const ET tmp7 ( A_(0,1)*A_(1,4) - A_(1,1)*A_(0,4) );
3116 const ET tmp8 ( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
3117 const ET tmp9 ( A_(0,2)*A_(1,4) - A_(1,2)*A_(0,4) );
3118 const ET tmp10( A_(0,3)*A_(1,4) - A_(1,3)*A_(0,4) );
3120 const ET tmp11( A_(0,0)*b_[1] - A_(0,1)*b_[0] );
3121 const ET tmp12( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
3122 const ET tmp13( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
3123 const ET tmp14( A_(0,3)*b_[1] - A_(1,3)*b_[0] );
3125 const ET tmp15( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
3126 const ET tmp16( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
3127 const ET tmp17( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
3128 const ET tmp18( A_(1,4)*b_[0] - A_(0,4)*b_[1] );
3130 const ET tmp19( tmp1*A_(2,2) - tmp2*A_(1,2) + tmp5*A_(0,2) );
3131 const ET tmp20( tmp1*A_(2,3) - tmp3*A_(1,2) + tmp6*A_(0,2) );
3132 const ET tmp21( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp8*A_(0,2) );
3133 const ET tmp22( tmp5*A_(2,3) - tmp6*A_(2,2) + tmp8*A_(1,2) );
3134 const ET tmp23( tmp1*A_(2,4) - tmp4*A_(1,2) + tmp7*A_(0,2) );
3135 const ET tmp24( tmp2*A_(2,4) - tmp4*A_(2,2) + tmp9*A_(0,2) );
3136 const ET tmp25( tmp5*A_(2,4) - tmp7*A_(2,2) + tmp9*A_(1,2) );
3137 const ET tmp26( tmp3*A_(2,4) - tmp4*A_(2,3) + tmp10*A_(0,2) );
3138 const ET tmp27( tmp6*A_(2,4) - tmp7*A_(2,3) + tmp10*A_(1,2) );
3139 const ET tmp28( tmp8*A_(2,4) - tmp9*A_(2,3) + tmp10*A_(2,2) );
3141 const ET tmp29( tmp19*A_(3,3) - tmp20*A_(2,3) + tmp21*A_(1,3) - tmp22*A_(0,3) );
3142 const ET tmp30( tmp19*A_(3,4) - tmp23*A_(2,3) + tmp24*A_(1,3) - tmp25*A_(0,3) );
3143 const ET tmp31( tmp20*A_(3,4) - tmp23*A_(3,3) + tmp26*A_(1,3) - tmp27*A_(0,3) );
3144 const ET tmp32( tmp21*A_(3,4) - tmp24*A_(3,3) + tmp26*A_(2,3) - tmp28*A_(0,3) );
3145 const ET tmp33( tmp22*A_(3,4) - tmp25*A_(3,3) + tmp27*A_(2,3) - tmp28*A_(1,3) );
3147 const ET D( tmp29*A_(4,4) - tmp30*A_(3,4) + tmp31*A_(2,4) - tmp32*A_(1,4) + tmp33*A_(0,4) );
3153 const ET invD(
inv( D ) );
3155 const ET tmp34( tmp15*A_(2,2) - tmp16*A_(1,2) + tmp5*b_[2] );
3156 const ET tmp35( tmp15*A_(2,3) - tmp17*A_(1,2) + tmp6*b_[2] );
3157 const ET tmp36( tmp16*A_(2,3) - tmp17*A_(2,2) + tmp8*b_[2] );
3158 const ET tmp37( tmp15*A_(2,4) - tmp18*A_(1,2) + tmp7*b_[2] );
3159 const ET tmp38( tmp16*A_(2,4) - tmp18*A_(2,2) + tmp9*b_[2] );
3160 const ET tmp39( tmp17*A_(2,4) - tmp18*A_(2,3) + tmp10*b_[2] );
3162 const ET tmp40( tmp11*A_(2,2) - tmp2*b_[2] + tmp16*A_(0,2) );
3163 const ET tmp41( tmp11*A_(2,3) - tmp3*b_[2] + tmp17*A_(0,2) );
3164 const ET tmp42( tmp12*A_(2,3) - tmp6*b_[2] + tmp17*A_(1,2) );
3165 const ET tmp43( tmp11*A_(2,4) - tmp4*b_[2] + tmp18*A_(0,2) );
3166 const ET tmp44( tmp12*A_(2,4) - tmp7*b_[2] + tmp18*A_(1,2) );
3167 const ET tmp45( tmp13*A_(2,4) - tmp9*b_[2] + tmp18*A_(2,2) );
3169 const ET tmp46( tmp1*b_[2] - tmp11*A_(1,2) + tmp12*A_(0,2) );
3170 const ET tmp47( tmp2*b_[2] - tmp11*A_(2,2) + tmp13*A_(0,2) );
3171 const ET tmp48( tmp5*b_[2] - tmp12*A_(2,2) + tmp13*A_(1,2) );
3172 const ET tmp49( tmp3*b_[2] - tmp11*A_(2,3) + tmp14*A_(0,2) );
3173 const ET tmp50( tmp6*b_[2] - tmp12*A_(2,3) + tmp14*A_(1,2) );
3174 const ET tmp51( tmp8*b_[2] - tmp13*A_(2,3) + tmp14*A_(2,2) );
3176 const ET tmp52( tmp34*A_(3,3) - tmp35*A_(2,3) + tmp36*A_(1,3) - tmp22*b_[3] );
3177 const ET tmp53( tmp34*A_(3,4) - tmp37*A_(2,3) + tmp38*A_(1,3) - tmp25*b_[3] );
3178 const ET tmp54( tmp35*A_(3,4) - tmp37*A_(3,3) + tmp39*A_(1,3) - tmp27*b_[3] );
3179 const ET tmp55( tmp36*A_(3,4) - tmp38*A_(3,3) + tmp39*A_(2,3) - tmp28*b_[3] );
3181 const ET tmp56( tmp40*A_(3,3) - tmp41*A_(2,3) + tmp21*b_[3] - tmp36*A_(0,3) );
3182 const ET tmp57( tmp40*A_(3,4) - tmp43*A_(2,3) + tmp24*b_[3] - tmp38*A_(0,3) );
3183 const ET tmp58( tmp41*A_(3,4) - tmp43*A_(3,3) + tmp26*b_[3] - tmp39*A_(0,3) );
3184 const ET tmp59( tmp42*A_(3,4) - tmp44*A_(3,3) + tmp27*b_[3] - tmp39*A_(1,3) );
3186 const ET tmp60( tmp46*A_(3,3) - tmp20*b_[3] + tmp41*A_(1,3) - tmp42*A_(0,3) );
3187 const ET tmp61( tmp46*A_(3,4) - tmp23*b_[3] + tmp43*A_(1,3) - tmp44*A_(0,3) );
3188 const ET tmp62( tmp47*A_(3,4) - tmp24*b_[3] + tmp43*A_(2,3) - tmp45*A_(0,3) );
3189 const ET tmp63( tmp48*A_(3,4) - tmp25*b_[3] + tmp44*A_(2,3) - tmp45*A_(1,3) );
3191 const ET tmp64( tmp19*b_[3] - tmp46*A_(2,3) + tmp47*A_(1,3) - tmp48*A_(0,3) );
3192 const ET tmp65( tmp20*b_[3] - tmp46*A_(3,3) + tmp49*A_(1,3) - tmp50*A_(0,3) );
3193 const ET tmp66( tmp21*b_[3] - tmp47*A_(3,3) + tmp49*A_(2,3) - tmp51*A_(0,3) );
3194 const ET tmp67( tmp22*b_[3] - tmp48*A_(3,3) + tmp50*A_(2,3) - tmp51*A_(1,3) );
3196 x_[0] = ( tmp52*A_(4,4) - tmp53*A_(3,4) + tmp54*A_(2,4) - tmp55*A_(1,4) + tmp33*b_[4] ) * invD;
3197 x_[1] = ( tmp56*A_(4,4) - tmp57*A_(3,4) + tmp58*A_(2,4) - tmp32*b_[4] + tmp55*A_(0,4) ) * invD;
3198 x_[2] = ( tmp60*A_(4,4) - tmp61*A_(3,4) + tmp31*b_[4] - tmp58*A_(1,4) + tmp59*A_(0,4) ) * invD;
3199 x_[3] = ( tmp64*A_(4,4) - tmp30*b_[4] + tmp61*A_(2,4) - tmp62*A_(1,4) + tmp63*A_(0,4) ) * invD;
3200 x_[4] = ( tmp29*b_[4] - tmp64*A_(3,4) + tmp65*A_(2,4) - tmp66*A_(1,4) + tmp67*A_(0,4) ) * invD;
3228template<
typename MT
3234 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
3235void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3251 CompositeType_t<MT> A_( *A );
3253 const VT2& b_( *b );
3255 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3261 x_[0] = ( b_[0] ) / A_(0,0);
3262 x_[1] = ( b_[1] - A_(1,0)*x_[0] ) / A_(1,1);
3263 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] ) / A_(2,2);
3264 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] ) / A_(3,3);
3265 x_[4] = ( b_[4] - A_(4,0)*x_[0] - A_(4,1)*x_[1] - A_(4,2)*x_[2] - A_(4,3)*x_[3] ) / A_(4,4);
3293template<
typename MT
3299 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
3300void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3316 CompositeType_t<MT> A_( *A );
3318 const VT2& b_( *b );
3323 x_[1] = ( b_[1] - A_(1,0)*x_[0] );
3324 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] );
3325 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] );
3326 x_[4] = ( b_[4] - A_(4,0)*x_[0] - A_(4,1)*x_[1] - A_(4,2)*x_[2] - A_(4,3)*x_[3] );
3354template<
typename MT
3360 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
3361void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3377 CompositeType_t<MT> A_( *A );
3379 const VT2& b_( *b );
3381 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3387 x_[4] = ( b_[4] ) / A_(4,4);
3388 x_[3] = ( b_[3] - A_(3,4)*x_[4] ) / A_(3,3);
3389 x_[2] = ( b_[2] - A_(2,3)*x_[3] - A_(2,4)*x_[4] ) / A_(2,2);
3390 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] - A_(1,4)*x_[4] ) / A_(1,1);
3391 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] - A_(0,4)*x_[4] ) / A_(0,0);
3419template<
typename MT
3425 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
3426void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3442 CompositeType_t<MT> A_( *A );
3444 const VT2& b_( *b );
3449 x_[3] = ( b_[3] - A_(3,4)*x_[4] );
3450 x_[2] = ( b_[2] - A_(2,3)*x_[3] - A_(2,4)*x_[4] );
3451 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] - A_(1,4)*x_[4] );
3452 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] - A_(0,4)*x_[4] );
3479template<
typename MT
3485 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
3486void solve5x5(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3502 CompositeType_t<MT> A_( *A );
3504 const VT2& b_( *b );
3506 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3512 x_[0] = b_[0] / A_(0,0);
3513 x_[1] = b_[1] / A_(1,1);
3514 x_[2] = b_[2] / A_(2,2);
3515 x_[3] = b_[3] / A_(3,3);
3516 x_[4] = b_[4] / A_(4,4);
3543template<
typename MT1
3549 ,
EnableIf_t< ( IsGeneral_v<MT1> || IsSymmetric_v<MT1> || IsHermitian_v<MT1> ) && !IsDiagonal_v<MT1> >* =
nullptr >
3550void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3566 resize( *X, (*B).rows(), (*B).columns() );
3567 const ResultType_t<MT1> invA(
inv( *A ) );
3596template<
typename MT1
3602 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
3603void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3619 using ET = ElementType_t<MT1>;
3621 CompositeType_t<MT1> A_( *A );
3623 const MT3& B_( *B );
3625 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3629 const size_t M( B_.rows() );
3630 const size_t N( B_.columns() );
3634 const ET invD0(
inv( A_(0,0) ) );
3635 const ET invD1(
inv( A_(1,1) ) );
3636 const ET invD2(
inv( A_(2,2) ) );
3637 const ET invD3(
inv( A_(3,3) ) );
3638 const ET invD4(
inv( A_(4,4) ) );
3640 for(
size_t j=0UL; j<N; ++j ) {
3641 X_(0,j) = ( B_(0,j) ) * invD0;
3642 X_(1,j) = ( B_(1,j) - A_(1,0)*X_(0,j) ) * invD1;
3643 X_(2,j) = ( B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j) ) * invD2;
3644 X_(3,j) = ( B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j) ) * invD3;
3645 X_(4,j) = ( B_(4,j) - A_(4,0)*X_(0,j) - A_(4,1)*X_(1,j) - A_(4,2)*X_(2,j) - A_(4,3)*X_(3,j) ) * invD4;
3674template<
typename MT1
3680 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
3681void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3697 CompositeType_t<MT1> A_( *A );
3699 const MT3& B_( *B );
3701 const size_t M( B_.rows() );
3702 const size_t N( B_.columns() );
3706 for(
size_t j=0UL; j<N; ++j ) {
3708 X_(1,j) = B_(1,j) - A_(1,0)*X_(0,j);
3709 X_(2,j) = B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j);
3710 X_(3,j) = B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j);
3711 X_(4,j) = B_(4,j) - A_(4,0)*X_(0,j) - A_(4,1)*X_(1,j) - A_(4,2)*X_(2,j) - A_(4,3)*X_(3,j);
3740template<
typename MT1
3746 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
3747void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3763 using ET = ElementType_t<MT1>;
3765 CompositeType_t<MT1> A_( *A );
3767 const MT3& B_( *B );
3769 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3773 const size_t M( B_.rows() );
3774 const size_t N( B_.columns() );
3778 const ET invD0(
inv( A_(0,0) ) );
3779 const ET invD1(
inv( A_(1,1) ) );
3780 const ET invD2(
inv( A_(2,2) ) );
3781 const ET invD3(
inv( A_(3,3) ) );
3782 const ET invD4(
inv( A_(4,4) ) );
3784 for(
size_t j=0UL; j<N; ++j ) {
3785 X_(4,j) = ( B_(4,j) ) * invD4;
3786 X_(3,j) = ( B_(3,j) - A_(3,4)*X_(4,j) ) * invD3;
3787 X_(2,j) = ( B_(2,j) - A_(2,3)*X_(3,j) - A_(2,4)*X_(4,j) ) * invD2;
3788 X_(1,j) = ( B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j) - A_(1,4)*X_(4,j) ) * invD1;
3789 X_(0,j) = ( B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j) - A_(0,4)*X_(4,j) ) * invD0;
3818template<
typename MT1
3824 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
3825void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3841 CompositeType_t<MT1> A_( *A );
3843 const MT3& B_( *B );
3845 const size_t M( B_.rows() );
3846 const size_t N( B_.columns() );
3850 for(
size_t j=0UL; j<N; ++j ) {
3852 X_(3,j) = B_(3,j) - A_(3,4)*X_(4,j);
3853 X_(2,j) = B_(2,j) - A_(2,3)*X_(3,j) - A_(2,4)*X_(4,j);
3854 X_(1,j) = B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j) - A_(1,4)*X_(4,j);
3855 X_(0,j) = B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j) - A_(0,4)*X_(4,j);
3883template<
typename MT1
3889 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
3890void solve5x5(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
3906 using ET = ElementType_t<MT1>;
3908 CompositeType_t<MT1> A_( *A );
3910 const MT3& B_( *B );
3912 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4) ) ) {
3916 const size_t M( B_.rows() );
3917 const size_t N( B_.columns() );
3921 const ET invD0(
inv( A_(0,0) ) );
3922 const ET invD1(
inv( A_(1,1) ) );
3923 const ET invD2(
inv( A_(2,2) ) );
3924 const ET invD3(
inv( A_(3,3) ) );
3925 const ET invD4(
inv( A_(4,4) ) );
3927 for(
size_t j=0UL; j<N; ++j ) {
3928 X_(0,j) = B_(0,j) * invD0;
3929 X_(1,j) = B_(1,j) * invD1;
3930 X_(2,j) = B_(2,j) * invD2;
3931 X_(3,j) = B_(3,j) * invD3;
3932 X_(4,j) = B_(4,j) * invD4;
3968template<
typename MT
3974 , EnableIf_t< IsGeneral_v<MT> || ( IsHermitian_v<MT> && !IsSymmetric_v<MT> ) >* =
nullptr >
3975void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
3991 using ET = ElementType_t<MT>;
3993 CompositeType_t<MT> A_( *A );
3995 const VT2& b_( *b );
3999 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(1,0)*A_(0,1) );
4000 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(1,0)*A_(0,2) );
4001 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(1,0)*A_(0,3) );
4002 const ET tmp4 ( A_(0,0)*A_(1,4) - A_(1,0)*A_(0,4) );
4003 const ET tmp5 ( A_(0,0)*A_(1,5) - A_(1,0)*A_(0,5) );
4004 const ET tmp6 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
4005 const ET tmp7 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
4006 const ET tmp8 ( A_(0,1)*A_(1,4) - A_(1,1)*A_(0,4) );
4007 const ET tmp9 ( A_(0,1)*A_(1,5) - A_(1,1)*A_(0,5) );
4008 const ET tmp10( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
4009 const ET tmp11( A_(0,2)*A_(1,4) - A_(1,2)*A_(0,4) );
4010 const ET tmp12( A_(0,2)*A_(1,5) - A_(1,2)*A_(0,5) );
4011 const ET tmp13( A_(0,3)*A_(1,4) - A_(1,3)*A_(0,4) );
4012 const ET tmp14( A_(0,3)*A_(1,5) - A_(1,3)*A_(0,5) );
4013 const ET tmp15( A_(0,4)*A_(1,5) - A_(1,4)*A_(0,5) );
4015 const ET tmp16( tmp1*A_(2,2) - tmp2*A_(2,1) + tmp6*A_(2,0) );
4016 const ET tmp17( tmp1*A_(2,3) - tmp3*A_(2,1) + tmp7*A_(2,0) );
4017 const ET tmp18( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp10*A_(2,0) );
4018 const ET tmp19( tmp6*A_(2,3) - tmp7*A_(2,2) + tmp10*A_(2,1) );
4019 const ET tmp20( tmp1*A_(2,4) - tmp4*A_(2,1) + tmp8*A_(2,0) );
4020 const ET tmp21( tmp2*A_(2,4) - tmp4*A_(2,2) + tmp11*A_(2,0) );
4021 const ET tmp22( tmp6*A_(2,4) - tmp8*A_(2,2) + tmp11*A_(2,1) );
4022 const ET tmp23( tmp3*A_(2,4) - tmp4*A_(2,3) + tmp13*A_(2,0) );
4023 const ET tmp24( tmp7*A_(2,4) - tmp8*A_(2,3) + tmp13*A_(2,1) );
4024 const ET tmp25( tmp10*A_(2,4) - tmp11*A_(2,3) + tmp13*A_(2,2) );
4025 const ET tmp26( tmp1*A_(2,5) - tmp5*A_(2,1) + tmp9*A_(2,0) );
4026 const ET tmp27( tmp2*A_(2,5) - tmp5*A_(2,2) + tmp12*A_(2,0) );
4027 const ET tmp28( tmp6*A_(2,5) - tmp9*A_(2,2) + tmp12*A_(2,1) );
4028 const ET tmp29( tmp3*A_(2,5) - tmp5*A_(2,3) + tmp14*A_(2,0) );
4029 const ET tmp30( tmp7*A_(2,5) - tmp9*A_(2,3) + tmp14*A_(2,1) );
4030 const ET tmp31( tmp10*A_(2,5) - tmp12*A_(2,3) + tmp14*A_(2,2) );
4031 const ET tmp32( tmp4*A_(2,5) - tmp5*A_(2,4) + tmp15*A_(2,0) );
4032 const ET tmp33( tmp8*A_(2,5) - tmp9*A_(2,4) + tmp15*A_(2,1) );
4033 const ET tmp34( tmp11*A_(2,5) - tmp12*A_(2,4) + tmp15*A_(2,2) );
4034 const ET tmp35( tmp13*A_(2,5) - tmp14*A_(2,4) + tmp15*A_(2,3) );
4036 const ET tmp36( tmp16*A_(3,3) - tmp17*A_(3,2) + tmp18*A_(3,1) - tmp19*A_(3,0) );
4037 const ET tmp37( tmp16*A_(3,4) - tmp20*A_(3,2) + tmp21*A_(3,1) - tmp22*A_(3,0) );
4038 const ET tmp38( tmp17*A_(3,4) - tmp20*A_(3,3) + tmp23*A_(3,1) - tmp24*A_(3,0) );
4039 const ET tmp39( tmp18*A_(3,4) - tmp21*A_(3,3) + tmp23*A_(3,2) - tmp25*A_(3,0) );
4040 const ET tmp40( tmp19*A_(3,4) - tmp22*A_(3,3) + tmp24*A_(3,2) - tmp25*A_(3,1) );
4041 const ET tmp41( tmp16*A_(3,5) - tmp26*A_(3,2) + tmp27*A_(3,1) - tmp28*A_(3,0) );
4042 const ET tmp42( tmp17*A_(3,5) - tmp26*A_(3,3) + tmp29*A_(3,1) - tmp30*A_(3,0) );
4043 const ET tmp43( tmp18*A_(3,5) - tmp27*A_(3,3) + tmp29*A_(3,2) - tmp31*A_(3,0) );
4044 const ET tmp44( tmp19*A_(3,5) - tmp28*A_(3,3) + tmp30*A_(3,2) - tmp31*A_(3,1) );
4045 const ET tmp45( tmp20*A_(3,5) - tmp26*A_(3,4) + tmp32*A_(3,1) - tmp33*A_(3,0) );
4046 const ET tmp46( tmp21*A_(3,5) - tmp27*A_(3,4) + tmp32*A_(3,2) - tmp34*A_(3,0) );
4047 const ET tmp47( tmp22*A_(3,5) - tmp28*A_(3,4) + tmp33*A_(3,2) - tmp34*A_(3,1) );
4048 const ET tmp48( tmp23*A_(3,5) - tmp29*A_(3,4) + tmp32*A_(3,3) - tmp35*A_(3,0) );
4049 const ET tmp49( tmp24*A_(3,5) - tmp30*A_(3,4) + tmp33*A_(3,3) - tmp35*A_(3,1) );
4050 const ET tmp50( tmp25*A_(3,5) - tmp31*A_(3,4) + tmp34*A_(3,3) - tmp35*A_(3,2) );
4052 const ET tmp51( tmp36*A_(4,4) - tmp37*A_(4,3) + tmp38*A_(4,2) - tmp39*A_(4,1) + tmp40*A_(4,0) );
4053 const ET tmp52( tmp36*A_(4,5) - tmp41*A_(4,3) + tmp42*A_(4,2) - tmp43*A_(4,1) + tmp44*A_(4,0) );
4054 const ET tmp53( tmp37*A_(4,5) - tmp41*A_(4,4) + tmp45*A_(4,2) - tmp46*A_(4,1) + tmp47*A_(4,0) );
4055 const ET tmp54( tmp38*A_(4,5) - tmp42*A_(4,4) + tmp45*A_(4,3) - tmp48*A_(4,1) + tmp49*A_(4,0) );
4056 const ET tmp55( tmp39*A_(4,5) - tmp43*A_(4,4) + tmp46*A_(4,3) - tmp48*A_(4,2) + tmp50*A_(4,0) );
4057 const ET tmp56( tmp40*A_(4,5) - tmp44*A_(4,4) + tmp47*A_(4,3) - tmp49*A_(4,2) + tmp50*A_(4,1) );
4059 const ET D( tmp51*A_(5,5) - tmp52*A_(5,4) + tmp53*A_(5,3) - tmp54*A_(5,2) + tmp55*A_(5,1) - tmp56*A_(5,0) );
4065 const ET invD(
inv( D ) );
4067 const ET tmp57( A_(0,0)*b_[1] - A_(1,0)*b_[0] );
4068 const ET tmp58( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
4069 const ET tmp59( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
4070 const ET tmp60( A_(0,3)*b_[1] - A_(1,3)*b_[0] );
4071 const ET tmp61( A_(0,4)*b_[1] - A_(1,4)*b_[0] );
4073 const ET tmp62( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
4074 const ET tmp63( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
4075 const ET tmp64( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
4076 const ET tmp65( A_(1,4)*b_[0] - A_(0,4)*b_[1] );
4077 const ET tmp66( A_(1,5)*b_[0] - A_(0,5)*b_[1] );
4079 const ET tmp67( tmp62*A_(2,2) - tmp63*A_(2,1) + tmp6*b_[2] );
4080 const ET tmp68( tmp62*A_(2,3) - tmp64*A_(2,1) + tmp7*b_[2] );
4081 const ET tmp69( tmp63*A_(2,3) - tmp64*A_(2,2) + tmp10*b_[2] );
4082 const ET tmp70( tmp62*A_(2,4) - tmp65*A_(2,1) + tmp8*b_[2] );
4083 const ET tmp71( tmp63*A_(2,4) - tmp65*A_(2,2) + tmp11*b_[2] );
4084 const ET tmp72( tmp64*A_(2,4) - tmp65*A_(2,3) + tmp13*b_[2] );
4085 const ET tmp73( tmp62*A_(2,5) - tmp66*A_(2,1) + tmp9*b_[2] );
4086 const ET tmp74( tmp63*A_(2,5) - tmp66*A_(2,2) + tmp12*b_[2] );
4087 const ET tmp75( tmp64*A_(2,5) - tmp66*A_(2,3) + tmp14*b_[2] );
4088 const ET tmp76( tmp65*A_(2,5) - tmp66*A_(2,4) + tmp15*b_[2] );
4090 const ET tmp77( tmp57*A_(2,2) - tmp2*b_[2] + tmp63*A_(2,0) );
4091 const ET tmp78( tmp57*A_(2,3) - tmp3*b_[2] + tmp64*A_(2,0) );
4092 const ET tmp79( tmp58*A_(2,3) - tmp7*b_[2] + tmp64*A_(2,1) );
4093 const ET tmp80( tmp57*A_(2,4) - tmp4*b_[2] + tmp65*A_(2,0) );
4094 const ET tmp81( tmp58*A_(2,4) - tmp8*b_[2] + tmp65*A_(2,1) );
4095 const ET tmp82( tmp59*A_(2,4) - tmp11*b_[2] + tmp65*A_(2,2) );
4096 const ET tmp83( tmp57*A_(2,5) - tmp5*b_[2] + tmp66*A_(2,0) );
4097 const ET tmp84( tmp58*A_(2,5) - tmp9*b_[2] + tmp66*A_(2,1) );
4098 const ET tmp85( tmp59*A_(2,5) - tmp12*b_[2] + tmp66*A_(2,2) );
4099 const ET tmp86( tmp60*A_(2,5) - tmp14*b_[2] + tmp66*A_(2,3) );
4101 const ET tmp87( tmp1*b_[2] - tmp57*A_(2,1) + tmp58*A_(2,0) );
4102 const ET tmp88( tmp2*b_[2] - tmp57*A_(2,2) + tmp59*A_(2,0) );
4103 const ET tmp89( tmp6*b_[2] - tmp58*A_(2,2) + tmp59*A_(2,1) );
4104 const ET tmp90( tmp3*b_[2] - tmp57*A_(2,3) + tmp60*A_(2,0) );
4105 const ET tmp91( tmp7*b_[2] - tmp58*A_(2,3) + tmp60*A_(2,1) );
4106 const ET tmp92( tmp10*b_[2] - tmp59*A_(2,3) + tmp60*A_(2,2) );
4107 const ET tmp93( tmp4*b_[2] - tmp57*A_(2,4) + tmp61*A_(2,0) );
4108 const ET tmp94( tmp8*b_[2] - tmp58*A_(2,4) + tmp61*A_(2,1) );
4109 const ET tmp95( tmp11*b_[2] - tmp59*A_(2,4) + tmp61*A_(2,2) );
4110 const ET tmp96( tmp13*b_[2] - tmp60*A_(2,4) + tmp61*A_(2,3) );
4112 const ET tmp97 ( tmp67*A_(3,3) - tmp68*A_(3,2) + tmp69*A_(3,1) - tmp19*b_[3] );
4113 const ET tmp98 ( tmp67*A_(3,4) - tmp70*A_(3,2) + tmp71*A_(3,1) - tmp22*b_[3] );
4114 const ET tmp99 ( tmp68*A_(3,4) - tmp70*A_(3,3) + tmp72*A_(3,1) - tmp24*b_[3] );
4115 const ET tmp100( tmp69*A_(3,4) - tmp71*A_(3,3) + tmp72*A_(3,2) - tmp25*b_[3] );
4116 const ET tmp101( tmp67*A_(3,5) - tmp73*A_(3,2) + tmp74*A_(3,1) - tmp28*b_[3] );
4117 const ET tmp102( tmp68*A_(3,5) - tmp73*A_(3,3) + tmp75*A_(3,1) - tmp30*b_[3] );
4118 const ET tmp103( tmp69*A_(3,5) - tmp74*A_(3,3) + tmp75*A_(3,2) - tmp31*b_[3] );
4119 const ET tmp104( tmp70*A_(3,5) - tmp73*A_(3,4) + tmp76*A_(3,1) - tmp33*b_[3] );
4120 const ET tmp105( tmp71*A_(3,5) - tmp74*A_(3,4) + tmp76*A_(3,2) - tmp34*b_[3] );
4121 const ET tmp106( tmp72*A_(3,5) - tmp75*A_(3,4) + tmp76*A_(3,3) - tmp35*b_[3] );
4123 const ET tmp107( tmp77*A_(3,3) - tmp78*A_(3,2) + tmp18*b_[3] - tmp69*A_(3,0) );
4124 const ET tmp108( tmp77*A_(3,4) - tmp80*A_(3,2) + tmp21*b_[3] - tmp71*A_(3,0) );
4125 const ET tmp109( tmp78*A_(3,4) - tmp80*A_(3,3) + tmp23*b_[3] - tmp72*A_(3,0) );
4126 const ET tmp110( tmp79*A_(3,4) - tmp81*A_(3,3) + tmp24*b_[3] - tmp72*A_(3,1) );
4127 const ET tmp111( tmp77*A_(3,5) - tmp83*A_(3,2) + tmp27*b_[3] - tmp74*A_(3,0) );
4128 const ET tmp112( tmp78*A_(3,5) - tmp83*A_(3,3) + tmp29*b_[3] - tmp75*A_(3,0) );
4129 const ET tmp113( tmp79*A_(3,5) - tmp84*A_(3,3) + tmp30*b_[3] - tmp75*A_(3,1) );
4130 const ET tmp114( tmp80*A_(3,5) - tmp83*A_(3,4) + tmp32*b_[3] - tmp76*A_(3,0) );
4131 const ET tmp115( tmp81*A_(3,5) - tmp84*A_(3,4) + tmp33*b_[3] - tmp76*A_(3,1) );
4132 const ET tmp116( tmp82*A_(3,5) - tmp85*A_(3,4) + tmp34*b_[3] - tmp76*A_(3,2) );
4134 const ET tmp117( tmp87*A_(3,3) - tmp17*b_[3] + tmp78*A_(3,1) - tmp79*A_(3,0) );
4135 const ET tmp118( tmp87*A_(3,4) - tmp20*b_[3] + tmp80*A_(3,1) - tmp81*A_(3,0) );
4136 const ET tmp119( tmp88*A_(3,4) - tmp21*b_[3] + tmp80*A_(3,2) - tmp82*A_(3,0) );
4137 const ET tmp120( tmp89*A_(3,4) - tmp22*b_[3] + tmp81*A_(3,2) - tmp82*A_(3,1) );
4138 const ET tmp121( tmp87*A_(3,5) - tmp26*b_[3] + tmp83*A_(3,1) - tmp84*A_(3,0) );
4139 const ET tmp122( tmp88*A_(3,5) - tmp27*b_[3] + tmp83*A_(3,2) - tmp85*A_(3,0) );
4140 const ET tmp123( tmp89*A_(3,5) - tmp28*b_[3] + tmp84*A_(3,2) - tmp85*A_(3,1) );
4141 const ET tmp124( tmp90*A_(3,5) - tmp29*b_[3] + tmp83*A_(3,3) - tmp86*A_(3,0) );
4142 const ET tmp125( tmp91*A_(3,5) - tmp30*b_[3] + tmp84*A_(3,3) - tmp86*A_(3,1) );
4143 const ET tmp126( tmp92*A_(3,5) - tmp31*b_[3] + tmp85*A_(3,3) - tmp86*A_(3,2) );
4145 const ET tmp127( tmp16*b_[3] - tmp87*A_(3,2) + tmp88*A_(3,1) - tmp89*A_(3,0) );
4146 const ET tmp128( tmp17*b_[3] - tmp87*A_(3,3) + tmp90*A_(3,1) - tmp91*A_(3,0) );
4147 const ET tmp129( tmp18*b_[3] - tmp88*A_(3,3) + tmp90*A_(3,2) - tmp92*A_(3,0) );
4148 const ET tmp130( tmp19*b_[3] - tmp89*A_(3,3) + tmp91*A_(3,2) - tmp92*A_(3,1) );
4149 const ET tmp131( tmp20*b_[3] - tmp87*A_(3,4) + tmp93*A_(3,1) - tmp94*A_(3,0) );
4150 const ET tmp132( tmp21*b_[3] - tmp88*A_(3,4) + tmp93*A_(3,2) - tmp95*A_(3,0) );
4151 const ET tmp133( tmp22*b_[3] - tmp89*A_(3,4) + tmp94*A_(3,2) - tmp95*A_(3,1) );
4152 const ET tmp134( tmp23*b_[3] - tmp90*A_(3,4) + tmp93*A_(3,3) - tmp96*A_(3,0) );
4153 const ET tmp135( tmp24*b_[3] - tmp91*A_(3,4) + tmp94*A_(3,3) - tmp96*A_(3,1) );
4154 const ET tmp136( tmp25*b_[3] - tmp92*A_(3,4) + tmp95*A_(3,3) - tmp96*A_(3,2) );
4156 const ET tmp137( tmp97*A_(4,4) - tmp98*A_(4,3) + tmp99*A_(4,2) - tmp100*A_(4,1) + tmp40*b_[4] );
4157 const ET tmp138( tmp97*A_(4,5) - tmp101*A_(4,3) + tmp102*A_(4,2) - tmp103*A_(4,1) + tmp44*b_[4] );
4158 const ET tmp139( tmp98*A_(4,5) - tmp101*A_(4,4) + tmp104*A_(4,2) - tmp105*A_(4,1) + tmp47*b_[4] );
4159 const ET tmp140( tmp99*A_(4,5) - tmp102*A_(4,4) + tmp104*A_(4,3) - tmp106*A_(4,1) + tmp49*b_[4] );
4160 const ET tmp141( tmp100*A_(4,5) - tmp103*A_(4,4) + tmp105*A_(4,3) - tmp106*A_(4,2) + tmp50*b_[4] );
4162 const ET tmp142( tmp107*A_(4,4) - tmp108*A_(4,3) + tmp109*A_(4,2) - tmp39*b_[4] + tmp100*A_(4,0) );
4163 const ET tmp143( tmp107*A_(4,5) - tmp111*A_(4,3) + tmp112*A_(4,2) - tmp43*b_[4] + tmp103*A_(4,0) );
4164 const ET tmp144( tmp108*A_(4,5) - tmp111*A_(4,4) + tmp114*A_(4,2) - tmp46*b_[4] + tmp105*A_(4,0) );
4165 const ET tmp145( tmp109*A_(4,5) - tmp112*A_(4,4) + tmp114*A_(4,3) - tmp48*b_[4] + tmp106*A_(4,0) );
4166 const ET tmp146( tmp110*A_(4,5) - tmp113*A_(4,4) + tmp115*A_(4,3) - tmp49*b_[4] + tmp106*A_(4,1) );
4168 const ET tmp147( tmp117*A_(4,4) - tmp118*A_(4,3) + tmp38*b_[4] - tmp109*A_(4,1) + tmp110*A_(4,0) );
4169 const ET tmp148( tmp117*A_(4,5) - tmp121*A_(4,3) + tmp42*b_[4] - tmp112*A_(4,1) + tmp113*A_(4,0) );
4170 const ET tmp149( tmp118*A_(4,5) - tmp121*A_(4,4) + tmp45*b_[4] - tmp114*A_(4,1) + tmp115*A_(4,0) );
4171 const ET tmp150( tmp119*A_(4,5) - tmp122*A_(4,4) + tmp46*b_[4] - tmp114*A_(4,2) + tmp116*A_(4,0) );
4172 const ET tmp151( tmp120*A_(4,5) - tmp123*A_(4,4) + tmp47*b_[4] - tmp115*A_(4,2) + tmp116*A_(4,1) );
4174 const ET tmp152( tmp127*A_(4,4) - tmp37*b_[4] + tmp118*A_(4,2) - tmp119*A_(4,1) + tmp120*A_(4,0) );
4175 const ET tmp153( tmp127*A_(4,5) - tmp41*b_[4] + tmp121*A_(4,2) - tmp122*A_(4,1) + tmp123*A_(4,0) );
4176 const ET tmp154( tmp128*A_(4,5) - tmp42*b_[4] + tmp121*A_(4,3) - tmp124*A_(4,1) + tmp125*A_(4,0) );
4177 const ET tmp155( tmp129*A_(4,5) - tmp43*b_[4] + tmp122*A_(4,3) - tmp124*A_(4,2) + tmp126*A_(4,0) );
4178 const ET tmp156( tmp130*A_(4,5) - tmp44*b_[4] + tmp123*A_(4,3) - tmp125*A_(4,2) + tmp126*A_(4,1) );
4180 const ET tmp157( tmp36*b_[4] - tmp127*A_(4,3) + tmp128*A_(4,2) - tmp129*A_(4,1) + tmp130*A_(4,0) );
4181 const ET tmp158( tmp37*b_[4] - tmp127*A_(4,4) + tmp131*A_(4,2) - tmp132*A_(4,1) + tmp133*A_(4,0) );
4182 const ET tmp159( tmp38*b_[4] - tmp128*A_(4,4) + tmp131*A_(4,3) - tmp134*A_(4,1) + tmp135*A_(4,0) );
4183 const ET tmp160( tmp39*b_[4] - tmp129*A_(4,4) + tmp132*A_(4,3) - tmp134*A_(4,2) + tmp136*A_(4,0) );
4184 const ET tmp161( tmp40*b_[4] - tmp130*A_(4,4) + tmp133*A_(4,3) - tmp135*A_(4,2) + tmp136*A_(4,1) );
4186 x_[0] = ( tmp137*A_(5,5) - tmp138*A_(5,4) + tmp139*A_(5,3) - tmp140*A_(5,2) + tmp141*A_(5,1) - tmp56*b_[5] ) * invD;
4187 x_[1] = ( tmp142*A_(5,5) - tmp143*A_(5,4) + tmp144*A_(5,3) - tmp145*A_(5,2) + tmp55*b_[5] - tmp141*A_(5,0) ) * invD;
4188 x_[2] = ( tmp147*A_(5,5) - tmp148*A_(5,4) + tmp149*A_(5,3) - tmp54*b_[5] + tmp145*A_(5,1) - tmp146*A_(5,0) ) * invD;
4189 x_[3] = ( tmp152*A_(5,5) - tmp153*A_(5,4) + tmp53*b_[5] - tmp149*A_(5,2) + tmp150*A_(5,1) - tmp151*A_(5,0) ) * invD;
4190 x_[4] = ( tmp157*A_(5,5) - tmp52*b_[5] + tmp153*A_(5,3) - tmp154*A_(5,2) + tmp155*A_(5,1) - tmp156*A_(5,0) ) * invD;
4191 x_[5] = ( tmp51*b_[5] - tmp157*A_(5,4) + tmp158*A_(5,3) - tmp159*A_(5,2) + tmp160*A_(5,1) - tmp161*A_(5,0) ) * invD;
4218template<
typename MT
4224 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
4225void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4241 using ET = ElementType_t<MT>;
4243 CompositeType_t<MT> A_( *A );
4245 const VT2& b_( *b );
4249 const ET tmp1 ( A_(0,0)*A_(1,1) - A_(0,1)*A_(0,1) );
4250 const ET tmp2 ( A_(0,0)*A_(1,2) - A_(0,1)*A_(0,2) );
4251 const ET tmp3 ( A_(0,0)*A_(1,3) - A_(0,1)*A_(0,3) );
4252 const ET tmp4 ( A_(0,0)*A_(1,4) - A_(0,1)*A_(0,4) );
4253 const ET tmp5 ( A_(0,0)*A_(1,5) - A_(0,1)*A_(0,5) );
4254 const ET tmp6 ( A_(0,1)*A_(1,2) - A_(1,1)*A_(0,2) );
4255 const ET tmp7 ( A_(0,1)*A_(1,3) - A_(1,1)*A_(0,3) );
4256 const ET tmp8 ( A_(0,1)*A_(1,4) - A_(1,1)*A_(0,4) );
4257 const ET tmp9 ( A_(0,1)*A_(1,5) - A_(1,1)*A_(0,5) );
4258 const ET tmp10( A_(0,2)*A_(1,3) - A_(1,2)*A_(0,3) );
4259 const ET tmp11( A_(0,2)*A_(1,4) - A_(1,2)*A_(0,4) );
4260 const ET tmp12( A_(0,2)*A_(1,5) - A_(1,2)*A_(0,5) );
4261 const ET tmp13( A_(0,3)*A_(1,4) - A_(1,3)*A_(0,4) );
4262 const ET tmp14( A_(0,3)*A_(1,5) - A_(1,3)*A_(0,5) );
4263 const ET tmp15( A_(0,4)*A_(1,5) - A_(1,4)*A_(0,5) );
4265 const ET tmp16( tmp1*A_(2,2) - tmp2*A_(1,2) + tmp6*A_(0,2) );
4266 const ET tmp17( tmp1*A_(2,3) - tmp3*A_(1,2) + tmp7*A_(0,2) );
4267 const ET tmp18( tmp2*A_(2,3) - tmp3*A_(2,2) + tmp10*A_(0,2) );
4268 const ET tmp19( tmp6*A_(2,3) - tmp7*A_(2,2) + tmp10*A_(1,2) );
4269 const ET tmp20( tmp1*A_(2,4) - tmp4*A_(1,2) + tmp8*A_(0,2) );
4270 const ET tmp21( tmp2*A_(2,4) - tmp4*A_(2,2) + tmp11*A_(0,2) );
4271 const ET tmp22( tmp6*A_(2,4) - tmp8*A_(2,2) + tmp11*A_(1,2) );
4272 const ET tmp23( tmp3*A_(2,4) - tmp4*A_(2,3) + tmp13*A_(0,2) );
4273 const ET tmp24( tmp7*A_(2,4) - tmp8*A_(2,3) + tmp13*A_(1,2) );
4274 const ET tmp25( tmp10*A_(2,4) - tmp11*A_(2,3) + tmp13*A_(2,2) );
4275 const ET tmp26( tmp1*A_(2,5) - tmp5*A_(1,2) + tmp9*A_(0,2) );
4276 const ET tmp27( tmp2*A_(2,5) - tmp5*A_(2,2) + tmp12*A_(0,2) );
4277 const ET tmp28( tmp6*A_(2,5) - tmp9*A_(2,2) + tmp12*A_(1,2) );
4278 const ET tmp29( tmp3*A_(2,5) - tmp5*A_(2,3) + tmp14*A_(0,2) );
4279 const ET tmp30( tmp7*A_(2,5) - tmp9*A_(2,3) + tmp14*A_(1,2) );
4280 const ET tmp31( tmp10*A_(2,5) - tmp12*A_(2,3) + tmp14*A_(2,2) );
4281 const ET tmp32( tmp4*A_(2,5) - tmp5*A_(2,4) + tmp15*A_(0,2) );
4282 const ET tmp33( tmp8*A_(2,5) - tmp9*A_(2,4) + tmp15*A_(1,2) );
4283 const ET tmp34( tmp11*A_(2,5) - tmp12*A_(2,4) + tmp15*A_(2,2) );
4284 const ET tmp35( tmp13*A_(2,5) - tmp14*A_(2,4) + tmp15*A_(2,3) );
4286 const ET tmp36( tmp16*A_(3,3) - tmp17*A_(2,3) + tmp18*A_(1,3) - tmp19*A_(0,3) );
4287 const ET tmp37( tmp16*A_(3,4) - tmp20*A_(2,3) + tmp21*A_(1,3) - tmp22*A_(0,3) );
4288 const ET tmp38( tmp17*A_(3,4) - tmp20*A_(3,3) + tmp23*A_(1,3) - tmp24*A_(0,3) );
4289 const ET tmp39( tmp18*A_(3,4) - tmp21*A_(3,3) + tmp23*A_(2,3) - tmp25*A_(0,3) );
4290 const ET tmp40( tmp19*A_(3,4) - tmp22*A_(3,3) + tmp24*A_(2,3) - tmp25*A_(1,3) );
4291 const ET tmp41( tmp16*A_(3,5) - tmp26*A_(2,3) + tmp27*A_(1,3) - tmp28*A_(0,3) );
4292 const ET tmp42( tmp17*A_(3,5) - tmp26*A_(3,3) + tmp29*A_(1,3) - tmp30*A_(0,3) );
4293 const ET tmp43( tmp18*A_(3,5) - tmp27*A_(3,3) + tmp29*A_(2,3) - tmp31*A_(0,3) );
4294 const ET tmp44( tmp19*A_(3,5) - tmp28*A_(3,3) + tmp30*A_(2,3) - tmp31*A_(1,3) );
4295 const ET tmp45( tmp20*A_(3,5) - tmp26*A_(3,4) + tmp32*A_(1,3) - tmp33*A_(0,3) );
4296 const ET tmp46( tmp21*A_(3,5) - tmp27*A_(3,4) + tmp32*A_(2,3) - tmp34*A_(0,3) );
4297 const ET tmp47( tmp22*A_(3,5) - tmp28*A_(3,4) + tmp33*A_(2,3) - tmp34*A_(1,3) );
4298 const ET tmp48( tmp23*A_(3,5) - tmp29*A_(3,4) + tmp32*A_(3,3) - tmp35*A_(0,3) );
4299 const ET tmp49( tmp24*A_(3,5) - tmp30*A_(3,4) + tmp33*A_(3,3) - tmp35*A_(1,3) );
4300 const ET tmp50( tmp25*A_(3,5) - tmp31*A_(3,4) + tmp34*A_(3,3) - tmp35*A_(2,3) );
4302 const ET tmp51( tmp36*A_(4,4) - tmp37*A_(3,4) + tmp38*A_(2,4) - tmp39*A_(1,4) + tmp40*A_(0,4) );
4303 const ET tmp52( tmp36*A_(4,5) - tmp41*A_(3,4) + tmp42*A_(2,4) - tmp43*A_(1,4) + tmp44*A_(0,4) );
4304 const ET tmp53( tmp37*A_(4,5) - tmp41*A_(4,4) + tmp45*A_(2,4) - tmp46*A_(1,4) + tmp47*A_(0,4) );
4305 const ET tmp54( tmp38*A_(4,5) - tmp42*A_(4,4) + tmp45*A_(3,4) - tmp48*A_(1,4) + tmp49*A_(0,4) );
4306 const ET tmp55( tmp39*A_(4,5) - tmp43*A_(4,4) + tmp46*A_(3,4) - tmp48*A_(2,4) + tmp50*A_(0,4) );
4307 const ET tmp56( tmp40*A_(4,5) - tmp44*A_(4,4) + tmp47*A_(3,4) - tmp49*A_(2,4) + tmp50*A_(1,4) );
4309 const ET D( tmp51*A_(5,5) - tmp52*A_(4,5) + tmp53*A_(3,5) - tmp54*A_(2,5) + tmp55*A_(1,5) - tmp56*A_(0,5) );
4315 const ET invD(
inv( D ) );
4317 const ET tmp57( A_(0,0)*b_[1] - A_(0,1)*b_[0] );
4318 const ET tmp58( A_(0,1)*b_[1] - A_(1,1)*b_[0] );
4319 const ET tmp59( A_(0,2)*b_[1] - A_(1,2)*b_[0] );
4320 const ET tmp60( A_(0,3)*b_[1] - A_(1,3)*b_[0] );
4321 const ET tmp61( A_(0,4)*b_[1] - A_(1,4)*b_[0] );
4323 const ET tmp62( A_(1,1)*b_[0] - A_(0,1)*b_[1] );
4324 const ET tmp63( A_(1,2)*b_[0] - A_(0,2)*b_[1] );
4325 const ET tmp64( A_(1,3)*b_[0] - A_(0,3)*b_[1] );
4326 const ET tmp65( A_(1,4)*b_[0] - A_(0,4)*b_[1] );
4327 const ET tmp66( A_(1,5)*b_[0] - A_(0,5)*b_[1] );
4329 const ET tmp67( tmp62*A_(2,2) - tmp63*A_(1,2) + tmp6*b_[2] );
4330 const ET tmp68( tmp62*A_(2,3) - tmp64*A_(1,2) + tmp7*b_[2] );
4331 const ET tmp69( tmp63*A_(2,3) - tmp64*A_(2,2) + tmp10*b_[2] );
4332 const ET tmp70( tmp62*A_(2,4) - tmp65*A_(1,2) + tmp8*b_[2] );
4333 const ET tmp71( tmp63*A_(2,4) - tmp65*A_(2,2) + tmp11*b_[2] );
4334 const ET tmp72( tmp64*A_(2,4) - tmp65*A_(2,3) + tmp13*b_[2] );
4335 const ET tmp73( tmp62*A_(2,5) - tmp66*A_(1,2) + tmp9*b_[2] );
4336 const ET tmp74( tmp63*A_(2,5) - tmp66*A_(2,2) + tmp12*b_[2] );
4337 const ET tmp75( tmp64*A_(2,5) - tmp66*A_(2,3) + tmp14*b_[2] );
4338 const ET tmp76( tmp65*A_(2,5) - tmp66*A_(2,4) + tmp15*b_[2] );
4340 const ET tmp77( tmp57*A_(2,2) - tmp2*b_[2] + tmp63*A_(0,2) );
4341 const ET tmp78( tmp57*A_(2,3) - tmp3*b_[2] + tmp64*A_(0,2) );
4342 const ET tmp79( tmp58*A_(2,3) - tmp7*b_[2] + tmp64*A_(1,2) );
4343 const ET tmp80( tmp57*A_(2,4) - tmp4*b_[2] + tmp65*A_(0,2) );
4344 const ET tmp81( tmp58*A_(2,4) - tmp8*b_[2] + tmp65*A_(1,2) );
4345 const ET tmp82( tmp59*A_(2,4) - tmp11*b_[2] + tmp65*A_(2,2) );
4346 const ET tmp83( tmp57*A_(2,5) - tmp5*b_[2] + tmp66*A_(0,2) );
4347 const ET tmp84( tmp58*A_(2,5) - tmp9*b_[2] + tmp66*A_(1,2) );
4348 const ET tmp85( tmp59*A_(2,5) - tmp12*b_[2] + tmp66*A_(2,2) );
4349 const ET tmp86( tmp60*A_(2,5) - tmp14*b_[2] + tmp66*A_(2,3) );
4351 const ET tmp87( tmp1*b_[2] - tmp57*A_(1,2) + tmp58*A_(0,2) );
4352 const ET tmp88( tmp2*b_[2] - tmp57*A_(2,2) + tmp59*A_(0,2) );
4353 const ET tmp89( tmp6*b_[2] - tmp58*A_(2,2) + tmp59*A_(1,2) );
4354 const ET tmp90( tmp3*b_[2] - tmp57*A_(2,3) + tmp60*A_(0,2) );
4355 const ET tmp91( tmp7*b_[2] - tmp58*A_(2,3) + tmp60*A_(1,2) );
4356 const ET tmp92( tmp10*b_[2] - tmp59*A_(2,3) + tmp60*A_(2,2) );
4357 const ET tmp93( tmp4*b_[2] - tmp57*A_(2,4) + tmp61*A_(0,2) );
4358 const ET tmp94( tmp8*b_[2] - tmp58*A_(2,4) + tmp61*A_(1,2) );
4359 const ET tmp95( tmp11*b_[2] - tmp59*A_(2,4) + tmp61*A_(2,2) );
4360 const ET tmp96( tmp13*b_[2] - tmp60*A_(2,4) + tmp61*A_(2,3) );
4362 const ET tmp97 ( tmp67*A_(3,3) - tmp68*A_(2,3) + tmp69*A_(1,3) - tmp19*b_[3] );
4363 const ET tmp98 ( tmp67*A_(3,4) - tmp70*A_(2,3) + tmp71*A_(1,3) - tmp22*b_[3] );
4364 const ET tmp99 ( tmp68*A_(3,4) - tmp70*A_(3,3) + tmp72*A_(1,3) - tmp24*b_[3] );
4365 const ET tmp100( tmp69*A_(3,4) - tmp71*A_(3,3) + tmp72*A_(2,3) - tmp25*b_[3] );
4366 const ET tmp101( tmp67*A_(3,5) - tmp73*A_(2,3) + tmp74*A_(1,3) - tmp28*b_[3] );
4367 const ET tmp102( tmp68*A_(3,5) - tmp73*A_(3,3) + tmp75*A_(1,3) - tmp30*b_[3] );
4368 const ET tmp103( tmp69*A_(3,5) - tmp74*A_(3,3) + tmp75*A_(2,3) - tmp31*b_[3] );
4369 const ET tmp104( tmp70*A_(3,5) - tmp73*A_(3,4) + tmp76*A_(1,3) - tmp33*b_[3] );
4370 const ET tmp105( tmp71*A_(3,5) - tmp74*A_(3,4) + tmp76*A_(2,3) - tmp34*b_[3] );
4371 const ET tmp106( tmp72*A_(3,5) - tmp75*A_(3,4) + tmp76*A_(3,3) - tmp35*b_[3] );
4373 const ET tmp107( tmp77*A_(3,3) - tmp78*A_(2,3) + tmp18*b_[3] - tmp69*A_(0,3) );
4374 const ET tmp108( tmp77*A_(3,4) - tmp80*A_(2,3) + tmp21*b_[3] - tmp71*A_(0,3) );
4375 const ET tmp109( tmp78*A_(3,4) - tmp80*A_(3,3) + tmp23*b_[3] - tmp72*A_(0,3) );
4376 const ET tmp110( tmp79*A_(3,4) - tmp81*A_(3,3) + tmp24*b_[3] - tmp72*A_(1,3) );
4377 const ET tmp111( tmp77*A_(3,5) - tmp83*A_(2,3) + tmp27*b_[3] - tmp74*A_(0,3) );
4378 const ET tmp112( tmp78*A_(3,5) - tmp83*A_(3,3) + tmp29*b_[3] - tmp75*A_(0,3) );
4379 const ET tmp113( tmp79*A_(3,5) - tmp84*A_(3,3) + tmp30*b_[3] - tmp75*A_(1,3) );
4380 const ET tmp114( tmp80*A_(3,5) - tmp83*A_(3,4) + tmp32*b_[3] - tmp76*A_(0,3) );
4381 const ET tmp115( tmp81*A_(3,5) - tmp84*A_(3,4) + tmp33*b_[3] - tmp76*A_(1,3) );
4382 const ET tmp116( tmp82*A_(3,5) - tmp85*A_(3,4) + tmp34*b_[3] - tmp76*A_(2,3) );
4384 const ET tmp117( tmp87*A_(3,3) - tmp17*b_[3] + tmp78*A_(1,3) - tmp79*A_(0,3) );
4385 const ET tmp118( tmp87*A_(3,4) - tmp20*b_[3] + tmp80*A_(1,3) - tmp81*A_(0,3) );
4386 const ET tmp119( tmp88*A_(3,4) - tmp21*b_[3] + tmp80*A_(2,3) - tmp82*A_(0,3) );
4387 const ET tmp120( tmp89*A_(3,4) - tmp22*b_[3] + tmp81*A_(2,3) - tmp82*A_(1,3) );
4388 const ET tmp121( tmp87*A_(3,5) - tmp26*b_[3] + tmp83*A_(1,3) - tmp84*A_(0,3) );
4389 const ET tmp122( tmp88*A_(3,5) - tmp27*b_[3] + tmp83*A_(2,3) - tmp85*A_(0,3) );
4390 const ET tmp123( tmp89*A_(3,5) - tmp28*b_[3] + tmp84*A_(2,3) - tmp85*A_(1,3) );
4391 const ET tmp124( tmp90*A_(3,5) - tmp29*b_[3] + tmp83*A_(3,3) - tmp86*A_(0,3) );
4392 const ET tmp125( tmp91*A_(3,5) - tmp30*b_[3] + tmp84*A_(3,3) - tmp86*A_(1,3) );
4393 const ET tmp126( tmp92*A_(3,5) - tmp31*b_[3] + tmp85*A_(3,3) - tmp86*A_(2,3) );
4395 const ET tmp127( tmp16*b_[3] - tmp87*A_(2,3) + tmp88*A_(1,3) - tmp89*A_(0,3) );
4396 const ET tmp128( tmp17*b_[3] - tmp87*A_(3,3) + tmp90*A_(1,3) - tmp91*A_(0,3) );
4397 const ET tmp129( tmp18*b_[3] - tmp88*A_(3,3) + tmp90*A_(2,3) - tmp92*A_(0,3) );
4398 const ET tmp130( tmp19*b_[3] - tmp89*A_(3,3) + tmp91*A_(2,3) - tmp92*A_(1,3) );
4399 const ET tmp131( tmp20*b_[3] - tmp87*A_(3,4) + tmp93*A_(1,3) - tmp94*A_(0,3) );
4400 const ET tmp132( tmp21*b_[3] - tmp88*A_(3,4) + tmp93*A_(2,3) - tmp95*A_(0,3) );
4401 const ET tmp133( tmp22*b_[3] - tmp89*A_(3,4) + tmp94*A_(2,3) - tmp95*A_(1,3) );
4402 const ET tmp134( tmp23*b_[3] - tmp90*A_(3,4) + tmp93*A_(3,3) - tmp96*A_(0,3) );
4403 const ET tmp135( tmp24*b_[3] - tmp91*A_(3,4) + tmp94*A_(3,3) - tmp96*A_(1,3) );
4404 const ET tmp136( tmp25*b_[3] - tmp92*A_(3,4) + tmp95*A_(3,3) - tmp96*A_(2,3) );
4406 const ET tmp137( tmp97*A_(4,4) - tmp98*A_(3,4) + tmp99*A_(2,4) - tmp100*A_(1,4) + tmp40*b_[4] );
4407 const ET tmp138( tmp97*A_(4,5) - tmp101*A_(3,4) + tmp102*A_(2,4) - tmp103*A_(1,4) + tmp44*b_[4] );
4408 const ET tmp139( tmp98*A_(4,5) - tmp101*A_(4,4) + tmp104*A_(2,4) - tmp105*A_(1,4) + tmp47*b_[4] );
4409 const ET tmp140( tmp99*A_(4,5) - tmp102*A_(4,4) + tmp104*A_(3,4) - tmp106*A_(1,4) + tmp49*b_[4] );
4410 const ET tmp141( tmp100*A_(4,5) - tmp103*A_(4,4) + tmp105*A_(3,4) - tmp106*A_(2,4) + tmp50*b_[4] );
4412 const ET tmp142( tmp107*A_(4,4) - tmp108*A_(3,4) + tmp109*A_(2,4) - tmp39*b_[4] + tmp100*A_(0,4) );
4413 const ET tmp143( tmp107*A_(4,5) - tmp111*A_(3,4) + tmp112*A_(2,4) - tmp43*b_[4] + tmp103*A_(0,4) );
4414 const ET tmp144( tmp108*A_(4,5) - tmp111*A_(4,4) + tmp114*A_(2,4) - tmp46*b_[4] + tmp105*A_(0,4) );
4415 const ET tmp145( tmp109*A_(4,5) - tmp112*A_(4,4) + tmp114*A_(3,4) - tmp48*b_[4] + tmp106*A_(0,4) );
4416 const ET tmp146( tmp110*A_(4,5) - tmp113*A_(4,4) + tmp115*A_(3,4) - tmp49*b_[4] + tmp106*A_(1,4) );
4418 const ET tmp147( tmp117*A_(4,4) - tmp118*A_(3,4) + tmp38*b_[4] - tmp109*A_(1,4) + tmp110*A_(0,4) );
4419 const ET tmp148( tmp117*A_(4,5) - tmp121*A_(3,4) + tmp42*b_[4] - tmp112*A_(1,4) + tmp113*A_(0,4) );
4420 const ET tmp149( tmp118*A_(4,5) - tmp121*A_(4,4) + tmp45*b_[4] - tmp114*A_(1,4) + tmp115*A_(0,4) );
4421 const ET tmp150( tmp119*A_(4,5) - tmp122*A_(4,4) + tmp46*b_[4] - tmp114*A_(2,4) + tmp116*A_(0,4) );
4422 const ET tmp151( tmp120*A_(4,5) - tmp123*A_(4,4) + tmp47*b_[4] - tmp115*A_(2,4) + tmp116*A_(1,4) );
4424 const ET tmp152( tmp127*A_(4,4) - tmp37*b_[4] + tmp118*A_(2,4) - tmp119*A_(1,4) + tmp120*A_(0,4) );
4425 const ET tmp153( tmp127*A_(4,5) - tmp41*b_[4] + tmp121*A_(2,4) - tmp122*A_(1,4) + tmp123*A_(0,4) );
4426 const ET tmp154( tmp128*A_(4,5) - tmp42*b_[4] + tmp121*A_(3,4) - tmp124*A_(1,4) + tmp125*A_(0,4) );
4427 const ET tmp155( tmp129*A_(4,5) - tmp43*b_[4] + tmp122*A_(3,4) - tmp124*A_(2,4) + tmp126*A_(0,4) );
4428 const ET tmp156( tmp130*A_(4,5) - tmp44*b_[4] + tmp123*A_(3,4) - tmp125*A_(2,4) + tmp126*A_(1,4) );
4430 const ET tmp157( tmp36*b_[4] - tmp127*A_(3,4) + tmp128*A_(2,4) - tmp129*A_(1,4) + tmp130*A_(0,4) );
4431 const ET tmp158( tmp37*b_[4] - tmp127*A_(4,4) + tmp131*A_(2,4) - tmp132*A_(1,4) + tmp133*A_(0,4) );
4432 const ET tmp159( tmp38*b_[4] - tmp128*A_(4,4) + tmp131*A_(3,4) - tmp134*A_(1,4) + tmp135*A_(0,4) );
4433 const ET tmp160( tmp39*b_[4] - tmp129*A_(4,4) + tmp132*A_(3,4) - tmp134*A_(2,4) + tmp136*A_(0,4) );
4434 const ET tmp161( tmp40*b_[4] - tmp130*A_(4,4) + tmp133*A_(3,4) - tmp135*A_(2,4) + tmp136*A_(1,4) );
4436 x_[0] = ( tmp137*A_(5,5) - tmp138*A_(4,5) + tmp139*A_(3,5) - tmp140*A_(2,5) + tmp141*A_(1,5) - tmp56*b_[5] ) * invD;
4437 x_[1] = ( tmp142*A_(5,5) - tmp143*A_(4,5) + tmp144*A_(3,5) - tmp145*A_(2,5) + tmp55*b_[5] - tmp141*A_(0,5) ) * invD;
4438 x_[2] = ( tmp147*A_(5,5) - tmp148*A_(4,5) + tmp149*A_(3,5) - tmp54*b_[5] + tmp145*A_(1,5) - tmp146*A_(0,5) ) * invD;
4439 x_[3] = ( tmp152*A_(5,5) - tmp153*A_(4,5) + tmp53*b_[5] - tmp149*A_(2,5) + tmp150*A_(1,5) - tmp151*A_(0,5) ) * invD;
4440 x_[4] = ( tmp157*A_(5,5) - tmp52*b_[5] + tmp153*A_(3,5) - tmp154*A_(2,5) + tmp155*A_(1,5) - tmp156*A_(0,5) ) * invD;
4441 x_[5] = ( tmp51*b_[5] - tmp157*A_(4,5) + tmp158*A_(3,5) - tmp159*A_(2,5) + tmp160*A_(1,5) - tmp161*A_(0,5) ) * invD;
4469template<
typename MT
4475 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
4476void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4492 CompositeType_t<MT> A_( *A );
4494 const VT2& b_( *b );
4496 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
4502 x_[0] = ( b_[0] ) / A_(0,0);
4503 x_[1] = ( b_[1] - A_(1,0)*x_[0] ) / A_(1,1);
4504 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] ) / A_(2,2);
4505 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] ) / A_(3,3);
4506 x_[4] = ( b_[4] - A_(4,0)*x_[0] - A_(4,1)*x_[1] - A_(4,2)*x_[2] - A_(4,3)*x_[3] ) / A_(4,4);
4507 x_[5] = ( b_[5] - A_(5,0)*x_[0] - A_(5,1)*x_[1] - A_(5,2)*x_[2] - A_(5,3)*x_[3] - A_(5,4)*x_[4] ) / A_(5,5);
4535template<
typename MT
4541 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
4542void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4558 CompositeType_t<MT> A_( *A );
4560 const VT2& b_( *b );
4565 x_[1] = ( b_[1] - A_(1,0)*x_[0] );
4566 x_[2] = ( b_[2] - A_(2,0)*x_[0] - A_(2,1)*x_[1] );
4567 x_[3] = ( b_[3] - A_(3,0)*x_[0] - A_(3,1)*x_[1] - A_(3,2)*x_[2] );
4568 x_[4] = ( b_[4] - A_(4,0)*x_[0] - A_(4,1)*x_[1] - A_(4,2)*x_[2] - A_(4,3)*x_[3] );
4569 x_[5] = ( b_[5] - A_(5,0)*x_[0] - A_(5,1)*x_[1] - A_(5,2)*x_[2] - A_(5,3)*x_[3] - A_(5,4)*x_[4] );
4597template<
typename MT
4603 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
4604void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4620 CompositeType_t<MT> A_( *A );
4622 const VT2& b_( *b );
4624 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
4630 x_[5] = ( b_[5] ) / A_(5,5);
4631 x_[4] = ( b_[4] - A_(4,5)*x_[5] ) / A_(4,4);
4632 x_[3] = ( b_[3] - A_(3,4)*x_[4] - A_(3,5)*x_[5] ) / A_(3,3);
4633 x_[2] = ( b_[2] - A_(2,3)*x_[3] - A_(2,4)*x_[4] - A_(2,5)*x_[5] ) / A_(2,2);
4634 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] - A_(1,4)*x_[4] - A_(1,5)*x_[5] ) / A_(1,1);
4635 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] - A_(0,4)*x_[4] - A_(0,5)*x_[5] ) / A_(0,0);
4663template<
typename MT
4669 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
4670void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4686 CompositeType_t<MT> A_( *A );
4688 const VT2& b_( *b );
4693 x_[4] = ( b_[4] - A_(4,5)*x_[5] );
4694 x_[3] = ( b_[3] - A_(3,4)*x_[4] - A_(3,5)*x_[5] );
4695 x_[2] = ( b_[2] - A_(2,3)*x_[3] - A_(2,4)*x_[4] - A_(2,5)*x_[5] );
4696 x_[1] = ( b_[1] - A_(1,2)*x_[2] - A_(1,3)*x_[3] - A_(1,4)*x_[4] - A_(1,5)*x_[5] );
4697 x_[0] = ( b_[0] - A_(0,1)*x_[1] - A_(0,2)*x_[2] - A_(0,3)*x_[3] - A_(0,4)*x_[4] - A_(0,5)*x_[5] );
4724template<
typename MT
4730 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
4731void solve6x6(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
4747 CompositeType_t<MT> A_( *A );
4749 const VT2& b_( *b );
4751 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
4757 x_[0] = b_[0] / A_(0,0);
4758 x_[1] = b_[1] / A_(1,1);
4759 x_[2] = b_[2] / A_(2,2);
4760 x_[3] = b_[3] / A_(3,3);
4761 x_[4] = b_[4] / A_(4,4);
4762 x_[5] = b_[5] / A_(5,5);
4789template<
typename MT1
4795 ,
EnableIf_t< ( IsGeneral_v<MT1> || IsSymmetric_v<MT1> || IsHermitian_v<MT1> ) && !IsDiagonal_v<MT1> >* =
nullptr >
4796void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
4812 resize( *X, (*B).rows(), (*B).columns() );
4813 const ResultType_t<MT1> invA(
inv( *A ) );
4842template<
typename MT1
4848 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
4849void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
4865 using ET = ElementType_t<MT1>;
4867 CompositeType_t<MT1> A_( *A );
4869 const MT3& B_( *B );
4871 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
4875 const size_t M( B_.rows() );
4876 const size_t N( B_.columns() );
4880 const ET invD0(
inv( A_(0,0) ) );
4881 const ET invD1(
inv( A_(1,1) ) );
4882 const ET invD2(
inv( A_(2,2) ) );
4883 const ET invD3(
inv( A_(3,3) ) );
4884 const ET invD4(
inv( A_(4,4) ) );
4885 const ET invD5(
inv( A_(5,5) ) );
4887 for(
size_t j=0UL; j<N; ++j ) {
4888 X_(0,j) = ( B_(0,j) ) * invD0;
4889 X_(1,j) = ( B_(1,j) - A_(1,0)*X_(0,j) ) * invD1;
4890 X_(2,j) = ( B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j) ) * invD2;
4891 X_(3,j) = ( B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j) ) * invD3;
4892 X_(4,j) = ( B_(4,j) - A_(4,0)*X_(0,j) - A_(4,1)*X_(1,j) - A_(4,2)*X_(2,j) - A_(4,3)*X_(3,j) ) * invD4;
4893 X_(5,j) = ( B_(5,j) - A_(5,0)*X_(0,j) - A_(5,1)*X_(1,j) - A_(5,2)*X_(2,j) - A_(5,3)*X_(3,j) - A_(5,4)*X_(4,j) ) * invD5;
4922template<
typename MT1
4928 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
4929void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
4945 CompositeType_t<MT1> A_( *A );
4947 const MT3& B_( *B );
4949 const size_t M( B_.rows() );
4950 const size_t N( B_.columns() );
4954 for(
size_t j=0UL; j<N; ++j ) {
4956 X_(1,j) = B_(1,j) - A_(1,0)*X_(0,j);
4957 X_(2,j) = B_(2,j) - A_(2,0)*X_(0,j) - A_(2,1)*X_(1,j);
4958 X_(3,j) = B_(3,j) - A_(3,0)*X_(0,j) - A_(3,1)*X_(1,j) - A_(3,2)*X_(2,j);
4959 X_(4,j) = B_(4,j) - A_(4,0)*X_(0,j) - A_(4,1)*X_(1,j) - A_(4,2)*X_(2,j) - A_(4,3)*X_(3,j);
4960 X_(5,j) = B_(5,j) - A_(5,0)*X_(0,j) - A_(5,1)*X_(1,j) - A_(5,2)*X_(2,j) - A_(5,3)*X_(3,j) - A_(5,4)*X_(4,j);
4989template<
typename MT1
4995 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
4996void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5012 using ET = ElementType_t<MT1>;
5014 CompositeType_t<MT1> A_( *A );
5016 const MT3& B_( *B );
5018 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
5022 const size_t M( B_.rows() );
5023 const size_t N( B_.columns() );
5027 const ET invD0(
inv( A_(0,0) ) );
5028 const ET invD1(
inv( A_(1,1) ) );
5029 const ET invD2(
inv( A_(2,2) ) );
5030 const ET invD3(
inv( A_(3,3) ) );
5031 const ET invD4(
inv( A_(4,4) ) );
5032 const ET invD5(
inv( A_(5,5) ) );
5034 for(
size_t j=0UL; j<N; ++j ) {
5035 X_(5,j) = ( B_(5,j) ) * invD5;
5036 X_(4,j) = ( B_(4,j) - A_(4,5)*X_(5,j) ) * invD4;
5037 X_(3,j) = ( B_(3,j) - A_(3,4)*X_(4,j) - A_(3,5)*X_(5,j) ) * invD3;
5038 X_(2,j) = ( B_(2,j) - A_(2,3)*X_(3,j) - A_(2,4)*X_(4,j) - A_(2,5)*X_(5,j) ) * invD2;
5039 X_(1,j) = ( B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j) - A_(1,4)*X_(4,j) - A_(1,5)*X_(5,j) ) * invD1;
5040 X_(0,j) = ( B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j) - A_(0,4)*X_(4,j) - A_(0,5)*X_(5,j) ) * invD0;
5069template<
typename MT1
5075 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
5076void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5092 CompositeType_t<MT1> A_( *A );
5094 const MT3& B_( *B );
5096 const size_t M( B_.rows() );
5097 const size_t N( B_.columns() );
5101 for(
size_t j=0UL; j<N; ++j ) {
5103 X_(4,j) = B_(4,j) - A_(4,5)*X_(5,j);
5104 X_(3,j) = B_(3,j) - A_(3,4)*X_(4,j) - A_(3,5)*X_(5,j);
5105 X_(2,j) = B_(2,j) - A_(2,3)*X_(3,j) - A_(2,4)*X_(4,j) - A_(2,5)*X_(5,j);
5106 X_(1,j) = B_(1,j) - A_(1,2)*X_(2,j) - A_(1,3)*X_(3,j) - A_(1,4)*X_(4,j) - A_(1,5)*X_(5,j);
5107 X_(0,j) = B_(0,j) - A_(0,1)*X_(1,j) - A_(0,2)*X_(2,j) - A_(0,3)*X_(3,j) - A_(0,4)*X_(4,j) - A_(0,5)*X_(5,j);
5135template<
typename MT1
5141 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
5142void solve6x6(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5158 using ET = ElementType_t<MT1>;
5160 CompositeType_t<MT1> A_( *A );
5162 const MT3& B_( *B );
5164 if( !
isDivisor( A_(0,0)*A_(1,1)*A_(2,2)*A_(3,3)*A_(4,4)*A_(5,5) ) ) {
5168 const size_t M( B_.rows() );
5169 const size_t N( B_.columns() );
5173 const ET invD0(
inv( A_(0,0) ) );
5174 const ET invD1(
inv( A_(1,1) ) );
5175 const ET invD2(
inv( A_(2,2) ) );
5176 const ET invD3(
inv( A_(3,3) ) );
5177 const ET invD4(
inv( A_(4,4) ) );
5178 const ET invD5(
inv( A_(5,5) ) );
5180 for(
size_t j=0UL; j<N; ++j ) {
5181 X_(0,j) = B_(0,j) * invD0;
5182 X_(1,j) = B_(1,j) * invD1;
5183 X_(2,j) = B_(2,j) * invD2;
5184 X_(3,j) = B_(3,j) * invD3;
5185 X_(4,j) = B_(4,j) * invD4;
5186 X_(5,j) = B_(5,j) * invD5;
5222template<
typename MT
5228 , EnableIf_t< IsGeneral_v<MT> >* =
nullptr >
5229void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5244 using RT = ResultType_t<MT>;
5245 using OT = OppositeType_t<MT>;
5247 const size_t N( (*b).size() );
5249 RemoveAdaptor_t< If_t<SO,RT,OT> > Atmp( A );
5254 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5256 gesv( Atmp, *x, ipiv.get() );
5283template<
typename MT
5289 , EnableIf_t< IsSymmetric_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
5290void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5305 using RT = ResultType_t<MT>;
5306 using OT = OppositeType_t<MT>;
5308 const size_t N( (*b).size() );
5310 RemoveAdaptor_t< If_t<SO,RT,OT> > Atmp( A );
5315 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5317 sysv( Atmp, *x,
'L', ipiv.get() );
5344template<
typename MT
5350 , EnableIf_t< IsHermitian_v<MT> && !IsSymmetric_v<MT> >* =
nullptr >
5351void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5366 using RT = ResultType_t<MT>;
5367 using OT = OppositeType_t<MT>;
5369 const size_t N( (*b).size() );
5371 RemoveAdaptor_t< If_t<SO,RT,OT> > Atmp( A );
5376 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5378 hesv( Atmp, *x,
'L', ipiv.get() );
5406template<
typename MT
5412 , EnableIf_t< IsLower_v<MT> && !IsUniLower_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
5413void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5428 CompositeType_t<MT> A_( *A );
5430 const VT2& b_( *b );
5436 const size_t N( (*b).size() );
5440 for(
size_t i=0UL; i<N; ++i ) {
5442 for(
size_t j=0UL; j<i; ++j )
5443 x_[i] -= A_(i,j)*x_[j];
5444 x_[i] *=
inv( A_(i,i) );
5473template<
typename MT
5479 , EnableIf_t< IsUniLower_v<MT> >* =
nullptr >
5480void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5495 CompositeType_t<MT> A_( *A );
5497 const VT2& b_( *b );
5499 const size_t N( (*b).size() );
5503 for(
size_t i=0UL; i<N; ++i ) {
5505 for(
size_t j=0UL; j<i; ++j )
5506 x_[i] -= A_(i,j)*x_[j];
5535template<
typename MT
5541 , EnableIf_t< IsUpper_v<MT> && !IsUniUpper_v<MT> && !IsDiagonal_v<MT> >* =
nullptr >
5542void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5557 CompositeType_t<MT> A_( *A );
5559 const VT2& b_( *b );
5565 const size_t N( (*b).size() );
5569 for(
size_t i=N-1UL; i<N; --i ) {
5571 for(
size_t j=i+1UL; j<N; ++j )
5572 x_[i] -= A_(i,j)*x_[j];
5573 x_[i] *=
inv( A_(i,i) );
5602template<
typename MT
5608 , EnableIf_t< IsUniUpper_v<MT> >* =
nullptr >
5609void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5624 CompositeType_t<MT> A_( *A );
5626 const VT2& b_( *b );
5628 const size_t N( (*b).size() );
5632 for(
size_t i=N-1UL; i<N; --i ) {
5634 for(
size_t j=i+1UL; j<N; ++j )
5635 x_[i] -= A_(i,j)*x_[j];
5663template<
typename MT
5669 , EnableIf_t< IsDiagonal_v<MT> >* =
nullptr >
5670void solveNxN(
const DenseMatrix<MT,SO>& A, DenseVector<VT1,TF1>& x,
const DenseVector<VT2,TF2>& b )
5685 const size_t N( (*b).size() );
5687 CompositeType_t<MT> A_( *A );
5689 const VT2& b_( *b );
5697 for(
size_t i=0UL; i<N; ++i ) {
5698 x_[i] = b_[i] / A_(i,i);
5726template<
typename MT1
5732 , EnableIf_t< IsGeneral_v<MT1> >* =
nullptr >
5733void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5747 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
5748 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
5750 using MT4 = RemoveAdaptor_t< If_t< SO1, ResultType_t<MT1>, OppositeType_t<MT1> > >;
5751 using MT5 = RemoveAdaptor_t< If_t< SO3, ResultType_t<MT3>, OppositeType_t<MT3> > >;
5756 const size_t N( (*A).rows() );
5761 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5763 gesv( Atmp, Xtmp, ipiv.get() );
5765 resize( *X, Xtmp.rows(), Xtmp.columns() );
5793template<
typename MT1
5799 , EnableIf_t< IsSymmetric_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
5800void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5814 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
5815 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
5817 using MT4 = RemoveAdaptor_t< If_t< SO1, ResultType_t<MT1>, OppositeType_t<MT1> > >;
5818 using MT5 = RemoveAdaptor_t< If_t< SO3, ResultType_t<MT3>, OppositeType_t<MT3> > >;
5823 const size_t N( (*A).rows() );
5828 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5830 sysv( Atmp, Xtmp,
'L', ipiv.get() );
5832 resize( *X, Xtmp.rows(), Xtmp.columns() );
5860template<
typename MT1
5866 , EnableIf_t< IsHermitian_v<MT1> && !IsSymmetric_v<MT1> >* =
nullptr >
5867void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5881 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
5882 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
5884 using MT4 = RemoveAdaptor_t< If_t< SO1, ResultType_t<MT1>, OppositeType_t<MT1> > >;
5885 using MT5 = RemoveAdaptor_t< If_t< SO3, ResultType_t<MT3>, OppositeType_t<MT3> > >;
5890 const size_t N( (*A).rows() );
5895 const std::unique_ptr<blas_int_t[]> ipiv(
new blas_int_t[N] );
5897 hesv( Atmp, Xtmp,
'L', ipiv.get() );
5899 resize( *X, Xtmp.rows(), Xtmp.columns() );
5928template<
typename MT1
5934 , EnableIf_t< IsLower_v<MT1> && !IsUniLower_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
5935void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
5949 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
5950 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
5952 using ET = ElementType_t<MT1>;
5954 CompositeType_t<MT1> A_( *A );
5956 const MT3& B_( *B );
5962 const size_t M( B_.rows() );
5963 const size_t N( B_.columns() );
5967 for(
size_t i=0UL; i<M; ++i ) {
5968 const ET invD(
inv( A_(i,i) ) );
5969 for(
size_t j=0UL; j<N; ++j ) {
5971 for(
size_t k=0UL; k<i; ++k )
5972 X_(i,j) -= A_(i,k)*X_(k,j);
6003template<
typename MT1
6009 , EnableIf_t< IsUniLower_v<MT1> >* =
nullptr >
6010void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
6024 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
6025 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
6027 CompositeType_t<MT1> A_( *A );
6029 const MT3& B_( *B );
6031 const size_t M( B_.rows() );
6032 const size_t N( B_.columns() );
6036 for(
size_t i=0UL; i<M; ++i ) {
6037 for(
size_t j=0UL; j<N; ++j ) {
6039 for(
size_t k=0UL; k<i; ++k )
6040 X_(i,j) -= A_(i,k)*X_(k,j);
6070template<
typename MT1
6076 , EnableIf_t< IsUpper_v<MT1> && !IsUniUpper_v<MT1> && !IsDiagonal_v<MT1> >* =
nullptr >
6077void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
6091 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
6092 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
6094 using ET = ElementType_t<MT1>;
6096 CompositeType_t<MT1> A_( *A );
6098 const MT3& B_( *B );
6104 const size_t M( B_.rows() );
6105 const size_t N( B_.columns() );
6109 for(
size_t i=M-1UL; i<M; --i ) {
6110 const ET invD(
inv( A_(i,i) ) );
6111 for(
size_t j=0; j<N; ++j ) {
6113 for(
size_t k=i+1UL; k<M; ++k )
6114 X_(i,j) -= A_(i,k)*X_(k,j);
6145template<
typename MT1
6151 , EnableIf_t< IsUniUpper_v<MT1> >* =
nullptr >
6152void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
6166 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
6167 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
6169 CompositeType_t<MT1> A_( *A );
6171 const MT3& B_( *B );
6173 const size_t M( B_.rows() );
6174 const size_t N( B_.columns() );
6178 for(
size_t i=M-1UL; i<M; --i ) {
6179 for(
size_t j=0; j<N; ++j ) {
6181 for(
size_t k=i+1UL; k<M; ++k )
6182 X_(i,j) -= A_(i,k)*X_(k,j);
6211template<
typename MT1
6217 , EnableIf_t< IsDiagonal_v<MT1> >* =
nullptr >
6218void solveNxN(
const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& X,
const DenseMatrix<MT3,SO3>& B )
6232 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).rows() == (*X).rows(),
"Invalid number of rows detected" );
6233 BLAZE_INTERNAL_ASSERT( IsResizable_v<MT2> || (*B).columns() == (*X).columns(),
"Invalid number of columns detected" );
6235 using ET = ElementType_t<MT1>;
6237 CompositeType_t<MT1> A_( *A );
6239 const MT3& B_( *B );
6245 const size_t M( B_.rows() );
6246 const size_t N( B_.columns() );
6250 for(
size_t i=0UL; i<M; ++i ) {
6251 const ET invD(
inv( A_(i,i) ) );
6252 for(
size_t j=0UL; j<N; ++j ) {
6253 X_(i,j) = B_(i,j) * invD;
6337template<
typename MT
6358 else if( (*A).rows() != (*b).size() ) {
6362 switch( (*A).rows() ) {
6364 case 1UL: solve1x1( *A, *x, *b );
break;
6365 case 2UL: solve2x2( *A, *x, *b );
break;
6366 case 3UL: solve3x3( *A, *x, *b );
break;
6367 case 4UL: solve4x4( *A, *x, *b );
break;
6368 case 5UL: solve5x5( *A, *x, *b );
break;
6369 case 6UL: solve6x6( *A, *x, *b );
break;
6370 default : solveNxN( *A, *x, *b );
break;
6446template<
typename MT1
6467 else if( (*A).rows() != (*B).rows() ) {
6471 switch( (*A).rows() ) {
6472 case 0UL: solve0x0( *A, *X, *B );
break;
6473 case 1UL: solve1x1( *A, *X, *B );
break;
6474 case 2UL: solve2x2( *A, *X, *B );
break;
6475 case 3UL: solve3x3( *A, *X, *B );
break;
6476 case 4UL: solve4x4( *A, *X, *B );
break;
6477 case 5UL: solve5x5( *A, *X, *B );
break;
6478 case 6UL: solve6x6( *A, *X, *B );
break;
6479 default : solveNxN( *A, *X, *B );
break;
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Header file for run time assertion macros.
Constraint on the data type.
Constraints on the storage order of matrix types.
Header file for the EnableIf class template.
Header file for the If class template.
Header file for the invert shim.
Header file for the IsDiagonal type trait.
Header file for the isDivisor shim.
Header file for the IsGeneral type trait.
Header file for the IsHermitian type trait.
Header file for the IsLower type trait.
Header file for the IsResizable type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Header file for the DenseMatrix base class.
Header file for the DenseVector base class.
Header file for the LAPACK general linear system solver functions (gesv)
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.
Definition: SameType.h:71
void solve(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO2 > &X, const DenseMatrix< MT3, SO3 > &B)
Solving the given linear system of equations ( ).
Definition: LSE.h:6452
ElementType_t< MT > det(const DenseMatrix< MT, SO > &dm)
Computation of the determinant of the given dense square matrix.
Definition: DMatDetExpr.h:384
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:405
bool isDivisor(const DenseVector< VT, TF > &dv)
Returns whether the given dense vector is a valid divisor.
Definition: DenseVector.h:1261
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
void gesv(blas_int_t n, blas_int_t nrhs, float *A, blas_int_t lda, blas_int_t *ipiv, float *B, blas_int_t ldb, blas_int_t *info)
LAPACK kernel for solving a general single precision linear system of equations ( ).
Definition: gesv.h:145
void hesv(char uplo, blas_int_t n, blas_int_t nrhs, complex< float > *A, blas_int_t lda, blas_int_t *ipiv, complex< float > *B, blas_int_t ldb, complex< float > *work, blas_int_t lwork, blas_int_t *info)
LAPACK kernel for solving a Hermitian indefinite single precision complex linear system of equations ...
Definition: hesv.h:148
void sysv(char uplo, blas_int_t n, blas_int_t nrhs, float *A, blas_int_t lda, blas_int_t *ipiv, float *B, blas_int_t ldb, float *work, blas_int_t lwork, blas_int_t *info)
LAPACK kernel for solving a symmetric indefinite single precision linear system of equations ( ).
Definition: sysv.h:164
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_STRICTLY_TRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: StrictlyTriangular.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNIFORM_TYPE(T)
Constraint on the data type.
Definition: Uniform.h:81
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
#define BLAZE_THROW_DIVISION_BY_ZERO(MESSAGE)
Macro for the emission of an exception on detection of a division by zero.
Definition: Exception.h:97
int32_t blas_int_t
Signed integer type used in the BLAS/LAPACK wrapper functions.
Definition: Types.h:64
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the LAPACK Hermitian indefinite linear system solver functions (hesv)
Header file for the exception macros of the math module.
Header file for the LAPACK symmetric indefinite linear system solver functions (sysv)
Header file for basic type definitions.