0
Solucionado
Errors converting from single complex to mp complex and back
I'm getting errors when I try to convert a single-precision complex variable to mp type and back. For example:
>> x = single(1 + i)
x =
1.0000 + 1.0000i
>> x = mp(x)
x =
6.94449606095542138733663817572487e-310 + 5.263544247120890312873936353273975e-315i
Due to the nature of the application I'm working on, I can't get around this by using a string, e.g. mp('1+i'); I have to convert from a single-precision variable. Presently I'm getting around this by casting the variable to double before passing it to mp, e.g. x = mp(double(x)), but I'd like to not have to do that.
In addition, when I try to cast from mp to single, the variable gets cast to a double instead. For example:
>> x = mp('1+i')
x =
1 + 1i
>> x = single(x)
x =
1.0000 + 1.0000i
>> whos
Name Size Bytes Class Attributes
x 1x1 16 double complex
Presently I'm getting around this issue by calling single() twice, e.g. x = single(single(x)), but again, I'd like to not have to do that.
I'm using MATLAB version 8.4.0.150421 (R2014b) and mp version 3.8.5 Build 9059.
>> x = single(1 + i)
x =
1.0000 + 1.0000i
>> x = mp(x)
x =
6.94449606095542138733663817572487e-310 + 5.263544247120890312873936353273975e-315i
Due to the nature of the application I'm working on, I can't get around this by using a string, e.g. mp('1+i'); I have to convert from a single-precision variable. Presently I'm getting around this by casting the variable to double before passing it to mp, e.g. x = mp(double(x)), but I'd like to not have to do that.
In addition, when I try to cast from mp to single, the variable gets cast to a double instead. For example:
>> x = mp('1+i')
x =
1 + 1i
>> x = single(x)
x =
1.0000 + 1.0000i
>> whos
Name Size Bytes Class Attributes
x 1x1 16 double complex
Presently I'm getting around this issue by calling single() twice, e.g. x = single(single(x)), but again, I'd like to not have to do that.
I'm using MATLAB version 8.4.0.150421 (R2014b) and mp version 3.8.5 Build 9059.
Servicio de atención al cliente por UserEcho
Both bugs are confirmed and will be fixed in next updates.
Thank you very much for reporting!
Until then, you can try using the following workarounds:
A. For 'mp' to 'single' conversion:
Replace the following line in mp.m (line #1146):
with B. For 'single' to 'mp':
Please insert this code after #667 line in mp.m:
Updates for GNU Linux & Mac OSX follow (I know you probably use the GNU Linux version).