Menu

Can't read complex 64 bit ints with Octave?

2016-07-26
2016-08-24
  • John Cognetti

    John Cognetti - 2016-07-26

    I modified the sample program from section 2.3.1, Writing numeric arrays, of the documentation to write int64_t (MAT_T_INT64) to a file. Upon reading the file from Octave, I get the error:

    error: load: reading imaginary matrix data for 'z'

    Is anyone else having this problem? Is this just a problem with Octave?

     

    Last edit: John Cognetti 2016-07-26
  • tbeu

    tbeu - 2016-07-30

    Can you please attach the created MAT file and the modified sample code here. Thanks.

     
  • tbeu

    tbeu - 2016-08-02

    Sorry, cannot reproduce.

     
  • John Cognetti

    John Cognetti - 2016-08-02

    Sorry for the delay. Here's the source code, a screenshot of the error from Octave, and the mat file that was produced by the code.

    #include <stdlib.h>
    #include <stdio.h>
    #include "matio.h"
    #include <stdint.h>
    
    int
    main(int argc,char **argv)
    {
        mat_t    *matfp;
        matvar_t *matvar;
        size_t    dims[2] = {10,1};
        int64_t   x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10},
                  y[10] = {11,12,13,14,15,16,17,18,19,20};
        struct mat_complex_split_t z = {x,y};
    
        matfp = Mat_CreateVer("test.mat",NULL,MAT_FT_DEFAULT);
        if ( NULL == matfp ) {
            fprintf(stderr,"Error creating MAT file \"test.mat\"\n");
            return EXIT_FAILURE;
        }
    
        matvar = Mat_VarCreate("x",MAT_C_INT64,MAT_T_INT64,2,dims,x,0);
        if ( NULL == matvar ) {
            fprintf(stderr,"Error creating variable for 'x'\n");
        } else {
            Mat_VarWrite(matfp,matvar,MAT_COMPRESSION_NONE);
            Mat_VarFree(matvar);
        }
    
        matvar = Mat_VarCreate("y",MAT_C_INT64,MAT_T_INT64,2,dims,y,0);
        if ( NULL == matvar ) {
            fprintf(stderr,"Error creating variable for 'y'\n");
        } else {
            Mat_VarWrite(matfp,matvar,MAT_COMPRESSION_NONE);
            Mat_VarFree(matvar);
        }
    
        matvar = Mat_VarCreate("z",MAT_C_INT64,MAT_T_INT64,2,dims,&z,
                     MAT_F_COMPLEX);
        if ( NULL == matvar ) {
            fprintf(stderr,"Error creating variable for 'z'\n");
        } else {
            Mat_VarWrite(matfp,matvar,MAT_COMPRESSION_NONE);
            Mat_VarFree(matvar);
        }
    
        Mat_Close(matfp);
        return EXIT_SUCCESS;
    }
    
     

    Last edit: John Cognetti 2016-08-02
  • tbeu

    tbeu - 2016-08-02

    Well, test.mat is a valid v5 MAT file that both MATLAB and matio/matdump 1.5.8 are able to load/read. I am afraid you need to ask Octave developers why it cannot be read. It is likely that Octave links to an outdated libmatio which could not read such complex int64 arrays.

     
  • John Cognetti

    John Cognetti - 2016-08-02

    Will do, thanks for the help. :-)

     
  • tbeu

    tbeu - 2016-08-24

    Any news from the Octave team?

     

Log in to post a comment.