/* Example program to demonstrate that returns different results for 32- vs. 64-bit ABI. The 32-bit program returns ================================================== Hexadecimal Complex Floating Point Eigenvalues Real Imaginary 3FF0000000000004 40158A68A4A8D9F7 3FF0000000000004 C0158A68A4A8D9F7 3FEFFFFFFFFFFFFC 40158A68A4A8D9F3 3FEFFFFFFFFFFFFC C0158A68A4A8D9F3 Decimal Complex Floating Point Eigenvalues Real Imaginary 1.00000000000000090 5.38516480713450730 1.00000000000000090 -5.38516480713450730 0.99999999999999956 5.38516480713450370 0.99999999999999956 -5.38516480713450370 ================================================== For some reason (library problems?), I can't get the 64-bit version to run (I trust you won't have the same problem). I have good reason to believe (from the source that demonstrated the problem in the first place) that the 64-bit program would return ================================================== Hexadecimal Complex Floating Point Eigenvalues Real Imaginary 3FF0000000000000 40158A68A4A8D9F4 3FF0000000000000 C0158A68A4A8D9F4 3FF0000000000000 40158A68A4A8D9F4 3FF0000000000000 C0158A68A4A8D9F4 Decimal Complex Floating Point Eigenvalues Real Imaginary 1.00000000000000000 5.38516480713450500 1.00000000000000000 -5.38516480713450500 1.00000000000000000 5.38516480713450500 1.00000000000000000 -5.38516480713450500 ================================================== Bob Smith bsmith@sudleyplace.com */ #define EQ == #define NE != #include #include //*************************************************************************** // $MyGsl_error_handler //*************************************************************************** void MyGsl_error_handler (const char *reason, const char *file, int line, int gsl_errno) { printf ("***Error handler called***\r\n"); printf ("reason = %s\r\n", reason); printf ("file = %s\r\n", file); printf ("line = %d\r\n", line); printf ("gsl_errno = %d\r\n", gsl_errno); } // End MyGsl_error_handler //*************************************************************************** // Main function //*************************************************************************** int main (void *argv[], int argc) { int N = 4, // Dimension i, j, // Loop counters iRet = 0, // Return code ErrCode; // Error code gsl_matrix *lpGslMatrixA = NULL; // GSL Temp gsl_vector_complex *lpGslCVectorEval = NULL; // Eigenvalues gsl_eigen_nonsymm_workspace *lpGslEigenWs = NULL; // Ptr to the GSL workspace double MatrixA[4][4] = // Matrix representation of the Quaternion 1i2j3k4 { { 1, -2, -3, -4}, { 2, 1, -4, 3}, { 3, 4, 1, -2}, { 4, -3, 2, 1}, }; // Set an error handler gsl_set_error_handler (MyGsl_error_handler); // Allocate the GSL temps lpGslMatrixA = gsl_matrix_alloc (N, N); lpGslCVectorEval = gsl_vector_complex_alloc (N); lpGslEigenWs = gsl_eigen_nonsymm_alloc (N); if (lpGslMatrixA EQ NULL || GSL_ENOMEM EQ (size_t) lpGslMatrixA || lpGslCVectorEval EQ NULL || GSL_ENOMEM EQ (size_t) lpGslCVectorEval || lpGslEigenWs EQ NULL || GSL_ENOMEM EQ (size_t) lpGslEigenWs ) goto WSFULL_EXIT; // Copy the data to the GSL matrix memcpy (lpGslMatrixA->data, &MatrixA[0][0], sizeof (MatrixA)); // Calculate the Eigenvalues ErrCode = gsl_eigen_nonsymm (lpGslMatrixA, lpGslCVectorEval, lpGslEigenWs); // Check the error code if (ErrCode NE GSL_SUCCESS) goto GSL_EXIT; // Format the result printf ("Hexadecimal Complex Floating Point Eigenvalues\r\n" " Real Imaginary\r\n" "%19llX %20llX\r\n" "%19llX %20llX\r\n" "%19llX %20llX\r\n" "%19llX %20llX\r\n", lpGslCVectorEval->data[0], lpGslCVectorEval->data[1], lpGslCVectorEval->data[2], lpGslCVectorEval->data[3], lpGslCVectorEval->data[4], lpGslCVectorEval->data[5], lpGslCVectorEval->data[6], lpGslCVectorEval->data[7]); printf ("\r\nDecimal Complex Floating Point Eigenvalues\r\n" " Real Imaginary\r\n" "% 20.17f % 20.17f\r\n" "% 20.17f % 20.17f\r\n" "% 20.17f % 20.17f\r\n" "% 20.17f % 20.17f\r\n", lpGslCVectorEval->data[0], lpGslCVectorEval->data[1], lpGslCVectorEval->data[2], lpGslCVectorEval->data[3], lpGslCVectorEval->data[4], lpGslCVectorEval->data[5], lpGslCVectorEval->data[6], lpGslCVectorEval->data[7]); goto NORMAL_EXIT; GSL_EXIT: printf ("Unable to calculate "); iRet = 2; goto ERROR_EXIT; WSFULL_EXIT: printf ("Unable to allocate the GSL temps"); iRet = 1; goto ERROR_EXIT; ERROR_EXIT: NORMAL_EXIT: if (lpGslEigenWs NE NULL) { gsl_eigen_nonsymm_free (lpGslEigenWs); lpGslEigenWs = NULL; } // End IF if (lpGslCVectorEval NE NULL) { // We no longer need this storage and ptr gsl_vector_complex_free (lpGslCVectorEval); lpGslCVectorEval = NULL; } // End IF if (lpGslMatrixA NE NULL) { // We no longer need this storage and ptr gsl_matrix_free (lpGslMatrixA); lpGslMatrixA = NULL; } // End IF return iRet; } // End main