https://bugs.documentfoundation.org/show_bug.cgi?id=174538

            Bug ID: 174538
           Summary: : Allow inline {...} braces for explicit array
                    vectorization and faster iterative recalculation
           Product: LibreOffice
           Version: 26.8.2.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

Hi,
I use Calc heavily for complex iterative models and wanted to suggest an
enhancement for how array formulas and vectorization are handled.
Right now, working with mixed scalar and array expressions in Calc is either
cumbersome (having to wrap the whole formula with Ctrl+Shift+Enter) or slow
during iterative recalculations. For example, when I drag a formula like this
across many rows:
=Name * SUM(IF(val1 * val2 = cond_other_dim; source1; source2))
Here, Name is just a single cell from the current row, while val1 * val2 =
cond_other_dim compares a column vector against a row of conditions. Without
explicit control over which part is vectorized, Calc either tries to
array-expand the whole thing or recalculates the entire array block on every
single cell change and iteration step, which kills performance.
My idea is to allow curly braces {...} inside a formula to mark specific
sub-expressions that should be evaluated as vectors/matrices, while keeping
everything outside {...} in normal scalar context:
=Name * {SUM(IF({val1} * {val2} = {cond_other_dim}; {source1}; {source2}))}
Why this would help a lot:

    ScCompiler can easily tell the difference between a constant inline array
like {1; 2; 3} and a calculated expression with cell references like {A1:A10 *
2}.
    Any scalar function inside {...} could automatically work element-wise
(lifting), without implicit intersection cutting ranges down to one cell.
    For the calculation engine, explicit {...} blocks make it much easier to
cache shared vector reductions (like the SUM above) instead of recalculating
them for every row, and to only recalculate changed indices during iterations.
    If an offset inside {...} goes out of sheet bounds, it could evaluate as 0,
and if a final spill hits the physical sheet edge, it could fill what fits and
show #SPILL!0! instead of blocking the whole formula.

Does this make sense from the ScCompiler / ScFormulaCellGroup perspective?
Happy to clarify any part of the use case.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to