- Notifications
You must be signed in to change notification settings - Fork15
Description
The default orientation of matrices is rowwise. This can be changed globally in SuiteSparse:GraphBLAS withgb.ss.config["format"] = "by_col", and a single matrix can be changed viaA.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 asB = (A + 1).new())? More illustrations below:
In [1]:importgraphblasasgbIn [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.formatOut[3]:'csc'In [4]:A.ss.orientationOut[4]:'columnwise'In [5]:B= (A+1).new()In [6]:B.ss.orientationOut[6]:'rowwise'In [7]:gb.ss.concat([[A,A]]).ss.orientationOut[7]:'rowwise'In [8]:A[:4, :4].new().ss.orientationOut[8]:'rowwise'
Perhaps this isn't surprising, since a global default means just that: everything is predictable, andnew 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")
- e.g.
It's worth noting that the upcoming GraphBLAS 2.1 specification will introduce the ability to introspect a Matrix for its orientation.