New Issue: unresolved call using LinearAlgebra.matPow on a sparse array

16340, “vasslitvinov”, “unresolved call using LinearAlgebra.matPow on a sparse array”, “2020-09-04T02:29:54Z”

The following code:

// extracted from test/library/packages/LinearAlgebra/correctness/no-dependencies/correctness.chpl

use LinearAlgebra;
//use LinearAlgebra.Sparse;   // uncomment this to fix the error
use LayoutCS;

var drDom = {1..3,1..3};
var csrDom: sparse subdomain(drDom) dmapped CS(sortedIndices=false);
var A: [csrDom] real;
var B = matPow(A, 3);

reports, in developer mode:

$CHPL_HOME/modules/packages/LinearAlgebra.chpl:937: In function '_expBySquaring':
$CHPL_HOME/modules/packages/LinearAlgebra.chpl:940: error: unresolved call 'eye(CSDom(2,int(64),domain(2,int(64),false),true,false,false), type real(64))'

The function matPow in LinearAlgebra, when invoked on a sparse array, needs eye and dot from the module LinearAlgebra.Sparse. Yet, that module is not visible to matPow. So matPow() relies on its caller to “use” LinearAlgebra.Sparse so that eye() and dot() can be reached through matPow’s point of instantiation (POI).

One solution is to use LinearAlgebra.Sparse in/around matPow(). This is undesirable because it will result in increased compilation time when the Sparse submodule is not actually needed. Another solution is to require the user to use LinearAlgebra.Sparse when invoking sparse matPow(). A third solution is to make two procs matPow, both redirecting to its current version converted to a helper, with the matPow in LinearAlgebra proper accept only non-sparse arrays.