问题描述
MATLAB是否支持float16操作?如果是这样,如何将双精度矩阵转换为float16?我正在一个大型矩阵上执行算术运算,在该矩阵上16位浮点表示足以满足我的表示要求.用双精度数据类型表示要占用4倍以上的内存.
Does MATLAB support float16 operations? If so, how to convert a double matrix to float16? I am doing an arithmetic operation on a large matrix where 16-bit floating representation is sufficient for my representation. Representing by a double datatype takes 4 times more memory.
推荐答案
您的矩阵是否已满?否则,请尝试sparse
-如果有很多零值元素,则会节省大量内存.
Is your matrix full? Otherwise, try sparse
-- saves a lot of memory if there's lots of zero-valued elements.
AFAIK,float16
.进入float
-datatype的最低要求是single
,它是32位数据类型:
AFAIK, float16
is not supported. Lowest you can go in float
-datatype is with single
, which is a 32-bit datatype:
A = single( rand(50) );
您可以乘以一个常数并将其强制转换为int16
,但是您将失去精度.
You could multiply by a constant and cast to int16
, but you'd lose precision.
这篇关于在matlab中支持float16吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!