Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Setting or propagating orientation (rowwise or columnwise) of a Matrix #492

Open
@eriknw

Description

@eriknw

The default orientation of matrices is rowwise. This can be changed globally in SuiteSparse:GraphBLAS with gb.ss.config["format"] = "by_col", and a single matrix can be changed via A.ss.config["format"] = "by_col".

Using matrices with non-default orientation may result in surprising behavior. For example, would users expect elementwise operations to result in the orientation changing (such as B = (A + 1).new())? More illustrations below:

In [1]: import graphblas as gb

In [2]: A = gb.Matrix.from_csc([0, 2, 3, 3, 5], [1, 3, 7, 6, 20], [10, 20, 30, 40, 50])

In [3]: A.ss.format
Out[3]: 'csc'

In [4]: A.ss.orientation
Out[4]: 'columnwise'

In [5]: B = (A + 1).new()

In [6]: B.ss.orientation
Out[6]: 'rowwise'

In [7]: gb.ss.concat([[A, A]]).ss.orientation
Out[7]: 'rowwise'

In [8]: A[:4, :4].new().ss.orientation
Out[8]: 'rowwise'

Perhaps this isn't surprising, since a global default means just that: everything is predictable, and new objects by default will use the default orientation. If you want to control the orientation of the output, then this is possible by first creating the output object and setting its orientation.

Some questions:

  • should we consider ever propagating the orientation of input matrices to the automatically created result matrix?
  • should we consider a way to specify orientation (and other config?) when creating new objects?
    • e.g. B = (A + 1).new(order="col")
    • e.g. B = gb.ss.concat([[A, A]], order="F")
    • e.g. B = A[:4, :4].new(order="columnwise")

It's worth noting that the upcoming GraphBLAS 2.1 specification will introduce the ability to introspect a Matrix for its orientation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionDiscussing a topic with no specific actions yetenhancementImprove existing functionality or make things work better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions