Skip to content

API: different shape between matrix.sum() (return scaler) and matrix@matrix (return matrix) #1057

@Zeroto521

Description

@Zeroto521

The result of one_dim_matrix.sum() is Expr (scaler). It was changed to a scaler if the size of the result is 1.
But the result of matrix@matrix is MatrixVariable (matrix). The size of the result matrix@matrix is 1.
Same shape but different result. Should we keep the same?

  • Use numpy style, don't change the result at all. Keep the result as the matrix.
  • If the size is one, change it to scaler.
In [1]: from pyscipopt import Model

In [2]: model = Model()

In [3]: x = model.addMatrixVar(3)

In [4]: y = model.addMatrixVar(3)

In [5]: type(x.sum())  # the size is 1, and result is a scaler
Out[5]: pyscipopt.scip.Expr

In [6]: type(x @ y)  # the size is 1, but result is a matrix
Out[6]: pyscipopt.scip.MatrixVariable

In [7]: (x @ y).shape
Out[7]: ()

In [8]: type((x @ y).item())
Out[8]: pyscipopt.scip.Expr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions