Try our new documentation site (beta).
Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
MQuadExpr.sum()
sum ( axis=None )
Sum the elements of this MQuadExpr; returns an MQuadExpr object.
Arguments:
axis: An int, or None. Sum along the specified axis. If set to None, summation takes place along all axes of this MQuadExpr.
Return value:
An MQuadExpr representing the sum.
Example usage:
expr = 2 * model.addMVar((2, 2))**2 - 1 sum_row = expr.sum(axis=0) # Sum along the rows sum_col = expr.sum(axis=1) # Sum along the columns sum_all = expr.sum() # Sum all elements, result is 0-D