Visible to Intel only — GUID: GUID-F60636FB-8605-4348-B731-155CB033FF5E
LAPACKE_zgeev Example Program in C for Column Major Data Layout
/******************************************************************************* * Copyright (C) 2009-2015 Intel Corporation. All Rights Reserved. * The information and material ("Material") provided below is owned by Intel * Corporation or its suppliers or licensors, and title to such Material remains * with Intel Corporation or its suppliers or licensors. The Material contains * proprietary information of Intel or its suppliers and licensors. The Material * is protected by worldwide copyright laws and treaty provisions. No part of * the Material may be copied, reproduced, published, uploaded, posted, * transmitted, or distributed in any way without Intel's prior express written * permission. No license under any patent, copyright or other intellectual * property rights in the Material is granted to or conferred upon you, either * expressly, by implication, inducement, estoppel or otherwise. Any license * under such intellectual property rights must be express and approved by Intel * in writing. * ******************************************************************************** */ /* LAPACKE_zgeev Example. ====================== Program computes the eigenvalues and left and right eigenvectors of a general rectangular matrix A: ( -3.84, 2.25) ( -8.94, -4.75) ( 8.95, -6.53) ( -9.87, 4.82) ( -0.66, 0.83) ( -4.40, -3.82) ( -3.50, -4.26) ( -3.15, 7.36) ( -3.99, -4.73) ( -5.88, -6.60) ( -3.36, -0.40) ( -0.75, 5.23) ( 7.74, 4.18) ( 3.66, -7.53) ( 2.58, 3.60) ( 4.59, 5.41) Description. ============ The routine computes for an n-by-n complex nonsymmetric matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors. The right eigenvector v(j) of A satisfies A*v(j)= lambda(j)*v(j) where lambda(j) is its eigenvalue. The left eigenvector u(j) of A satisfies u(j)H*A = lambda(j)*u(j)H where u(j)H denotes the conjugate transpose of u(j). The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real. Example Program Results. ======================== LAPACKE_zgeev (row-major, high-level) Example Program Results Eigenvalues ( -9.43,-12.98) ( -3.44, 12.69) ( 0.11, -3.40) ( 5.76, 7.13) Left eigenvectors ( 0.24, -0.18) ( 0.61, 0.00) ( -0.18, -0.33) ( 0.28, 0.09) ( 0.79, 0.00) ( -0.05, -0.27) ( 0.82, 0.00) ( -0.55, 0.16) ( 0.22, -0.27) ( -0.21, 0.53) ( -0.37, 0.15) ( 0.45, 0.09) ( -0.02, 0.41) ( 0.40, -0.24) ( 0.06, 0.12) ( 0.62, 0.00) Right eigenvectors ( 0.43, 0.33) ( 0.83, 0.00) ( 0.60, 0.00) ( -0.31, 0.03) ( 0.51, -0.03) ( 0.08, -0.25) ( -0.40, -0.20) ( 0.04, 0.34) ( 0.62, 0.00) ( -0.25, 0.28) ( -0.09, -0.48) ( 0.36, 0.06) ( -0.23, 0.11) ( -0.10, -0.32) ( -0.43, 0.13) ( 0.81, 0.00) */ #include <stdlib.h> #include <stdio.h> #include "mkl_lapacke.h" /* Auxiliary routines prototypes */ extern void print_matrix( char* desc, MKL_INT m, MKL_INT n, MKL_Complex16* a, MKL_INT lda ); /* Parameters */ #define N 4 #define LDA N #define LDVL N #define LDVR N /* Main program */ int main() { /* Locals */ MKL_INT n = N, lda = LDA, ldvl = LDVL, ldvr = LDVR, info; /* Local arrays */ MKL_Complex16 w[N], vl[LDVL*N], vr[LDVR*N]; MKL_Complex16 a[LDA*N] = { {-3.84, 2.25}, {-8.94, -4.75}, { 8.95, -6.53}, {-9.87, 4.82}, {-0.66, 0.83}, {-4.40, -3.82}, {-3.50, -4.26}, {-3.15, 7.36}, {-3.99, -4.73}, {-5.88, -6.60}, {-3.36, -0.40}, {-0.75, 5.23}, { 7.74, 4.18}, { 3.66, -7.53}, { 2.58, 3.60}, { 4.59, 5.41} }; /* Executable statements */ printf( "LAPACKE_zgeev (row-major, high-level) Example Program Results\n" ); /* Solve eigenproblem */ info = LAPACKE_zgeev( LAPACK_ROW_MAJOR, 'V', 'V', n, a, lda, w, vl, ldvl, vr, ldvr ); /* Check for convergence */ if( info > 0 ) { printf( "The algorithm failed to compute eigenvalues.\n" ); exit( 1 ); } /* Print eigenvalues */ print_matrix( "Eigenvalues", 1, n, w, 1 ); /* Print left eigenvectors */ print_matrix( "Left eigenvectors", n, n, vl, ldvl ); /* Print right eigenvectors */ print_matrix( "Right eigenvectors", n, n, vr, ldvr ); exit( 0 ); } /* End of LAPACKE_zgeev Example */ /* Auxiliary routine: printing a matrix */ void print_matrix( char* desc, MKL_INT m, MKL_INT n, MKL_Complex16* a, MKL_INT lda ) { MKL_INT i, j; printf( "\n %s\n", desc ); for( i = 0; i < m; i++ ) { for( j = 0; j < n; j++ ) printf( " (%6.2f,%6.2f)", a[i*lda+j].real, a[i*lda+j].imag ); printf( "\n" ); } }
Parent topic: ZGEEV Example