Є відповідь

Exchanging a value in a double precision array

Michael_ 9 років тому оновлено Pavel Holoborodko 9 років тому 2

I am not sure if the following is really intended:

Adding a mp number to a double number:

The variable test is a mp number, so the variable 'b' was cast to mp.
If I assign a mp number to a double array, it will be cast to double.


The array A is still double.
Probably this is done intentionally, but I think it was different in an older version. (I have the newest one)

Best regards,
Є відповідь
This is one of OOP rules in MATLAB. It does the conversion automatically without asking the toolbox and we have no control over this behavior (and it is always been like this).

In case of scalar operands - MATLAB casts to more powerful or custom type.
In case of arrays - the scalar RHS entity is converted to LHS type.

Actually it is a good solution. Otherwise, the whole array A would be converted to 'double' in the case:

% A becomes 'double' !

This would be much more unexpected behavior, isn't it?

Btw, newest version has some improvements in matrix multiplication in quadruple precision.
You might notice some speed-up for large matrices (~10-15%).