geev.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_LAPACK_GEEV_H_
36 #define _BLAZE_MATH_LAPACK_GEEV_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <memory>
44 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
53 #include <blaze/math/shims/Equal.h>
56 #include <blaze/util/Assert.h>
57 #include <blaze/util/Complex.h>
60 #include <blaze/util/DisableIf.h>
61 #include <blaze/util/EnableIf.h>
62 #include <blaze/util/NumericCast.h>
64 
65 
66 namespace blaze {
67 
68 //=================================================================================================
69 //
70 // LAPACK GENERAL MATRIX EIGENVALUE FUNCTIONS (GEEV)
71 //
72 //=================================================================================================
73 
74 //*************************************************************************************************
77 template< typename MT, bool SO, typename VT, bool TF >
78 inline void geev( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w );
79 
80 template< typename MT1, bool SO1, typename MT2, bool SO2, typename VT, bool TF >
81 inline void geev( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL, DenseVector<VT,TF>& w );
82 
83 template< typename MT1, bool SO1, typename VT, bool TF, typename MT2, bool SO2 >
84 inline void geev( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& VR );
85 
86 template< typename MT1, bool SO1, typename MT2, bool SO2, typename VT, bool TF, typename MT3, bool SO3 >
87 inline void geev( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
88  DenseVector<VT,TF>& w, DenseMatrix<MT3,SO3>& VR );
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
110 template< typename MT // Type of the matrix A
111  , bool SO // Storage order of the matrix A
112  , typename VT // Type of the vector w
113  , bool TF > // Transpose flag of the vector w
114 inline DisableIf_< IsComplex< ElementType_<MT> > >
115  geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
116 {
117  BLAZE_INTERNAL_ASSERT( isSquare( ~A ), "Invalid non-square matrix detected" );
118  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
119 
120  using CT = ElementType_<VT>;
121  using BT = ElementType_<MT>;
122 
125 
126  int n ( numeric_cast<int>( (~A).rows() ) );
127  int lda ( numeric_cast<int>( (~A).spacing() ) );
128  int info( 0 );
129 
130  int lwork( 3*n + 2 );
131  const std::unique_ptr<BT[]> wr ( new BT[n] );
132  const std::unique_ptr<BT[]> wi ( new BT[n] );
133  const std::unique_ptr<BT[]> work( new BT[lwork] );
134 
135  geev( 'N', 'N', n, (~A).data(), lda, wr.get(), wi.get(),
136  nullptr, 1, nullptr, 1, work.get(), lwork, &info );
137 
138  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
139 
140  if( info > 0 ) {
141  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
142  }
143 
144  for( size_t i=0UL; i<(~A).rows(); ++i ) {
145  (~w)[i] = CT( wr[i], wi[i] );
146  }
147 }
149 //*************************************************************************************************
150 
151 
152 //*************************************************************************************************
169 template< typename MT // Type of the matrix A
170  , bool SO // Storage order of the matrix A
171  , typename VT // Type of the vector w
172  , bool TF > // Transpose flag of the vector w
173 inline EnableIf_< IsComplex< ElementType_<MT> > >
174  geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
175 {
176  BLAZE_INTERNAL_ASSERT( isSquare( ~A ), "Invalid non-square matrix detected" );
177  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
178 
179  using CT = ElementType_<MT>;
180  using BT = UnderlyingElement_<CT>;
181 
184 
185  int n ( numeric_cast<int>( (~A).rows() ) );
186  int lda ( numeric_cast<int>( (~A).spacing() ) );
187  int info( 0 );
188 
189  int lwork( 2*n + 2 );
190  const std::unique_ptr<CT[]> work ( new CT[lwork] );
191  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
192 
193  geev( 'N', 'N', n, (~A).data(), lda, (~w).data(),
194  nullptr, 1, nullptr, 1, work.get(), lwork, rwork.get(), &info );
195 
196  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
197 
198  if( info > 0 ) {
199  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
200  }
201 }
203 //*************************************************************************************************
204 
205 
206 //*************************************************************************************************
261 template< typename MT // Type of the matrix A
262  , bool SO // Storage order of the matrix A
263  , typename VT // Type of the vector w
264  , bool TF > // Transpose flag of the vector w
266 {
271 
276 
277  const size_t N( (~A).rows() );
278 
279  if( !isSquare( ~A ) ) {
280  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
281  }
282 
283  resize( ~w, N, false );
284 
285  if( N == 0UL ) {
286  return;
287  }
288 
289  geev_backend( ~A, ~w );
290 }
291 //*************************************************************************************************
292 
293 
294 //*************************************************************************************************
312 template< typename MT1 // Type of the matrix A
313  , bool SO1 // Storage order of the matrix A
314  , typename MT2 // Type of the matrix VL
315  , bool SO2 // Storage order of the matrix VL
316  , typename VT // Type of the vector w
317  , bool TF > // Transpose flag of the vector w
320 {
321  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
322  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
323  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
324  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
325 
326  using CT = ElementType_<VT>;
327  using BT = ElementType_<MT1>;
328 
331 
332  int n ( numeric_cast<int>( (~A).rows() ) );
333  int lda ( numeric_cast<int>( (~A).spacing() ) );
334  int info( 0 );
335 
336  int lwork( 4*n + 2 );
337  const std::unique_ptr<BT[]> vl ( new BT[n*n] );
338  const std::unique_ptr<BT[]> wr ( new BT[n] );
339  const std::unique_ptr<BT[]> wi ( new BT[n] );
340  const std::unique_ptr<BT[]> work( new BT[lwork] );
341 
342  geev( ( SO1 ? 'V' : 'N' ), ( SO1 ? 'N' : 'V' ), n, (~A).data(), lda, wr.get(), wi.get(),
343  ( SO1 ? vl.get() : nullptr ), ( SO1 ? n : 1 ),
344  ( SO1 ? nullptr : vl.get() ), ( SO1 ? 1 : n ),
345  work.get(), lwork, &info );
346 
347  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
348 
349  if( info > 0 ) {
350  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
351  }
352 
353  const size_t N( (~A).rows() );
354 
355  for( size_t j=0UL; j<N; ++j ) {
356  (~w)[j] = CT( wr[j], wi[j] );
357  }
358 
359  for( size_t j=0UL; j<N; ++j ) {
360  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
361  for( size_t i=0UL; i<N; ++i )
362  {
363  const size_t j1( SO1 ? j : j+1UL );
364  const size_t j2( SO1 ? j+1UL : j );
365 
366  const BT vl1( vl[i+j*N] );
367  const BT vl2( vl[i+(j+1UL)*N] );
368 
369  ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
370  ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
371  }
372 
373  ++j;
374  }
375  else {
376  for( size_t i=0UL; i<N; ++i ) {
377  ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
378  }
379  }
380  }
381 }
383 //*************************************************************************************************
384 
385 
386 //*************************************************************************************************
404 template< typename MT1 // Type of the matrix A
405  , bool SO1 // Storage order of the matrix A
406  , typename MT2 // Type of the matrix VL
407  , bool SO2 // Storage order of the matrix VL
408  , typename VT // Type of the vector w
409  , bool TF > // Transpose flag of the vector w
412 {
413  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
414  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
415  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
416  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
417 
418  using CT = ElementType_<MT1>;
419  using BT = UnderlyingElement_<CT>;
420 
423 
424  int n ( numeric_cast<int>( (~A).rows() ) );
425  int lda ( numeric_cast<int>( (~A).spacing() ) );
426  int ldvl( numeric_cast<int>( (~VL).spacing() ) );
427  int info( 0 );
428 
429  int lwork( 2*n + 2 );
430  const std::unique_ptr<CT[]> work ( new CT[lwork] );
431  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
432 
433  geev( ( SO1 ? 'V' : 'N' ), ( SO1 ? 'N' : 'V' ), n, (~A).data(), lda, (~w).data(),
434  ( SO1 ? (~VL).data() : nullptr ), ( SO1 ? ldvl : 1 ),
435  ( SO1 ? nullptr : (~VL).data() ), ( SO1 ? 1 : ldvl ),
436  work.get(), lwork, rwork.get(), &info );
437 
438  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
439 
440  if( info > 0 ) {
441  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
442  }
443 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
517 template< typename MT1 // Type of the matrix A
518  , bool SO1 // Storage order of the matrix A
519  , typename MT2 // Type of the matrix VL
520  , bool SO2 // Storage order of the matrix VL
521  , typename VT // Type of the vector w
522  , bool TF > // Transpose flag of the vector w
524 {
529 
535 
540 
541  const size_t N( (~A).rows() );
542 
543  if( !isSquare( ~A ) ) {
544  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
545  }
546 
547  resize( ~w, N, false );
548  resize( ~VL, N, N, false );
549 
550  if( N == 0UL ) {
551  return;
552  }
553 
554  geev_backend( ~A, ~VL, ~w );
555 }
556 //*************************************************************************************************
557 
558 
559 //*************************************************************************************************
577 template< typename MT1 // Type of the matrix A
578  , bool SO1 // Storage order of the matrix A
579  , typename VT // Type of the vector w
580  , bool TF // Transpose flag of the vector w
581  , typename MT2 // Type of the matrix VR
582  , bool SO2 > // Storage order of the matrix VR
585 {
586  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
587  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
588  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
589  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
590 
591  using CT = ElementType_<VT>;
592  using BT = ElementType_<MT1>;
593 
596 
597  int n ( numeric_cast<int>( (~A).rows() ) );
598  int lda ( numeric_cast<int>( (~A).spacing() ) );
599  int info( 0 );
600 
601  int lwork( 4*n + 2 );
602  const std::unique_ptr<BT[]> vr ( new BT[n*n] );
603  const std::unique_ptr<BT[]> wr ( new BT[n] );
604  const std::unique_ptr<BT[]> wi ( new BT[n] );
605  const std::unique_ptr<BT[]> work( new BT[lwork] );
606 
607  geev( ( SO1 ? 'N' : 'V' ), ( SO1 ? 'V' : 'N' ), n, (~A).data(), lda, wr.get(), wi.get(),
608  ( SO1 ? nullptr : vr.get() ), ( SO1 ? 1 : n ),
609  ( SO1 ? vr.get() : nullptr ), ( SO1 ? n : 1 ),
610  work.get(), lwork, &info );
611 
612  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
613 
614  if( info > 0 ) {
615  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
616  }
617 
618  const size_t N( (~A).rows() );
619 
620  for( size_t j=0UL; j<N; ++j ) {
621  (~w)[j] = CT( wr[j], wi[j] );
622  }
623 
624  for( size_t j=0UL; j<N; ++j ) {
625  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
626  for( size_t i=0UL; i<N; ++i )
627  {
628  const size_t j1( SO1 ? j : j+1UL );
629  const size_t j2( SO1 ? j+1UL : j );
630 
631  const BT vr1( vr[i+j*N] );
632  const BT vr2( vr[i+(j+1UL)*N] );
633 
634  ( SO2 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO2 ? vr2 : -vr2 ) );
635  ( SO2 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO2 ? -vr2 : vr2 ) );
636  }
637 
638  ++j;
639  }
640  else {
641  for( size_t i=0UL; i<N; ++i ) {
642  ( SO2 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
643  }
644  }
645  }
646 }
648 //*************************************************************************************************
649 
650 
651 //*************************************************************************************************
669 template< typename MT1 // Type of the matrix A
670  , bool SO1 // Storage order of the matrix A
671  , typename VT // Type of the vector w
672  , bool TF // Transpose flag of the vector w
673  , typename MT2 // Type of the matrix VR
674  , bool SO2 > // Storage order of the matrix VR
677 {
678  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
679  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
680  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
681  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
682 
683  using CT = ElementType_<MT1>;
684  using BT = UnderlyingElement_<CT>;
685 
688 
689  int n ( numeric_cast<int>( (~A).rows() ) );
690  int lda ( numeric_cast<int>( (~A).spacing() ) );
691  int ldvr( numeric_cast<int>( (~VR).spacing() ) );
692  int info( 0 );
693 
694  int lwork( 2*n + 2 );
695  const std::unique_ptr<CT[]> work ( new CT[lwork] );
696  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
697 
698  geev( ( SO1 ? 'N' : 'V' ), ( SO1 ? 'V' : 'N' ), n, (~A).data(), lda, (~w).data(),
699  ( SO1 ? nullptr : (~VR).data() ), ( SO1 ? 1 : ldvr ),
700  ( SO1 ? (~VR).data() : nullptr ), ( SO1 ? ldvr : 1 ),
701  work.get(), lwork, rwork.get(), &info );
702 
703  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
704 
705  if( info > 0 ) {
706  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
707  }
708 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
782 template< typename MT1 // Type of the matrix A
783  , bool SO1 // Storage order of the matrix A
784  , typename VT // Type of the vector w
785  , bool TF // Transpose flag of the vector w
786  , typename MT2 // Type of the matrix VR
787  , bool SO2 > // Storage order of the matrix VR
789 {
794 
799 
805 
806  const size_t N( (~A).rows() );
807 
808  if( !isSquare( ~A ) ) {
809  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
810  }
811 
812  resize( ~w, N, false );
813  resize( ~VR, N, N, false );
814 
815  if( N == 0UL ) {
816  return;
817  }
818 
819  geev_backend( ~A, ~w, ~VR );
820 }
821 //*************************************************************************************************
822 
823 
824 //*************************************************************************************************
843 template< typename MT1 // Type of the matrix A
844  , bool SO1 // Storage order of the matrix A
845  , typename MT2 // Type of the matrix VL
846  , bool SO2 // Storage order of the matrix VL
847  , typename VT // Type of the vector w
848  , bool TF // Transpose flag of the vector w
849  , typename MT3 // Type of the matrix VR
850  , bool SO3 > // Storage order of the matrix VR
852  geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
854 {
855  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
856  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
857  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
858  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
859  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
860  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
861 
862  using CT = ElementType_<VT>;
863  using BT = ElementType_<MT1>;
864 
867 
868  int n ( numeric_cast<int>( (~A).rows() ) );
869  int lda ( numeric_cast<int>( (~A).spacing() ) );
870  int info( 0 );
871 
872  int lwork( 4*n + 2 );
873  const std::unique_ptr<BT[]> vl ( new BT[n*n] );
874  const std::unique_ptr<BT[]> vr ( new BT[n*n] );
875  const std::unique_ptr<BT[]> wr ( new BT[n] );
876  const std::unique_ptr<BT[]> wi ( new BT[n] );
877  const std::unique_ptr<BT[]> work( new BT[lwork] );
878 
879  geev( 'V', 'V', n, (~A).data(), lda, wr.get(), wi.get(),
880  ( SO1 ? vl.get() : vr.get() ), n, ( SO1 ? vr.get() : vl.get() ), n,
881  work.get(), lwork, &info );
882 
883  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
884 
885  if( info > 0 ) {
886  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
887  }
888 
889  const size_t N( (~A).rows() );
890 
891  for( size_t j=0UL; j<N; ++j ) {
892  (~w)[j] = CT( wr[j], wi[j] );
893  }
894 
895  for( size_t j=0UL; j<N; ++j ) {
896  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
897  for( size_t i=0UL; i<N; ++i )
898  {
899  const size_t j1( SO1 ? j : j+1UL );
900  const size_t j2( SO1 ? j+1UL : j );
901 
902  const BT vl1( vl[i+j*N] );
903  const BT vl2( vl[i+(j+1UL)*N] );
904  const BT vr1( vr[i+j*N] );
905  const BT vr2( vr[i+(j+1UL)*N] );
906 
907  ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
908  ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
909  ( SO3 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO3 ? vr2 : -vr2 ) );
910  ( SO3 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO3 ? -vr2 : vr2 ) );
911  }
912 
913  ++j;
914  }
915  else {
916  for( size_t i=0UL; i<N; ++i ) {
917  ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
918  ( SO3 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
919  }
920  }
921  }
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
946 template< typename MT1 // Type of the matrix A
947  , bool SO1 // Storage order of the matrix A
948  , typename MT2 // Type of the matrix VL
949  , bool SO2 // Storage order of the matrix VL
950  , typename VT // Type of the vector w
951  , bool TF // Transpose flag of the vector w
952  , typename MT3 // Type of the matrix VR
953  , bool SO3 > // Storage order of the matrix VR
955  geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
957 {
958  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
959  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
960  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
961  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
962  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
963  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
964 
965  using CT = ElementType_<MT1>;
966  using BT = UnderlyingElement_<CT>;
967 
970 
971  int n ( numeric_cast<int>( (~A).rows() ) );
972  int lda ( numeric_cast<int>( (~A).spacing() ) );
973  int ldvl( numeric_cast<int>( (~VL).spacing() ) );
974  int ldvr( numeric_cast<int>( (~VR).spacing() ) );
975  int info( 0 );
976 
977  int lwork( 2*n + 2 );
978  const std::unique_ptr<CT[]> work ( new CT[lwork] );
979  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
980 
981  geev( 'V', 'V', n, (~A).data(), lda, (~w).data(),
982  ( SO1 ? (~VL).data() : (~VR).data() ), ( SO1 ? ldvl : ldvr ),
983  ( SO1 ? (~VR).data() : (~VL).data() ), ( SO1 ? ldvr : ldvl ),
984  work.get(), lwork, rwork.get(), &info );
985 
986  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
987 
988  if( info > 0 ) {
989  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
990  }
991 }
993 //*************************************************************************************************
994 
995 
996 //*************************************************************************************************
1074 template< typename MT1 // Type of the matrix A
1075  , bool SO1 // Storage order of the matrix A
1076  , typename MT2 // Type of the matrix VL
1077  , bool SO2 // Storage order of the matrix VL
1078  , typename VT // Type of the vector w
1079  , bool TF // Transpose flag of the vector w
1080  , typename MT3 // Type of the matrix VR
1081  , bool SO3 > // Storage order of the matrix VR
1084 {
1089 
1095 
1100 
1106 
1107  const size_t N( (~A).rows() );
1108 
1109  if( !isSquare( ~A ) ) {
1110  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
1111  }
1112 
1113  resize( ~w, N, false );
1114  resize( ~VL, N, N, false );
1115  resize( ~VR, N, N, false );
1116 
1117  if( N == 0UL ) {
1118  return;
1119  }
1120 
1121  geev_backend( ~A, ~VL, ~w, ~VR );
1122 }
1123 //*************************************************************************************************
1124 
1125 } // namespace blaze
1126 
1127 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to m...
Definition: MutableDataAccess.h:61
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
Constraint on the data type.
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the DenseVector base class.
Header file for the UnderlyingElement type trait.
Constraint on the data type.
Cast operators for numeric types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE(T)
Constraint on the data type.In case the given data type T is an adaptor type (as for instance LowerMa...
Definition: Adaptor.h:81
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Constraint on the data type.
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void geev(char jobvl, char jobvr, int n, float *A, int lda, float *wr, float *wi, float *VL, int ldvl, float *VR, int ldvr, float *work, int lwork, int *info)
LAPACK kernel for computing the eigenvalues of the given dense general single precision column-major ...
Definition: geev.h:163
Header file for the DenseMatrix base class.
typename UnderlyingElement< T >::Type UnderlyingElement_
Auxiliary alias declaration for the UnderlyingElement type trait.The UnderlyingElement_ alias declara...
Definition: UnderlyingElement.h:132
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Header file for the equal shim.
Header file for the exception macros of the math module.
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:714
Constraint on the data type.
Header file for the EnableIf class template.
Header file for run time assertion macros.
#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:61
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
#define BLAZE_CONSTRAINT_MUST_BE_BUILTIN_TYPE(T)
Constraint on the data type.In case the given data type T is not a built-in data type, a compilation error is created.
Definition: Builtin.h:60
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
#define BLAZE_CONSTRAINT_MUST_BE_COMPLEX_TYPE(T)
Constraint on the data type.This compile time constraint checks that the given data type T is a compl...
Definition: Complex.h:62
#define BLAZE_THROW_LAPACK_ERROR(MESSAGE)
Macro for the emission of an exception on detection of a LAPACK error.This macro encapsulates the def...
Definition: Exception.h:146
Header file for the IsComplex type trait.
Header file for the complex data type.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the IsResizable 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
Constraint on the data type.
Header file for the CLAPACK geev wrapper functions.