matrixfunctions / GraphMatFun.jl

Computation graphs for matrix functions
MIT License
13 stars 0 forks source link

DegOpt / Graph refactorization #73

Closed jarlebring closed 9 months ago

jarlebring commented 9 months ago

Currently the graph data structures allows for linear combination: a1*A1+a2*A2

Instead I suggest we allow for: a1*A1+... +aN*AN (in floating point interpreted as evaluation as usual from left to right).

The main data structure change would involve changing Tuple to NTuple or Vector or similar on line 46-47:

https://github.com/matrixfunctions/GraphMatFun.jl/blob/dc7e01d4dbcec7a19275d15c242b65aa1497881c/src/compgraph_struct.jl#L43-L50

In fact, such a data structure is already used in the code generation (for a subset of languages). It would be cleaner system design to have it as the fundamental graph structure.

https://github.com/matrixfunctions/GraphMatFun.jl/blob/dc7e01d4dbcec7a19275d15c242b65aa1497881c/src/code_gen/multilincomb.jl#L3-L10

Reason: It would eliminate the need for a DegOpt data structure. With this change a DegOpt would be a particular case of this data structure. In the future I want to generalize the DegOpts and this would be helpful to do first.

Cons:

Pros:

Our original thought was that there were data structure advantages that every node has exactly two parents. I'm not so convinced anymore.