MXCREATEDOUBLEMATRIX memory overflow error

2 visualizaciones (últimos 30 días)
Lukas Bystricky
Lukas Bystricky el 3 de Abr. de 2020
Editada: James Tursa el 8 de Dic. de 2021
I have a mex file which calls MXCREATEDOUBLEMATRIX, for example
PLHS(1) = MXCREATEDOUBLEMATRIX(100,1,0)
At this line Matlab gives the error
Requested 4703255833574637668x429496729601 (17179869184.0GB) array exceeds maximum array size preference.
Obviously that's not what I actually want to request. What might be causing this?
For reference I am using Matlab 2018a on Ubuntu 16.04. The mex file is a Fortran file and I've linked it with the gfortran, iomp5, irc, svml, and imf libraries.

Respuestas (1)

James Tursa
James Tursa el 8 de Dic. de 2021
Editada: James Tursa el 8 de Dic. de 2021
Rather later for an Answer, but here goes anyway:
You should never use literal integers for API calls, because you can't be sure the default literal integer size is the same as the integer size that the API routines expect. Always use typed variables that match the API doc exactly. E.g., here is the signaure from the doc:
mwPointer mxCreateDoubleMatrix(m, n, ComplexFlag)
mwSize m, n
integer*4 ComplexFlag
so the code sould be something like
mwSize m, n
integer*4 ComplexFlag
m = 100
n = 1
ComplexFlag = 0
plhs(1) = mxCreateDoubleMatrix(m,n,ComplexFlag)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by