Arithmetic and Math Operations (Not Supported) - Arithmetic and Math Operations (Not Supported) - 2026.2 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-11-11
Version
2026.2 English

varray does not implement arithmetic or math operators for any data type, including varray.half, varray.fi, and varray.mx9. +, -, .*, ./, .^, *, /, ^, unary -/+, as well as sort, round, flip, repmat, and repelem all raise varray:invalidOperation:

"plus" is not supported for varrays. Use MATLAB cast() to convert the
varray to a MATLAB array first.

To do math, cast to a native MATLAB type, compute, then re-wrap:

a = varray.int32([1, 2, 3]);
b = varray.int32([4, 5, 6]);

% a + b                             % ERROR
result = int32(a) + int32(b);       % native MATLAB arithmetic

% Re-wrap if you need a varray again:
result_varray = varray.int32(result);

This is intentional. varray stores hardware-accurate byte images (quantized fi, block-scaled mx, bfloat16, half, and so on), and re-quantization after every operation hides bugs. Do the math in MATLAB, then re-wrap explicitly with the varray type you want the hardware to see.