<< spCompHessian scicolpack spyCol >>

scicolpack >> scicolpack > spCompJacobian

spCompJacobian

Consruct a compressed Jacobian engine from its sparsity pattern using column intersection graph coloring

Syntax

jac = spCompJacobian(f,sp)
jac = spCompJacobian(f,sp,options)

Parameters

f

a Scilab function

sp

a sparse matrix

options

a sequence of optional named arguments allowing to customize the engine (see available options below)

jac

the returned engine, an MList of _spCompJacobian type (fields are described below)

Description

The spCompJacobian function consructs a compressed Jacobian engine from the given sparsity pattern using column intersection graph coloring. Internally, after using a heuristic coloring algorithm, a "seed matrix" is generated, available as jac.seed, and later used by the engine to compute (approximate) directional derivatives of f in each seed column direction. Then the uncompressed Jacobian is recovered. The typical call sequence starts by calling spCompJacobian then continues by invoking the returned MList with the vectors at which the Jacobian is to be computed:

jac = spCompJacobian(f,sp);
J0 = jac(x0);
J1 = jac(x1);

The options allows to change some parameters of the coloring algorithm and to choose the derivative approximation scheme as well as the step vector. The available options are the following:

The jac MList can be invoked with more than one arguments. In this case the remaining argument after the first are used by the engine as complimentary arguments when calling f.

Examples

function y=f(x)
    y = x(1:$-2).^2./(4+cos(x(2:$-1)).*sin(x(3:$)));
endfunction
n = 1000;
sp = sparse([1:n-2,1:n-2,1:n-2;1:n-2,2:n-1,3:n]',ones(3*(n-2),1),[n-2,n]);
jac = spCompJacobian(f,sp)
x0 = rand(n,1);
tic
J = jac(x0);
toc
tic
Jd = numderivative(f,x0);
toc
max(abs(Jd-J))

See also

Bibliography

A. H. Gebremedhin, D. C. Nguyen, Md. M. A. Patwary, A. Pothen}, ColPack: Software for graph coloring and related problems in scientific computing, ACM Trans. Math. Softw., N. 40(1), pp. 1-31, 2013, https://doi.org/10.1145/2513109.2513110.


Report an issue
<< spCompHessian scicolpack spyCol >>