Glibc error for dgesvd

Glibc error for dgesvd

Hi, I am using MKL to compute SVD of a real matrix. I use C++ code with std::vectors. Here is a portion of my code related to SVD

void Decompose_InterpolMatrix_To_SVD(int rows, int columns, std::vector<double> &Interp_matrix) {
        /* Locals */
        int m = rows, n = columns, lda = m, ldu = m, ldvt = m, info, lwork;
        int i,j,k;

        double wkopt;
        double* work;
        double *a,alpha=1.0e0,beta=0.0e0,tausq=1.0e-4;
        //double s[columns], u[rows*rows], vt[columns*columns];
        std::vector<double> u, s, vt;

        a = &(Interp_matrix[0]);

        double *vtran;
        vtran = &(vt[0]);

        /* Query and allocate the optimal workspace */
        lwork = -1;
        dgesvd( "All", "All", &m, &n, a, &lda, &(s[0]), &(u[0]), &ldu, &(vt[0]), &ldvt, &wkopt, &lwork,
         &info );
        lwork = (int)wkopt;
        work = (double*)malloc( lwork*sizeof(double) );
        /* Compute SVD */
        dgesvd( "All", "All", &m, &n, a, &lda, &(s[0]), &(u[0]), &ldu, &(vt[0]), &ldvt, work, &lwork,
         &info );
        /* Check for convergence */
        if( info > 0 ) {
                std::cerr << "The algorithm computing SVD failed to converge." << std::endl;
                exit( 1 );

        /* Free workspace */
        free( (void*)work );


When I run this code I get :

*** glibc detected *** ./checkmkl1: munmap_chunk(): invalid pointer: 0x000000001a43e610 ***
======= Backtrace: =========

      I do not get this error when I declare s,u,vt as proper arrays. This is strange as one can use vectors of primitive types as arrays. Any help is greatly appreciated.


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi. Sorry for the false alarm. I gave ldvt a value of m instead of n.

Leave a Comment

Please sign in to add a comment. Not a member? Join today