Code generation and efficiency

While the graph can be evaluated with eval_graph, the ideal way to utilize a good graph is to produce efficient code. Currently code generation to Julia, Matlab, and C is supported.

Improving graph topology

The Compgraph is a general framework, and sometimes the topology can be improved. This is especially important before code generation.

GraphMatFun.compress_graph!Function
compress_graph!(graph,cref=[];verbose=false)

Searches for nodes which can be removed or reorganized without changing the function it represents. Corresponding references in the cref-vector are removed.

source
Missing docstring.

Missing docstring for compress_graph_output_cleaning!. Check Documenter's build log for details.

GraphMatFun.compress_graph_dangling!Function
compress_graph_dangling!(graph,cref=[];verbose=false)

Removes dangling nodes in the graph. If a node is not used anywhere and it is not in the output, it can safely be removed.

source
GraphMatFun.compress_graph_redundant!Function
compress_graph_redundant!(
    graph,
    cref = [];
    compress_lincomb = true,
    verbose = false,
)

Removes from the graph redundant nodes, that is, nodes that repeat a computation that is already present in the graph. Nodes corresponding to a linear combination are removed only if the coefficients are the same and compress_lincomb is set to true.

source
GraphMatFun.compress_graph_zero_coeff!Function
compress_graph_zero_coeff!(graph,cref=[];droptol=0;verbose=false)

Searches for linear combinations with zero coeff and removes those. The cref list deletes references to zero coeffs and updates all other crefs.

source
GraphMatFun.compress_graph_passthrough!Function
compress_graph_passthrough!(graph,cref=[];verbose=false);

Identifies lincombs of length one with coeff equal to one. The node has no effect and is redirected appropriately.

source
Missing docstring.

Missing docstring for extract_sums. Check Documenter's build log for details.

GraphMatFun.has_trivial_nodesFunction
has_trivial_node(graph) -> Bool

Checks whether the graph has trivial nodes, that is, multiplications by the identity or linear systems whose coefficient is the identity matrix.

source

Code generation

GraphMatFun.gen_codeFunction
gen_code(
    fname,
    graph;
    priohelp = Dict{Symbol,Float64}(),
    lang = LangJulia(),
    funname = "dummy",
    precomputed_nodes = [:A],
)

Generates the code for the graph in the language specified in lang and writes it into the file fname. The string funname is the function name. Topological order of the nodes is comptued using get_topo_order and priohelp can be used to influence the order. The nodes listed in precomputed_nodes are viewed as inputs, and code to compute these nodes are not computed.

Currently supported languages: LangC_MKL, LangC_OpenBLAS, LangJulia, LangMatlab.

source
GraphMatFun.LangJuliaType
LangJulia(overwrite_input=true,inline=true,alloc_function,only_overwrite=false)

Code generation in julia language, with optional overwriting of input. The parameter alloc_function is a function of three parameters alloc_function(k) where k is the memory slot (default is alloc_function(k)=similar(A,T)). The only_overwrite specifies if f should be created if the overwrite funtion f! contains the actual code.

source