LowerMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
54 #include <blaze/math/Forward.h>
55 #include <blaze/math/Functions.h>
79 #include <blaze/util/Assert.h>
80 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/Exception.h>
83 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // LOWERMATRIX OPERATORS
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
98 template< typename MT, bool SO, bool DF >
99 inline void reset( LowerMatrix<MT,SO,DF>& m );
100 
101 template< typename MT, bool SO, bool DF >
102 inline void reset( LowerMatrix<MT,SO,DF>& m, size_t i );
103 
104 template< typename MT, bool SO, bool DF >
105 inline void clear( LowerMatrix<MT,SO,DF>& m );
106 
107 template< typename MT, bool SO, bool DF >
108 inline bool isDefault( const LowerMatrix<MT,SO,DF>& m );
109 
110 template< typename MT, bool SO, bool DF >
111 inline bool isIntact( const LowerMatrix<MT,SO,DF>& m );
112 
113 template< typename MT, bool SO, bool DF >
114 inline void swap( LowerMatrix<MT,SO,DF>& a, LowerMatrix<MT,SO,DF>& b ) /* throw() */;
116 //*************************************************************************************************
117 
118 
119 //*************************************************************************************************
126 template< typename MT // Type of the adapted matrix
127  , bool SO // Storage order of the adapted matrix
128  , bool DF > // Density flag
129 inline void reset( LowerMatrix<MT,SO,DF>& m )
130 {
131  m.reset();
132 }
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
149 template< typename MT // Type of the adapted matrix
150  , bool SO // Storage order of the adapted matrix
151  , bool DF > // Density flag
152 inline void reset( LowerMatrix<MT,SO,DF>& m, size_t i )
153 {
154  m.reset( i );
155 }
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
166 template< typename MT // Type of the adapted matrix
167  , bool SO // Storage order of the adapted matrix
168  , bool DF > // Density flag
169 inline void clear( LowerMatrix<MT,SO,DF>& m )
170 {
171  m.clear();
172 }
173 //*************************************************************************************************
174 
175 
176 //*************************************************************************************************
197 template< typename MT // Type of the adapted matrix
198  , bool SO // Storage order of the adapted matrix
199  , bool DF > // Density flag
200 inline bool isDefault( const LowerMatrix<MT,SO,DF>& m )
201 {
202  return isDefault( m.matrix_ );
203 }
204 //*************************************************************************************************
205 
206 
207 //*************************************************************************************************
228 template< typename MT // Type of the adapted matrix
229  , bool SO // Storage order of the adapted matrix
230  , bool DF > // Density flag
231 inline bool isIntact( const LowerMatrix<MT,SO,DF>& m )
232 {
233  return m.isIntact();
234 }
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
247 template< typename MT // Type of the adapted matrix
248  , bool SO // Storage order of the adapted matrix
249  , bool DF > // Density flag
250 inline void swap( LowerMatrix<MT,SO,DF>& a, LowerMatrix<MT,SO,DF>& b ) /* throw() */
251 {
252  a.swap( b );
253 }
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
273 template< typename MT // Type of the dense matrix
274  , bool SO > // Storage order of the dense matrix
275 inline void invert2x2( LowerMatrix<MT,SO,true>& m )
276 {
278 
279  BLAZE_INTERNAL_ASSERT( m.rows() == 2UL, "Invalid number of rows detected" );
280  BLAZE_INTERNAL_ASSERT( m.columns() == 2UL, "Invalid number of columns detected" );
281 
282  typedef typename MT::ElementType ET;
283 
284  typename DerestrictTrait<MT>::Type A( derestrict( m ) );
285 
286  const ET det( A(0,0) * A(1,1) );
287 
288  if( isDefault( det ) ) {
289  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
290  }
291 
292  const ET idet( ET(1) / det );
293  const ET a11( A(0,0) * idet );
294 
295  A(0,0) = A(1,1) * idet;
296  A(1,0) = -A(1,0) * idet;
297  A(1,1) = a11;
298 
299  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
300 }
302 //*************************************************************************************************
303 
304 
305 //*************************************************************************************************
321 template< typename MT // Type of the dense matrix
322  , bool SO > // Storage order of the dense matrix
323 inline void invert3x3( LowerMatrix<MT,SO,true>& m )
324 {
326 
327  BLAZE_INTERNAL_ASSERT( m.rows() == 3UL, "Invalid number of rows detected" );
328  BLAZE_INTERNAL_ASSERT( m.columns() == 3UL, "Invalid number of columns detected" );
329 
330  typedef typename MT::ElementType ET;
331 
332  const StaticMatrix<ET,3UL,3UL,SO> A( m );
333  typename DerestrictTrait<MT>::Type B( derestrict( m ) );
334 
335  const ET tmp( A(1,1)*A(2,2) );
336  const ET det( A(0,0)*tmp );
337 
338  if( isDefault( det ) ) {
339  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
340  }
341 
342  B(0,0) = tmp;
343  B(1,0) = - A(1,0)*A(2,2);
344  B(2,0) = A(1,0)*A(2,1) - A(1,1)*A(2,0);
345  B(1,1) = A(0,0)*A(2,2);
346  B(2,1) = - A(0,0)*A(2,1);
347  B(2,2) = A(0,0)*A(1,1);
348 
349  B /= det;
350 
351  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
352 }
354 //*************************************************************************************************
355 
356 
357 //*************************************************************************************************
373 template< typename MT // Type of the dense matrix
374  , bool SO > // Storage order of the dense matrix
375 inline void invert4x4( LowerMatrix<MT,SO,true>& m )
376 {
378 
379  BLAZE_INTERNAL_ASSERT( m.rows() == 4UL, "Invalid number of rows detected" );
380  BLAZE_INTERNAL_ASSERT( m.columns() == 4UL, "Invalid number of columns detected" );
381 
382  typedef typename MT::ElementType ET;
383 
384  const StaticMatrix<ET,4UL,4UL,SO> A( m );
385  typename DerestrictTrait<MT>::Type B( derestrict( m ) );
386 
387  const ET tmp1( A(2,2)*A(3,3) );
388  const ET tmp2( A(2,1)*A(3,3) );
389  const ET tmp3( A(2,1)*A(3,2) - A(2,2)*A(3,1) );
390  const ET tmp4( A(0,0)*A(1,1) );
391 
392  const ET det( tmp4 * A(2,2) * A(3,3) );
393 
394  if( isDefault( det ) ) {
395  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
396  }
397 
398  B(0,0) = A(1,1)*tmp1;
399  B(1,0) = - A(1,0)*tmp1;
400  B(2,0) = A(1,0)*tmp2 - A(1,1)*A(2,0)*A(3,3);
401  B(3,0) = A(1,1)*( A(2,0)*A(3,2) - A(2,2)*A(3,0) ) - A(1,0)*tmp3;
402  B(1,1) = A(0,0)*tmp1;
403  B(2,1) = - A(0,0)*tmp2;
404  B(3,1) = A(0,0)*tmp3;
405  B(2,2) = A(3,3)*tmp4;
406  B(3,2) = - A(3,2)*tmp4;
407  B(3,3) = A(2,2)*tmp4;
408 
409  B /= det;
410 
411  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
412 }
414 //*************************************************************************************************
415 
416 
417 //*************************************************************************************************
433 template< typename MT // Type of the dense matrix
434  , bool SO > // Storage order of the dense matrix
435 inline void invert5x5( LowerMatrix<MT,SO,true>& m )
436 {
438 
439  BLAZE_INTERNAL_ASSERT( m.rows() == 5UL, "Invalid number of rows detected" );
440  BLAZE_INTERNAL_ASSERT( m.columns() == 5UL, "Invalid number of columns detected" );
441 
442  typedef typename MT::ElementType ET;
443 
444  const StaticMatrix<ET,5UL,5UL,SO> A( m );
445  typename DerestrictTrait<MT>::Type B( derestrict( m ) );
446 
447  const ET tmp1( A(3,3)*A(4,4) );
448  const ET tmp2( A(3,2)*A(4,4) );
449  const ET tmp3( A(3,2)*A(4,3) - A(3,3)*A(4,2) );
450  const ET tmp4( A(0,0)*A(1,1) );
451 
452  const ET tmp5 ( A(2,2)*tmp1 );
453  const ET tmp6 ( A(2,1)*tmp1 );
454  const ET tmp7 ( A(2,1)*tmp2 - A(2,2)*A(3,1)*A(4,4) );
455  const ET tmp8 ( A(2,1)*tmp3 - A(2,2)*( A(3,1)*A(4,3) - A(3,3)*A(4,1) ) );
456  const ET tmp9 ( A(3,2)*tmp4 );
457  const ET tmp10( A(2,2)*tmp4 );
458 
459  B(0,0) = A(1,1)*tmp5;
460  B(1,0) = - A(1,0)*tmp5;
461  B(2,0) = A(1,0)*tmp6 - A(1,1)*A(2,0)*tmp1;
462  B(3,0) = A(1,1)*( A(2,0)*tmp2 - A(2,2)*A(3,0)*A(4,4) ) - A(1,0)*tmp7;
463  B(4,0) = A(1,0)*tmp8 - A(1,1)*( A(2,0)*tmp3 - A(2,2)*( A(3,0)*A(4,3) - A(3,3)*A(4,0) ) );
464  B(1,1) = A(0,0)*tmp5;
465  B(2,1) = - A(0,0)*tmp6;
466  B(3,1) = A(0,0)*tmp7;
467  B(4,1) = - A(0,0)*tmp8;
468  B(2,2) = A(0,0)*A(1,1)*tmp1;
469  B(3,2) = - A(4,4)*tmp9;
470  B(4,2) = A(4,3)*tmp9 - A(4,2)*A(3,3)*tmp4;
471  B(3,3) = A(4,4)*tmp10;
472  B(4,3) = - A(4,3)*tmp10;
473  B(4,4) = A(3,3)*tmp10;
474 
475  const ET det( B(4,4) * A(4,4) );
476 
477  if( isDefault( det ) ) {
478  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
479  }
480 
481  B /= det;
482 
483  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
484 }
486 //*************************************************************************************************
487 
488 
489 //*************************************************************************************************
505 template< typename MT // Type of the dense matrix
506  , bool SO > // Storage order of the dense matrix
507 inline void invert6x6( LowerMatrix<MT,SO,true>& m )
508 {
510 
511  BLAZE_INTERNAL_ASSERT( m.rows() == 6UL, "Invalid number of rows detected" );
512  BLAZE_INTERNAL_ASSERT( m.columns() == 6UL, "Invalid number of columns detected" );
513 
514  typedef typename MT::ElementType ET;
515 
516  const StaticMatrix<ET,6UL,6UL,SO> A( m );
517  typename DerestrictTrait<MT>::Type B( derestrict( m ) );
518 
519  const ET tmp1( A(4,4)*A(5,5) );
520  const ET tmp2( A(4,3)*A(5,5) );
521  const ET tmp3( A(4,3)*A(5,4) - A(4,4)*A(5,3) );
522 
523  const ET tmp4( A(3,3)*tmp1 );
524  const ET tmp5( A(3,2)*tmp1 );
525  const ET tmp6( A(3,2)*tmp2 - A(3,3)*A(4,2)*A(5,5) );
526  const ET tmp7( A(3,2)*tmp3 - A(3,3)*( A(4,2)*A(5,4) - A(4,4)*A(5,2) ) );
527  const ET tmp8( A(0,0)*A(1,1)*A(2,2) );
528 
529  const ET tmp9 ( A(2,2)*tmp4 );
530  const ET tmp10( A(2,1)*tmp4 );
531  const ET tmp11( A(2,1)*tmp5 - A(2,2)*A(3,1)*tmp1 );
532  const ET tmp12( A(2,1)*tmp6 - A(2,2)*( A(3,1)*tmp2 - A(3,3)*A(4,1)*A(5,5) ) );
533  const ET tmp13( A(2,1)*tmp7 - A(2,2)*( A(3,1)*tmp3 - A(3,3)*( A(4,1)*A(5,4) - A(4,4)*A(5,1) ) ) );
534  const ET tmp14( A(4,4)*tmp8 );
535  const ET tmp15( A(4,3)*tmp8 );
536  const ET tmp16( A(3,3)*tmp8 );
537 
538  B(0,0) = A(1,1)*tmp9;
539  B(1,0) = - A(1,0)*tmp9;
540  B(2,0) = A(1,0)*tmp10 - A(1,1)*A(2,0)*tmp4;
541  B(3,0) = - A(1,0)*tmp11 + A(1,1)*( A(2,0)*tmp5 - A(2,2)*A(3,0)*tmp1 );
542  B(4,0) = A(1,0)*tmp12 - A(1,1)*( A(2,0)*tmp6 - A(2,2)*( A(3,0)*tmp2 - A(3,3)*A(4,0)*A(5,5) ) );
543  B(5,0) = - A(1,0)*tmp13 + A(1,1)*( A(2,0)*tmp7 - A(2,2)*( A(3,0)*tmp3 - A(3,3)*( A(4,0)*A(5,4) - A(4,4)*A(5,0) ) ) );
544  B(1,1) = A(0,0)*tmp9;
545  B(2,1) = - A(0,0)*tmp10;
546  B(3,1) = A(0,0)*tmp11;
547  B(4,1) = - A(0,0)*tmp12;
548  B(5,1) = A(0,0)*tmp13;
549  B(2,2) = A(0,0)*A(1,1)*tmp4;
550  B(3,2) = - A(0,0)*A(1,1)*tmp5;
551  B(4,2) = A(0,0)*A(1,1)*tmp6;
552  B(5,2) = - A(0,0)*A(1,1)*tmp7;
553  B(3,3) = A(5,5)*tmp14;
554  B(4,3) = - A(5,5)*tmp15;
555  B(5,3) = A(5,4)*tmp15 - A(5,3)*tmp14;
556  B(4,4) = A(5,5)*tmp16 - A(5,3)*A(3,5)*tmp8;
557  B(5,4) = - A(5,4)*tmp16;
558  B(5,5) = A(4,4)*tmp16;
559 
560  const ET det( B(5,5)*A(5,5) );
561 
562  if( isDefault( det ) ) {
563  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
564  }
565 
566  B /= det;
567 
568  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
569 }
571 //*************************************************************************************************
572 
573 
574 //*************************************************************************************************
597 template< typename MT // Type of the dense matrix
598  , bool SO > // Storage order of the dense matrix
599 inline void invertByDefault( LowerMatrix<MT,SO,true>& m )
600 {
601  invertByLU( m );
602 }
604 //*************************************************************************************************
605 
606 
607 //*************************************************************************************************
630 template< typename MT // Type of the dense matrix
631  , bool SO > // Storage order of the dense matrix
632 inline void invertByLU( LowerMatrix<MT,SO,true>& m )
633 {
635 
636  typename DerestrictTrait<MT>::Type A( derestrict( ~m ) );
637 
638  trtri( A, 'L', 'N' );
639 
640  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
641 }
643 //*************************************************************************************************
644 
645 
646 //*************************************************************************************************
669 template< typename MT // Type of the dense matrix
670  , bool SO > // Storage order of the dense matrix
671 inline void invertByLDLT( LowerMatrix<MT,SO,true>& m )
672 {
673  invertByLLH( m );
674 }
676 //*************************************************************************************************
677 
678 
679 //*************************************************************************************************
702 template< typename MT // Type of the dense matrix
703  , bool SO > // Storage order of the dense matrix
704 inline void invertByLDLH( LowerMatrix<MT,SO,true>& m )
705 {
706  invertByLLH( m );
707 }
709 //*************************************************************************************************
710 
711 
712 //*************************************************************************************************
732 template< typename MT // Type of the dense matrix
733  , bool SO > // Storage order of the dense matrix
734 inline void invertByLLH( LowerMatrix<MT,SO,true>& m )
735 {
737 
738  BLAZE_INTERNAL_ASSERT( isDiagonal( ~m ), "Violation of preconditions detected" );
739 
740  typename DerestrictTrait<MT>::Type A( derestrict( ~m ) );
741 
742  for( size_t i=0UL; i<A.rows(); ++i )
743  {
744  if( isDefault( A(i,i) ) ) {
745  BLAZE_THROW_INVALID_ARGUMENT( "Inversion of singular matrix failed" );
746  }
747 
748  invert( A(i,i) );
749  }
750 
751  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
752 }
754 //*************************************************************************************************
755 
756 
757 //*************************************************************************************************
776 template< typename MT1, bool SO1, typename MT2, typename MT3, typename MT4, bool SO2 >
777 inline void lu( const LowerMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
778  DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P )
779 {
781 
786 
791 
792  typedef typename MT3::ElementType ET3;
793  typedef typename MT4::ElementType ET4;
794 
795  const size_t n( (~A).rows() );
796 
797  typename DerestrictTrait<MT3>::Type U2( derestrict( ~U ) );
798 
799  (~L) = A;
800 
801  resize( ~U, n, n );
802  reset( U2 );
803 
804  resize( ~P, n, n );
805  reset( ~P );
806 
807  for( size_t i=0UL; i<n; ++i ) {
808  U2(i,i) = ET3(1);
809  (~P)(i,i) = ET4(1);
810  }
811 }
813 //*************************************************************************************************
814 
815 
816 //*************************************************************************************************
832 template< typename MT // Type of the adapted matrix
833  , bool SO // Storage order of the adapted matrix
834  , bool DF // Density flag
835  , typename VT > // Type of the right-hand side dense vector
836 inline bool tryAssign( const LowerMatrix<MT,SO,DF>& lhs,
837  const DenseVector<VT,false>& rhs, size_t row, size_t column )
838 {
840 
841  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
842  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
843  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
844 
845  UNUSED_PARAMETER( lhs );
846 
847  if( column <= row )
848  return true;
849 
850  const size_t iend( min( column - row, (~rhs).size() ) );
851 
852  for( size_t i=0UL; i<iend; ++i ) {
853  if( !isDefault( (~rhs)[i] ) )
854  return false;
855  }
856 
857  return true;
858 }
860 //*************************************************************************************************
861 
862 
863 //*************************************************************************************************
879 template< typename MT // Type of the adapted matrix
880  , bool SO // Storage order of the adapted matrix
881  , bool DF // Density flag
882  , typename VT > // Type of the right-hand side dense vector
883 inline bool tryAssign( const LowerMatrix<MT,SO,DF>& lhs,
884  const DenseVector<VT,true>& rhs, size_t row, size_t column )
885 {
887 
888  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
889  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
890  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
891 
892  UNUSED_PARAMETER( lhs );
893 
894  const size_t ibegin( ( row < column )?( 0UL ):( row - column + 1UL ) );
895 
896  for( size_t i=ibegin; i<(~rhs).size(); ++i ) {
897  if( !isDefault( (~rhs)[i] ) )
898  return false;
899  }
900 
901  return true;
902 }
904 //*************************************************************************************************
905 
906 
907 //*************************************************************************************************
923 template< typename MT // Type of the adapted matrix
924  , bool SO // Storage order of the adapted matrix
925  , bool DF // Density flag
926  , typename VT > // Type of the right-hand side sparse vector
927 inline bool tryAssign( const LowerMatrix<MT,SO,DF>& lhs,
928  const SparseVector<VT,false>& rhs, size_t row, size_t column )
929 {
931 
932  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
933  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
934  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
935 
936  UNUSED_PARAMETER( lhs );
937 
938  typedef typename VT::ConstIterator RhsIterator;
939 
940  if( column <= row )
941  return true;
942 
943  const RhsIterator last( (~rhs).lowerBound( column - row ) );
944 
945  for( RhsIterator element=(~rhs).begin(); element!=last; ++element ) {
946  if( !isDefault( element->value() ) )
947  return false;
948  }
949 
950  return true;
951 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
972 template< typename MT // Type of the adapted matrix
973  , bool SO // Storage order of the adapted matrix
974  , bool DF // Density flag
975  , typename VT > // Type of the right-hand side sparse vector
976 inline bool tryAssign( const LowerMatrix<MT,SO,DF>& lhs,
977  const SparseVector<VT,true>& rhs, size_t row, size_t column )
978 {
980 
981  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
982  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
983  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
984 
985  UNUSED_PARAMETER( lhs );
986 
987  typedef typename VT::ConstIterator RhsIterator;
988 
989  const RhsIterator last( (~rhs).end() );
990  RhsIterator element( (~rhs).lowerBound( ( row < column )?( 0UL ):( row - column + 1UL ) ) );
991 
992  for( ; element!=last; ++element ) {
993  if( !isDefault( element->value() ) )
994  return false;
995  }
996 
997  return true;
998 }
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1019 template< typename MT1 // Type of the adapted matrix
1020  , bool SO // Storage order of the adapted matrix
1021  , bool DF // Density flag
1022  , typename MT2 > // Type of the right-hand side dense matrix
1023 inline bool tryAssign( const LowerMatrix<MT1,SO,DF>& lhs,
1024  const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1025 {
1027 
1028  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1029  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1030  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
1031  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
1032 
1033  UNUSED_PARAMETER( lhs );
1034 
1035  const size_t M( (~rhs).rows() );
1036  const size_t N( (~rhs).columns() );
1037 
1038  if( row + 1UL >= column + N )
1039  return true;
1040 
1041  const size_t iend( min( column + N - row - 1UL, M ) );
1042 
1043  for( size_t i=0UL; i<iend; ++i )
1044  {
1045  const bool containsDiagonal( row + i >= column );
1046  const size_t jbegin( ( containsDiagonal )?( row + i - column + 1UL ):( 0UL ) );
1047 
1048  for( size_t j=jbegin; j<N; ++j ) {
1049  if( !isDefault( (~rhs)(i,j) ) )
1050  return false;
1051  }
1052  }
1053 
1054  return true;
1055 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1076 template< typename MT1 // Type of the adapted matrix
1077  , bool SO // Storage order of the adapted matrix
1078  , bool DF // Density flag
1079  , typename MT2 > // Type of the right-hand side dense matrix
1080 inline bool tryAssign( const LowerMatrix<MT1,SO,DF>& lhs,
1081  const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1082 {
1084 
1085  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1086  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1087  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
1088  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
1089 
1090  UNUSED_PARAMETER( lhs );
1091 
1092  const size_t M( (~rhs).rows() );
1093  const size_t N( (~rhs).columns() );
1094 
1095  if( row + 1UL >= column + N )
1096  return true;
1097 
1098  const size_t jbegin( ( row < column )?( 0UL ):( row - column + 1UL ) );
1099 
1100  for( size_t j=jbegin; j<N; ++j )
1101  {
1102  const size_t iend( min( column + j - row, M ) );
1103 
1104  for( size_t i=0UL; i<iend; ++i ) {
1105  if( !isDefault( (~rhs)(i,j) ) )
1106  return false;
1107  }
1108  }
1109 
1110  return true;
1111 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1132 template< typename MT1 // Type of the adapted matrix
1133  , bool SO // Storage order of the adapted matrix
1134  , bool DF // Density flag
1135  , typename MT2 > // Type of the right-hand side sparse matrix
1136 inline bool tryAssign( const LowerMatrix<MT1,SO,DF>& lhs,
1137  const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1138 {
1140 
1141  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1142  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1143  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
1144  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
1145 
1146  UNUSED_PARAMETER( lhs );
1147 
1148  typedef typename MT2::ConstIterator RhsIterator;
1149 
1150  const size_t M( (~rhs).rows() );
1151  const size_t N( (~rhs).columns() );
1152 
1153  if( row + 1UL >= column + N )
1154  return true;
1155 
1156  const size_t iend( min( column + N - row - 1UL, M ) );
1157 
1158  for( size_t i=0UL; i<iend; ++i )
1159  {
1160  const bool containsDiagonal( row + i >= column );
1161  const size_t index( ( containsDiagonal )?( row + i - column + 1UL ):( 0UL ) );
1162 
1163  const RhsIterator last( (~rhs).end(i) );
1164  RhsIterator element( (~rhs).lowerBound( i, index ) );
1165 
1166  for( ; element!=last; ++element ) {
1167  if( !isDefault( element->value() ) )
1168  return false;
1169  }
1170  }
1171 
1172  return true;
1173 }
1175 //*************************************************************************************************
1176 
1177 
1178 //*************************************************************************************************
1194 template< typename MT1 // Type of the adapted matrix
1195  , bool SO // Storage order of the adapted matrix
1196  , bool DF // Density flag
1197  , typename MT2 > // Type of the right-hand side sparse matrix
1198 inline bool tryAssign( const LowerMatrix<MT1,SO,DF>& lhs,
1199  const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1200 {
1202 
1203  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1204  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1205  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
1206  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
1207 
1208  UNUSED_PARAMETER( lhs );
1209 
1210  typedef typename MT2::ConstIterator RhsIterator;
1211 
1212  const size_t M( (~rhs).rows() );
1213  const size_t N( (~rhs).columns() );
1214 
1215  if( row + 1UL >= column + N )
1216  return true;
1217 
1218  const size_t jbegin( ( row < column )?( 0UL ):( row - column + 1UL ) );
1219 
1220  for( size_t j=jbegin; j<N; ++j )
1221  {
1222  const size_t index( column + j - row );
1223  const RhsIterator last( (~rhs).lowerBound( min( index, M ), j ) );
1224 
1225  for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
1226  if( !isDefault( element->value() ) )
1227  return false;
1228  }
1229  }
1230 
1231  return true;
1232 }
1234 //*************************************************************************************************
1235 
1236 
1237 //*************************************************************************************************
1253 template< typename MT // Type of the adapted matrix
1254  , bool SO // Storage order of the adapted matrix
1255  , bool DF // Density flag
1256  , typename VT // Type of the right-hand side vector
1257  , bool TF > // Transpose flag of the right-hand side vector
1258 inline bool tryAddAssign( const LowerMatrix<MT,SO,DF>& lhs,
1259  const Vector<VT,TF>& rhs, size_t row, size_t column )
1260 {
1261  return tryAssign( lhs, ~rhs, row, column );
1262 }
1264 //*************************************************************************************************
1265 
1266 
1267 //*************************************************************************************************
1283 template< typename MT1 // Type of the adapted matrix
1284  , bool SO1 // Storage order of the adapted matrix
1285  , bool DF // Density flag
1286  , typename MT2 // Type of the right-hand side matrix
1287  , bool SO2 > // Storage order of the right-hand side matrix
1288 inline bool tryAddAssign( const LowerMatrix<MT1,SO1,DF>& lhs,
1289  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1290 {
1291  return tryAssign( lhs, ~rhs, row, column );
1292 }
1294 //*************************************************************************************************
1295 
1296 
1297 //*************************************************************************************************
1313 template< typename MT // Type of the adapted matrix
1314  , bool SO // Storage order of the adapted matrix
1315  , bool DF // Density flag
1316  , typename VT // Type of the right-hand side vector
1317  , bool TF > // Transpose flag of the right-hand side vector
1318 inline bool trySubAssign( const LowerMatrix<MT,SO,DF>& lhs,
1319  const Vector<VT,TF>& rhs, size_t row, size_t column )
1320 {
1321  return tryAssign( lhs, ~rhs, row, column );
1322 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1343 template< typename MT1 // Type of the adapted matrix
1344  , bool SO1 // Storage order of the adapted matrix
1345  , bool DF // Density flag
1346  , typename MT2 // Type of the right-hand side matrix
1347  , bool SO2 > // Storage order of the right-hand side matrix
1348 inline bool trySubAssign( const LowerMatrix<MT1,SO1,DF>& lhs,
1349  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1350 {
1351  return tryAssign( lhs, ~rhs, row, column );
1352 }
1354 //*************************************************************************************************
1355 
1356 
1357 //*************************************************************************************************
1371 template< typename MT // Type of the adapted matrix
1372  , bool SO // Storage order of the adapted matrix
1373  , bool DF > // Density flag
1374 inline MT& derestrict( LowerMatrix<MT,SO,DF>& m )
1375 {
1376  return m.matrix_;
1377 }
1379 //*************************************************************************************************
1380 
1381 
1382 
1383 
1384 //=================================================================================================
1385 //
1386 // ROWS SPECIALIZATIONS
1387 //
1388 //=================================================================================================
1389 
1390 //*************************************************************************************************
1392 template< typename MT, bool SO, bool DF >
1393 struct Rows< LowerMatrix<MT,SO,DF> > : public Rows<MT>
1394 {};
1396 //*************************************************************************************************
1397 
1398 
1399 
1400 
1401 //=================================================================================================
1402 //
1403 // COLUMNS SPECIALIZATIONS
1404 //
1405 //=================================================================================================
1406 
1407 //*************************************************************************************************
1409 template< typename MT, bool SO, bool DF >
1410 struct Columns< LowerMatrix<MT,SO,DF> > : public Columns<MT>
1411 {};
1413 //*************************************************************************************************
1414 
1415 
1416 
1417 
1418 //=================================================================================================
1419 //
1420 // ISSQUARE SPECIALIZATIONS
1421 //
1422 //=================================================================================================
1423 
1424 //*************************************************************************************************
1426 template< typename MT, bool SO, bool DF >
1427 struct IsSquare< LowerMatrix<MT,SO,DF> > : public IsTrue<true>
1428 {};
1430 //*************************************************************************************************
1431 
1432 
1433 
1434 
1435 //=================================================================================================
1436 //
1437 // ISLOWER SPECIALIZATIONS
1438 //
1439 //=================================================================================================
1440 
1441 //*************************************************************************************************
1443 template< typename MT, bool SO, bool DF >
1444 struct IsLower< LowerMatrix<MT,SO,DF> > : public IsTrue<true>
1445 {};
1447 //*************************************************************************************************
1448 
1449 
1450 
1451 
1452 //=================================================================================================
1453 //
1454 // ISADAPTOR SPECIALIZATIONS
1455 //
1456 //=================================================================================================
1457 
1458 //*************************************************************************************************
1460 template< typename MT, bool SO, bool DF >
1461 struct IsAdaptor< LowerMatrix<MT,SO,DF> > : public IsTrue<true>
1462 {};
1464 //*************************************************************************************************
1465 
1466 
1467 
1468 
1469 //=================================================================================================
1470 //
1471 // ISRESTRICTED SPECIALIZATIONS
1472 //
1473 //=================================================================================================
1474 
1475 //*************************************************************************************************
1477 template< typename MT, bool SO, bool DF >
1478 struct IsRestricted< LowerMatrix<MT,SO,DF> > : public IsTrue<true>
1479 {};
1481 //*************************************************************************************************
1482 
1483 
1484 
1485 
1486 //=================================================================================================
1487 //
1488 // HASCONSTDATAACCESS SPECIALIZATIONS
1489 //
1490 //=================================================================================================
1491 
1492 //*************************************************************************************************
1494 template< typename MT, bool SO >
1495 struct HasConstDataAccess< LowerMatrix<MT,SO,true> > : public IsTrue<true>
1496 {};
1498 //*************************************************************************************************
1499 
1500 
1501 
1502 
1503 //=================================================================================================
1504 //
1505 // ISALIGNED SPECIALIZATIONS
1506 //
1507 //=================================================================================================
1508 
1509 //*************************************************************************************************
1511 template< typename MT, bool SO, bool DF >
1512 struct IsAligned< LowerMatrix<MT,SO,DF> > : public IsTrue< IsAligned<MT>::value >
1513 {};
1515 //*************************************************************************************************
1516 
1517 
1518 
1519 
1520 //=================================================================================================
1521 //
1522 // ISPADDED SPECIALIZATIONS
1523 //
1524 //=================================================================================================
1525 
1526 //*************************************************************************************************
1528 template< typename MT, bool SO, bool DF >
1529 struct IsPadded< LowerMatrix<MT,SO,DF> > : public IsTrue< IsPadded<MT>::value >
1530 {};
1532 //*************************************************************************************************
1533 
1534 
1535 
1536 
1537 //=================================================================================================
1538 //
1539 // ISRESIZABLE SPECIALIZATIONS
1540 //
1541 //=================================================================================================
1542 
1543 //*************************************************************************************************
1545 template< typename MT, bool SO, bool DF >
1546 struct IsResizable< LowerMatrix<MT,SO,DF> > : public IsTrue< IsResizable<MT>::value >
1547 {};
1549 //*************************************************************************************************
1550 
1551 
1552 
1553 
1554 //=================================================================================================
1555 //
1556 // REMOVEADAPTOR SPECIALIZATIONS
1557 //
1558 //=================================================================================================
1559 
1560 //*************************************************************************************************
1562 template< typename MT, bool SO, bool DF >
1563 struct RemoveAdaptor< LowerMatrix<MT,SO,DF> >
1564 {
1565  typedef MT Type;
1566 };
1568 //*************************************************************************************************
1569 
1570 
1571 
1572 
1573 //=================================================================================================
1574 //
1575 // DERESTRICTTRAIT SPECIALIZATIONS
1576 //
1577 //=================================================================================================
1578 
1579 //*************************************************************************************************
1581 template< typename MT, bool SO, bool DF >
1582 struct DerestrictTrait< LowerMatrix<MT,SO,DF> >
1583 {
1584  typedef MT& Type;
1585 };
1587 //*************************************************************************************************
1588 
1589 
1590 
1591 
1592 //=================================================================================================
1593 //
1594 // ADDTRAIT SPECIALIZATIONS
1595 //
1596 //=================================================================================================
1597 
1598 //*************************************************************************************************
1600 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1601 struct AddTrait< LowerMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1602 {
1603  typedef typename AddTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
1604 };
1605 
1606 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1607 struct AddTrait< StaticMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1608 {
1609  typedef typename AddTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
1610 };
1611 
1612 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1613 struct AddTrait< LowerMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1614 {
1615  typedef typename AddTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
1616 };
1617 
1618 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1619 struct AddTrait< HybridMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1620 {
1621  typedef typename AddTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
1622 };
1623 
1624 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1625 struct AddTrait< LowerMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1626 {
1627  typedef typename AddTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
1628 };
1629 
1630 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1631 struct AddTrait< DynamicMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1632 {
1633  typedef typename AddTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
1634 };
1635 
1636 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1637 struct AddTrait< LowerMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1638 {
1639  typedef typename AddTrait< MT, CustomMatrix<T,AF,PF,SO2> >::Type Type;
1640 };
1641 
1642 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1643 struct AddTrait< CustomMatrix<T,AF,PF,SO1>, LowerMatrix<MT,SO2,DF> >
1644 {
1645  typedef typename AddTrait< CustomMatrix<T,AF,PF,SO1>, MT >::Type Type;
1646 };
1647 
1648 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1649 struct AddTrait< LowerMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1650 {
1651  typedef typename AddTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
1652 };
1653 
1654 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1655 struct AddTrait< CompressedMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1656 {
1657  typedef typename AddTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
1658 };
1659 
1660 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1661 struct AddTrait< LowerMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1662 {
1663  typedef typename AddTrait<MT1,MT2>::Type Type;
1664 };
1665 
1666 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1667 struct AddTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, LowerMatrix<MT2,SO2,DF2> >
1668 {
1669  typedef typename AddTrait<MT1,MT2>::Type Type;
1670 };
1671 
1672 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1673 struct AddTrait< LowerMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1674 {
1675  typedef typename AddTrait<MT1,MT2>::Type Type;
1676 };
1677 
1678 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1679 struct AddTrait< HermitianMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1680 {
1681  typedef typename AddTrait<MT1,MT2>::Type Type;
1682 };
1683 
1684 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1685 struct AddTrait< LowerMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1686 {
1687  typedef LowerMatrix< typename AddTrait<MT1,MT2>::Type > Type;
1688 };
1690 //*************************************************************************************************
1691 
1692 
1693 
1694 
1695 //=================================================================================================
1696 //
1697 // SUBTRAIT SPECIALIZATIONS
1698 //
1699 //=================================================================================================
1700 
1701 //*************************************************************************************************
1703 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1704 struct SubTrait< LowerMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1705 {
1706  typedef typename SubTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
1707 };
1708 
1709 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1710 struct SubTrait< StaticMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1711 {
1712  typedef typename SubTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
1713 };
1714 
1715 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1716 struct SubTrait< LowerMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1717 {
1718  typedef typename SubTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
1719 };
1720 
1721 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1722 struct SubTrait< HybridMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1723 {
1724  typedef typename SubTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
1725 };
1726 
1727 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1728 struct SubTrait< LowerMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1729 {
1730  typedef typename SubTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
1731 };
1732 
1733 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1734 struct SubTrait< DynamicMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1735 {
1736  typedef typename SubTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
1737 };
1738 
1739 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1740 struct SubTrait< LowerMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1741 {
1742  typedef typename SubTrait< MT, CustomMatrix<T,AF,PF,SO2> >::Type Type;
1743 };
1744 
1745 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1746 struct SubTrait< CustomMatrix<T,AF,PF,SO1>, LowerMatrix<MT,SO2,DF> >
1747 {
1748  typedef typename SubTrait< CustomMatrix<T,AF,PF,SO1>, MT >::Type Type;
1749 };
1750 
1751 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1752 struct SubTrait< LowerMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1753 {
1754  typedef typename SubTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
1755 };
1756 
1757 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1758 struct SubTrait< CompressedMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1759 {
1760  typedef typename SubTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
1761 };
1762 
1763 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1764 struct SubTrait< LowerMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1765 {
1766  typedef typename SubTrait<MT1,MT2>::Type Type;
1767 };
1768 
1769 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1770 struct SubTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, LowerMatrix<MT2,SO2,DF2> >
1771 {
1772  typedef typename SubTrait<MT1,MT2>::Type Type;
1773 };
1774 
1775 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1776 struct SubTrait< LowerMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1777 {
1778  typedef typename SubTrait<MT1,MT2>::Type Type;
1779 };
1780 
1781 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1782 struct SubTrait< HermitianMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1783 {
1784  typedef typename SubTrait<MT1,MT2>::Type Type;
1785 };
1786 
1787 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1788 struct SubTrait< LowerMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1789 {
1790  typedef LowerMatrix< typename SubTrait<MT1,MT2>::Type > Type;
1791 };
1793 //*************************************************************************************************
1794 
1795 
1796 
1797 
1798 //=================================================================================================
1799 //
1800 // MULTTRAIT SPECIALIZATIONS
1801 //
1802 //=================================================================================================
1803 
1804 //*************************************************************************************************
1806 template< typename MT, bool SO, bool DF, typename T >
1807 struct MultTrait< LowerMatrix<MT,SO,DF>, T, typename EnableIf< IsNumeric<T> >::Type >
1808 {
1809  typedef LowerMatrix< typename MultTrait<MT,T>::Type > Type;
1810 };
1811 
1812 template< typename T, typename MT, bool SO, bool DF >
1813 struct MultTrait< T, LowerMatrix<MT,SO,DF>, typename EnableIf< IsNumeric<T> >::Type >
1814 {
1815  typedef LowerMatrix< typename MultTrait<T,MT>::Type > Type;
1816 };
1817 
1818 template< typename MT, bool SO, bool DF, typename T, size_t N >
1819 struct MultTrait< LowerMatrix<MT,SO,DF>, StaticVector<T,N,false> >
1820 {
1821  typedef typename MultTrait< MT, StaticVector<T,N,false> >::Type Type;
1822 };
1823 
1824 template< typename T, size_t N, typename MT, bool SO, bool DF >
1825 struct MultTrait< StaticVector<T,N,true>, LowerMatrix<MT,SO,DF> >
1826 {
1827  typedef typename MultTrait< StaticVector<T,N,true>, MT >::Type Type;
1828 };
1829 
1830 template< typename MT, bool SO, bool DF, typename T, size_t N >
1831 struct MultTrait< LowerMatrix<MT,SO,DF>, HybridVector<T,N,false> >
1832 {
1833  typedef typename MultTrait< MT, HybridVector<T,N,false> >::Type Type;
1834 };
1835 
1836 template< typename T, size_t N, typename MT, bool SO, bool DF >
1837 struct MultTrait< HybridVector<T,N,true>, LowerMatrix<MT,SO,DF> >
1838 {
1839  typedef typename MultTrait< HybridVector<T,N,true>, MT >::Type Type;
1840 };
1841 
1842 template< typename MT, bool SO, bool DF, typename T >
1843 struct MultTrait< LowerMatrix<MT,SO,DF>, DynamicVector<T,false> >
1844 {
1845  typedef typename MultTrait< MT, DynamicVector<T,false> >::Type Type;
1846 };
1847 
1848 template< typename T, typename MT, bool SO, bool DF >
1849 struct MultTrait< DynamicVector<T,true>, LowerMatrix<MT,SO,DF> >
1850 {
1851  typedef typename MultTrait< DynamicVector<T,true>, MT >::Type Type;
1852 };
1853 
1854 template< typename MT, bool SO, bool DF, typename T, bool AF, bool PF >
1855 struct MultTrait< LowerMatrix<MT,SO,DF>, CustomVector<T,AF,PF,false> >
1856 {
1857  typedef typename MultTrait< MT, CustomVector<T,AF,PF,false> >::Type Type;
1858 };
1859 
1860 template< typename T, bool AF, bool PF, typename MT, bool SO, bool DF >
1861 struct MultTrait< CustomVector<T,AF,PF,true>, LowerMatrix<MT,SO,DF> >
1862 {
1863  typedef typename MultTrait< CustomVector<T,AF,PF,true>, MT >::Type Type;
1864 };
1865 
1866 template< typename MT, bool SO, bool DF, typename T >
1867 struct MultTrait< LowerMatrix<MT,SO,DF>, CompressedVector<T,false> >
1868 {
1869  typedef typename MultTrait< MT, CompressedVector<T,false> >::Type Type;
1870 };
1871 
1872 template< typename T, typename MT, bool SO, bool DF >
1873 struct MultTrait< CompressedVector<T,true>, LowerMatrix<MT,SO,DF> >
1874 {
1875  typedef typename MultTrait< CompressedVector<T,true>, MT >::Type Type;
1876 };
1877 
1878 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1879 struct MultTrait< LowerMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1880 {
1881  typedef typename MultTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
1882 };
1883 
1884 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1885 struct MultTrait< StaticMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1886 {
1887  typedef typename MultTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
1888 };
1889 
1890 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1891 struct MultTrait< LowerMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1892 {
1893  typedef typename MultTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
1894 };
1895 
1896 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1897 struct MultTrait< HybridMatrix<T,M,N,SO1>, LowerMatrix<MT,SO2,DF> >
1898 {
1899  typedef typename MultTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
1900 };
1901 
1902 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1903 struct MultTrait< LowerMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1904 {
1905  typedef typename MultTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
1906 };
1907 
1908 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1909 struct MultTrait< DynamicMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1910 {
1911  typedef typename MultTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
1912 };
1913 
1914 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1915 struct MultTrait< LowerMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1916 {
1917  typedef typename MultTrait< MT, CustomMatrix<T,AF,PF,SO2> >::Type Type;
1918 };
1919 
1920 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1921 struct MultTrait< CustomMatrix<T,AF,PF,SO1>, LowerMatrix<MT,SO2,DF> >
1922 {
1923  typedef typename MultTrait< CustomMatrix<T,AF,PF,SO1>, MT >::Type Type;
1924 };
1925 
1926 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1927 struct MultTrait< LowerMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1928 {
1929  typedef typename MultTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
1930 };
1931 
1932 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1933 struct MultTrait< CompressedMatrix<T,SO1>, LowerMatrix<MT,SO2,DF> >
1934 {
1935  typedef typename MultTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
1936 };
1937 
1938 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1939 struct MultTrait< LowerMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1940 {
1941  typedef typename MultTrait<MT1,MT2>::Type Type;
1942 };
1943 
1944 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1945 struct MultTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, LowerMatrix<MT2,SO2,DF2> >
1946 {
1947  typedef typename MultTrait<MT1,MT2>::Type Type;
1948 };
1949 
1950 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1951 struct MultTrait< LowerMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1952 {
1953  typedef typename MultTrait<MT1,MT2>::Type Type;
1954 };
1955 
1956 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1957 struct MultTrait< HermitianMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1958 {
1959  typedef typename MultTrait<MT1,MT2>::Type Type;
1960 };
1961 
1962 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1963 struct MultTrait< LowerMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1964 {
1965  typedef LowerMatrix< typename MultTrait<MT1,MT2>::Type > Type;
1966 };
1968 //*************************************************************************************************
1969 
1970 
1971 
1972 
1973 //=================================================================================================
1974 //
1975 // DIVTRAIT SPECIALIZATIONS
1976 //
1977 //=================================================================================================
1978 
1979 //*************************************************************************************************
1981 template< typename MT, bool SO, bool DF, typename T >
1982 struct DivTrait< LowerMatrix<MT,SO,DF>, T, typename EnableIf< IsNumeric<T> >::Type >
1983 {
1984  typedef LowerMatrix< typename DivTrait<MT,T>::Type > Type;
1985 };
1987 //*************************************************************************************************
1988 
1989 
1990 
1991 
1992 //=================================================================================================
1993 //
1994 // MATHTRAIT SPECIALIZATIONS
1995 //
1996 //=================================================================================================
1997 
1998 //*************************************************************************************************
2000 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
2001 struct MathTrait< LowerMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
2002 {
2003  typedef LowerMatrix< typename MathTrait<MT1,MT2>::HighType > HighType;
2004  typedef LowerMatrix< typename MathTrait<MT1,MT2>::LowType > LowType;
2005 };
2007 //*************************************************************************************************
2008 
2009 
2010 
2011 
2012 //=================================================================================================
2013 //
2014 // SUBMATRIXTRAIT SPECIALIZATIONS
2015 //
2016 //=================================================================================================
2017 
2018 //*************************************************************************************************
2020 template< typename MT, bool SO, bool DF >
2021 struct SubmatrixTrait< LowerMatrix<MT,SO,DF> >
2022 {
2023  typedef typename SubmatrixTrait<MT>::Type Type;
2024 };
2026 //*************************************************************************************************
2027 
2028 
2029 
2030 
2031 //=================================================================================================
2032 //
2033 // ROWTRAIT SPECIALIZATIONS
2034 //
2035 //=================================================================================================
2036 
2037 //*************************************************************************************************
2039 template< typename MT, bool SO, bool DF >
2040 struct RowTrait< LowerMatrix<MT,SO,DF> >
2041 {
2042  typedef typename RowTrait<MT>::Type Type;
2043 };
2045 //*************************************************************************************************
2046 
2047 
2048 
2049 
2050 //=================================================================================================
2051 //
2052 // COLUMNTRAIT SPECIALIZATIONS
2053 //
2054 //=================================================================================================
2055 
2056 //*************************************************************************************************
2058 template< typename MT, bool SO, bool DF >
2059 struct ColumnTrait< LowerMatrix<MT,SO,DF> >
2060 {
2061  typedef typename ColumnTrait<MT>::Type Type;
2062 };
2064 //*************************************************************************************************
2065 
2066 } // namespace blaze
2067 
2068 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Header file for mathematical functions.
void trtri(char uplo, char diag, int n, float *A, int lda, int *info)
LAPACK kernel for the inversion of the given dense triangular single precision column-major matrix...
Definition: trtri.h:133
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1511
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
Header file for the row trait.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
LowerMatrix specialization for dense matrices.
Matrix adapter for lower triangular matrices.
Definition: Forward.h:48
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
MT::ElementType det(const DenseMatrix< MT, SO > &dm)
Computation of the determinant of the given dense square matrix.
Definition: DMatDetExpr.h:382
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:118
Header file for the invert shim.
Constraint on the data type.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Header file for the IsSquare type trait.
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:767
Header file for the multiplication trait.
Header file for the implementation of the base template of the LowerMatrix.
Header file for the LAPACK triangular matrix inversion functions (trtri)
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
void lu(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO1 > &L, DenseMatrix< MT3, SO1 > &U, Matrix< MT4, SO2 > &P)
LU decomposition of the given dense matrix.
Definition: LU.h:217
Header file for the Columns type trait.
Header file for the implementation of a fixed-size matrix.
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:118
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Constraint on the data type.
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:118
Header file for the column trait.
Header file for the isDefault shim.
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i...
Definition: BlasCompatible.h:79
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the mathematical trait.
LowerMatrix specialization for sparse matrices.
Header file for the IsTrue value trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:116
Header file for exception macros.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101