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 <boost/cast.hpp>
45 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
54 #include <blaze/math/shims/Equal.h>
57 #include <blaze/util/Assert.h>
58 #include <blaze/util/Complex.h>
61 #include <blaze/util/DisableIf.h>
62 #include <blaze/util/EnableIf.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  using boost::numeric_cast;
118 
119  BLAZE_INTERNAL_ASSERT( isSquare( ~A ), "Invalid non-square matrix detected" );
120  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
121 
122  using CT = ElementType_<VT>;
123  using BT = ElementType_<MT>;
124 
127 
128  int n ( numeric_cast<int>( (~A).rows() ) );
129  int lda ( numeric_cast<int>( (~A).spacing() ) );
130  int info( 0 );
131 
132  int lwork( 3*n + 2 );
133  const std::unique_ptr<BT[]> wr ( new BT[n] );
134  const std::unique_ptr<BT[]> wi ( new BT[n] );
135  const std::unique_ptr<BT[]> work( new BT[lwork] );
136 
137  geev( 'N', 'N', n, (~A).data(), lda, wr.get(), wi.get(),
138  nullptr, 1, nullptr, 1, work.get(), lwork, &info );
139 
140  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
141 
142  if( info > 0 ) {
143  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
144  }
145 
146  for( size_t i=0UL; i<(~A).rows(); ++i ) {
147  (~w)[i] = CT( wr[i], wi[i] );
148  }
149 }
151 //*************************************************************************************************
152 
153 
154 //*************************************************************************************************
171 template< typename MT // Type of the matrix A
172  , bool SO // Storage order of the matrix A
173  , typename VT // Type of the vector w
174  , bool TF > // Transpose flag of the vector w
175 inline EnableIf_< IsComplex< ElementType_<MT> > >
176  geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
177 {
178  using boost::numeric_cast;
179 
180  BLAZE_INTERNAL_ASSERT( isSquare( ~A ), "Invalid non-square matrix detected" );
181  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
182 
183  using CT = ElementType_<MT>;
184  using BT = UnderlyingElement_<CT>;
185 
188 
189  int n ( numeric_cast<int>( (~A).rows() ) );
190  int lda ( numeric_cast<int>( (~A).spacing() ) );
191  int info( 0 );
192 
193  int lwork( 2*n + 2 );
194  const std::unique_ptr<CT[]> work ( new CT[lwork] );
195  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
196 
197  geev( 'N', 'N', n, (~A).data(), lda, (~w).data(),
198  nullptr, 1, nullptr, 1, work.get(), lwork, rwork.get(), &info );
199 
200  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
201 
202  if( info > 0 ) {
203  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
204  }
205 }
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
265 template< typename MT // Type of the matrix A
266  , bool SO // Storage order of the matrix A
267  , typename VT // Type of the vector w
268  , bool TF > // Transpose flag of the vector w
270 {
275 
280 
281  const size_t N( (~A).rows() );
282 
283  if( !isSquare( ~A ) ) {
284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
285  }
286 
287  resize( ~w, N, false );
288 
289  if( N == 0UL ) {
290  return;
291  }
292 
293  geev_backend( ~A, ~w );
294 }
295 //*************************************************************************************************
296 
297 
298 //*************************************************************************************************
316 template< typename MT1 // Type of the matrix A
317  , bool SO1 // Storage order of the matrix A
318  , typename MT2 // Type of the matrix VL
319  , bool SO2 // Storage order of the matrix VL
320  , typename VT // Type of the vector w
321  , bool TF > // Transpose flag of the vector w
324 {
325  using boost::numeric_cast;
326 
327  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
328  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
329  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
330  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
331 
332  using CT = ElementType_<VT>;
333  using BT = ElementType_<MT1>;
334 
337 
338  int n ( numeric_cast<int>( (~A).rows() ) );
339  int lda ( numeric_cast<int>( (~A).spacing() ) );
340  int info( 0 );
341 
342  int lwork( 4*n + 2 );
343  const std::unique_ptr<BT[]> vl ( new BT[n*n] );
344  const std::unique_ptr<BT[]> wr ( new BT[n] );
345  const std::unique_ptr<BT[]> wi ( new BT[n] );
346  const std::unique_ptr<BT[]> work( new BT[lwork] );
347 
348  geev( ( SO1 ? 'V' : 'N' ), ( SO1 ? 'N' : 'V' ), n, (~A).data(), lda, wr.get(), wi.get(),
349  ( SO1 ? vl.get() : nullptr ), ( SO1 ? n : 1 ),
350  ( SO1 ? nullptr : vl.get() ), ( SO1 ? 1 : n ),
351  work.get(), lwork, &info );
352 
353  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
354 
355  if( info > 0 ) {
356  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
357  }
358 
359  const size_t N( (~A).rows() );
360 
361  for( size_t j=0UL; j<N; ++j ) {
362  (~w)[j] = CT( wr[j], wi[j] );
363  }
364 
365  for( size_t j=0UL; j<N; ++j ) {
366  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
367  for( size_t i=0UL; i<N; ++i )
368  {
369  const size_t j1( SO1 ? j : j+1UL );
370  const size_t j2( SO1 ? j+1UL : j );
371 
372  const BT vl1( vl[i+j*N] );
373  const BT vl2( vl[i+(j+1UL)*N] );
374 
375  ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
376  ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
377  }
378 
379  ++j;
380  }
381  else {
382  for( size_t i=0UL; i<N; ++i ) {
383  ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
384  }
385  }
386  }
387 }
389 //*************************************************************************************************
390 
391 
392 //*************************************************************************************************
410 template< typename MT1 // Type of the matrix A
411  , bool SO1 // Storage order of the matrix A
412  , typename MT2 // Type of the matrix VL
413  , bool SO2 // Storage order of the matrix VL
414  , typename VT // Type of the vector w
415  , bool TF > // Transpose flag of the vector w
418 {
419  using boost::numeric_cast;
420 
421  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
422  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
423  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
424  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
425 
426  using CT = ElementType_<MT1>;
427  using BT = UnderlyingElement_<CT>;
428 
431 
432  int n ( numeric_cast<int>( (~A).rows() ) );
433  int lda ( numeric_cast<int>( (~A).spacing() ) );
434  int ldvl( numeric_cast<int>( (~VL).spacing() ) );
435  int info( 0 );
436 
437  int lwork( 2*n + 2 );
438  const std::unique_ptr<CT[]> work ( new CT[lwork] );
439  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
440 
441  geev( ( SO1 ? 'V' : 'N' ), ( SO1 ? 'N' : 'V' ), n, (~A).data(), lda, (~w).data(),
442  ( SO1 ? (~VL).data() : nullptr ), ( SO1 ? ldvl : 1 ),
443  ( SO1 ? nullptr : (~VL).data() ), ( SO1 ? 1 : ldvl ),
444  work.get(), lwork, rwork.get(), &info );
445 
446  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
447 
448  if( info > 0 ) {
449  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
450  }
451 }
453 //*************************************************************************************************
454 
455 
456 //*************************************************************************************************
525 template< typename MT1 // Type of the matrix A
526  , bool SO1 // Storage order of the matrix A
527  , typename MT2 // Type of the matrix VL
528  , bool SO2 // Storage order of the matrix VL
529  , typename VT // Type of the vector w
530  , bool TF > // Transpose flag of the vector w
532 {
537 
543 
548 
549  const size_t N( (~A).rows() );
550 
551  if( !isSquare( ~A ) ) {
552  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
553  }
554 
555  resize( ~w, N, false );
556  resize( ~VL, N, N, false );
557 
558  if( N == 0UL ) {
559  return;
560  }
561 
562  geev_backend( ~A, ~VL, ~w );
563 }
564 //*************************************************************************************************
565 
566 
567 //*************************************************************************************************
585 template< typename MT1 // Type of the matrix A
586  , bool SO1 // Storage order of the matrix A
587  , typename VT // Type of the vector w
588  , bool TF // Transpose flag of the vector w
589  , typename MT2 // Type of the matrix VR
590  , bool SO2 > // Storage order of the matrix VR
593 {
594  using boost::numeric_cast;
595 
596  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
597  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
598  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
599  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
600 
601  using CT = ElementType_<VT>;
602  using BT = ElementType_<MT1>;
603 
606 
607  int n ( numeric_cast<int>( (~A).rows() ) );
608  int lda ( numeric_cast<int>( (~A).spacing() ) );
609  int info( 0 );
610 
611  int lwork( 4*n + 2 );
612  const std::unique_ptr<BT[]> vr ( new BT[n*n] );
613  const std::unique_ptr<BT[]> wr ( new BT[n] );
614  const std::unique_ptr<BT[]> wi ( new BT[n] );
615  const std::unique_ptr<BT[]> work( new BT[lwork] );
616 
617  geev( ( SO1 ? 'N' : 'V' ), ( SO1 ? 'V' : 'N' ), n, (~A).data(), lda, wr.get(), wi.get(),
618  ( SO1 ? nullptr : vr.get() ), ( SO1 ? 1 : n ),
619  ( SO1 ? vr.get() : nullptr ), ( SO1 ? n : 1 ),
620  work.get(), lwork, &info );
621 
622  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
623 
624  if( info > 0 ) {
625  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
626  }
627 
628  const size_t N( (~A).rows() );
629 
630  for( size_t j=0UL; j<N; ++j ) {
631  (~w)[j] = CT( wr[j], wi[j] );
632  }
633 
634  for( size_t j=0UL; j<N; ++j ) {
635  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
636  for( size_t i=0UL; i<N; ++i )
637  {
638  const size_t j1( SO1 ? j : j+1UL );
639  const size_t j2( SO1 ? j+1UL : j );
640 
641  const BT vr1( vr[i+j*N] );
642  const BT vr2( vr[i+(j+1UL)*N] );
643 
644  ( SO2 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO2 ? vr2 : -vr2 ) );
645  ( SO2 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO2 ? -vr2 : vr2 ) );
646  }
647 
648  ++j;
649  }
650  else {
651  for( size_t i=0UL; i<N; ++i ) {
652  ( SO2 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
653  }
654  }
655  }
656 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
679 template< typename MT1 // Type of the matrix A
680  , bool SO1 // Storage order of the matrix A
681  , typename VT // Type of the vector w
682  , bool TF // Transpose flag of the vector w
683  , typename MT2 // Type of the matrix VR
684  , bool SO2 > // Storage order of the matrix VR
687 {
688  using boost::numeric_cast;
689 
690  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
691  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
692  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
693  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
694 
695  using CT = ElementType_<MT1>;
696  using BT = UnderlyingElement_<CT>;
697 
700 
701  int n ( numeric_cast<int>( (~A).rows() ) );
702  int lda ( numeric_cast<int>( (~A).spacing() ) );
703  int ldvr( numeric_cast<int>( (~VR).spacing() ) );
704  int info( 0 );
705 
706  int lwork( 2*n + 2 );
707  const std::unique_ptr<CT[]> work ( new CT[lwork] );
708  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
709 
710  geev( ( SO1 ? 'N' : 'V' ), ( SO1 ? 'V' : 'N' ), n, (~A).data(), lda, (~w).data(),
711  ( SO1 ? nullptr : (~VR).data() ), ( SO1 ? 1 : ldvr ),
712  ( SO1 ? (~VR).data() : nullptr ), ( SO1 ? ldvr : 1 ),
713  work.get(), lwork, rwork.get(), &info );
714 
715  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
716 
717  if( info > 0 ) {
718  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
719  }
720 }
722 //*************************************************************************************************
723 
724 
725 //*************************************************************************************************
794 template< typename MT1 // Type of the matrix A
795  , bool SO1 // Storage order of the matrix A
796  , typename VT // Type of the vector w
797  , bool TF // Transpose flag of the vector w
798  , typename MT2 // Type of the matrix VR
799  , bool SO2 > // Storage order of the matrix VR
801 {
806 
811 
817 
818  const size_t N( (~A).rows() );
819 
820  if( !isSquare( ~A ) ) {
821  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
822  }
823 
824  resize( ~w, N, false );
825  resize( ~VR, N, N, false );
826 
827  if( N == 0UL ) {
828  return;
829  }
830 
831  geev_backend( ~A, ~w, ~VR );
832 }
833 //*************************************************************************************************
834 
835 
836 //*************************************************************************************************
855 template< typename MT1 // Type of the matrix A
856  , bool SO1 // Storage order of the matrix A
857  , typename MT2 // Type of the matrix VL
858  , bool SO2 // Storage order of the matrix VL
859  , typename VT // Type of the vector w
860  , bool TF // Transpose flag of the vector w
861  , typename MT3 // Type of the matrix VR
862  , bool SO3 > // Storage order of the matrix VR
864  geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
866 {
867  using boost::numeric_cast;
868 
869  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
870  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
871  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
872  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
873  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
874  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
875 
876  using CT = ElementType_<VT>;
877  using BT = ElementType_<MT1>;
878 
881 
882  int n ( numeric_cast<int>( (~A).rows() ) );
883  int lda ( numeric_cast<int>( (~A).spacing() ) );
884  int info( 0 );
885 
886  int lwork( 4*n + 2 );
887  const std::unique_ptr<BT[]> vl ( new BT[n*n] );
888  const std::unique_ptr<BT[]> vr ( new BT[n*n] );
889  const std::unique_ptr<BT[]> wr ( new BT[n] );
890  const std::unique_ptr<BT[]> wi ( new BT[n] );
891  const std::unique_ptr<BT[]> work( new BT[lwork] );
892 
893  geev( 'V', 'V', n, (~A).data(), lda, wr.get(), wi.get(),
894  ( SO1 ? vl.get() : vr.get() ), n, ( SO1 ? vr.get() : vl.get() ), n,
895  work.get(), lwork, &info );
896 
897  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
898 
899  if( info > 0 ) {
900  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
901  }
902 
903  const size_t N( (~A).rows() );
904 
905  for( size_t j=0UL; j<N; ++j ) {
906  (~w)[j] = CT( wr[j], wi[j] );
907  }
908 
909  for( size_t j=0UL; j<N; ++j ) {
910  if( j+1UL < N && equal( (~w)[j], conj( (~w)[j+1UL] ) ) ) {
911  for( size_t i=0UL; i<N; ++i )
912  {
913  const size_t j1( SO1 ? j : j+1UL );
914  const size_t j2( SO1 ? j+1UL : j );
915 
916  const BT vl1( vl[i+j*N] );
917  const BT vl2( vl[i+(j+1UL)*N] );
918  const BT vr1( vr[i+j*N] );
919  const BT vr2( vr[i+(j+1UL)*N] );
920 
921  ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
922  ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
923  ( SO3 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO3 ? vr2 : -vr2 ) );
924  ( SO3 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO3 ? -vr2 : vr2 ) );
925  }
926 
927  ++j;
928  }
929  else {
930  for( size_t i=0UL; i<N; ++i ) {
931  ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
932  ( SO3 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
933  }
934  }
935  }
936 }
938 //*************************************************************************************************
939 
940 
941 //*************************************************************************************************
960 template< typename MT1 // Type of the matrix A
961  , bool SO1 // Storage order of the matrix A
962  , typename MT2 // Type of the matrix VL
963  , bool SO2 // Storage order of the matrix VL
964  , typename VT // Type of the vector w
965  , bool TF // Transpose flag of the vector w
966  , typename MT3 // Type of the matrix VR
967  , bool SO3 > // Storage order of the matrix VR
969  geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
971 {
972  using boost::numeric_cast;
973 
974  BLAZE_INTERNAL_ASSERT( isSquare( ~A ) , "Invalid non-square matrix detected" );
975  BLAZE_INTERNAL_ASSERT( isSquare( ~VL ), "Invalid non-square matrix detected" );
976  BLAZE_INTERNAL_ASSERT( isSquare( ~VR ), "Invalid non-square matrix detected" );
977  BLAZE_INTERNAL_ASSERT( (~VL).rows() == (~A).rows(), "Invalid matrix dimension detected" );
978  BLAZE_INTERNAL_ASSERT( (~VR).rows() == (~A).rows(), "Invalid matrix dimension detected" );
979  BLAZE_INTERNAL_ASSERT( (~w).size() == (~A).rows(), "Invalid vector dimension detected" );
980 
981  using CT = ElementType_<MT1>;
982  using BT = UnderlyingElement_<CT>;
983 
986 
987  int n ( numeric_cast<int>( (~A).rows() ) );
988  int lda ( numeric_cast<int>( (~A).spacing() ) );
989  int ldvl( numeric_cast<int>( (~VL).spacing() ) );
990  int ldvr( numeric_cast<int>( (~VR).spacing() ) );
991  int info( 0 );
992 
993  int lwork( 2*n + 2 );
994  const std::unique_ptr<CT[]> work ( new CT[lwork] );
995  const std::unique_ptr<BT[]> rwork( new BT[2*n] );
996 
997  geev( 'V', 'V', n, (~A).data(), lda, (~w).data(),
998  ( SO1 ? (~VL).data() : (~VR).data() ), ( SO1 ? ldvl : ldvr ),
999  ( SO1 ? (~VR).data() : (~VL).data() ), ( SO1 ? ldvr : ldvl ),
1000  work.get(), lwork, rwork.get(), &info );
1001 
1002  BLAZE_INTERNAL_ASSERT( info >= 0, "Invalid argument for eigenvalue computation" );
1003 
1004  if( info > 0 ) {
1005  BLAZE_THROW_LAPACK_ERROR( "Eigenvalue computation failed" );
1006  }
1007 }
1009 //*************************************************************************************************
1010 
1011 
1012 //*************************************************************************************************
1090 template< typename MT1 // Type of the matrix A
1091  , bool SO1 // Storage order of the matrix A
1092  , typename MT2 // Type of the matrix VL
1093  , bool SO2 // Storage order of the matrix VL
1094  , typename VT // Type of the vector w
1095  , bool TF // Transpose flag of the vector w
1096  , typename MT3 // Type of the matrix VR
1097  , bool SO3 > // Storage order of the matrix VR
1100 {
1105 
1111 
1116 
1122 
1123  const size_t N( (~A).rows() );
1124 
1125  if( !isSquare( ~A ) ) {
1126  BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
1127  }
1128 
1129  resize( ~w, N, false );
1130  resize( ~VL, N, N, false );
1131  resize( ~VR, N, N, false );
1132 
1133  if( N == 0UL ) {
1134  return;
1135  }
1136 
1137  geev_backend( ~A, ~VL, ~w, ~VR );
1138 }
1139 //*************************************************************************************************
1140 
1141 } // namespace blaze
1142 
1143 #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.
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:102
const DMatForEachExpr< MT, Conj, SO > conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatForEachExpr.h:1214
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:261
#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:223
Header file for the DenseVector base class.
Header file for the UnderlyingElement type trait.
Constraint on the data type.
#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:71
Constraint on the data type.
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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:161
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:133
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:70
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:544
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:223
#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:320
#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.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
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.