| MATLAB Compiler | ![]() |
Nonscalar Arrays
(fold_non_scalar_mxarrays) This optimization is very similar to fold_scalar_mxarrays. It folds nonscalar mxArray values into compile-time arrays that are initialized at program start-up. This can have a large performance impact if you are constructing arrays that use [] or {} within a loop. This optimization makes the code less readable. For example,
function y = test y = [ 1 0; 0 1] * [ pi pi/2; -pi -pi/2 ];
If you compile this with the -O none option, you get
... mlfAssign( &y, mclMtimes( mlfDoubleMatrix(2, 2, _array0_, (double *)NULL), mlfDoubleMatrix(2, 2, _array1_, (double *)NULL))); ...
Compiling with -O none -O fold_non_scalar_mxarrays:on gives
... mlfAssign(&y, _mxarray0_); ...
| Optimizing Arrays | Optimizing Loops | ![]() |