Functions

Problem

Sparspak.SpkProblem.inaij!Method
inaij!(p::Problem{IT,FT}, rnum, cnum, aij=zero(FT)) where {IT,FT}

Input a matrix coefficient.

The value is added to the existing contents.

source
Sparspak.SpkProblem.infullrhs!Function
infullrhs!(p::Problem{IT,FT}, rhs)  where {IT,FT}

Add a vector of values, rhs, to the current right hand side of a problem object.

Input:

  • rhs - the source right-hand side. It must be of length at least p.nrows and if it is greater than p.nrows, only the first p.nrows are used.

Updated:

  • p - the problem in which rhs is to be inserted.
source
Sparspak.SpkProblem.computeresidualFunction
computeresidual(p::Problem, res::Vector{FT}, xin::Vector{FT} = FT[], mtype = "T") where {FT}

Compute the residual of a problem.

Given a vector x, this routine calculates the difference between the RHS of the given Problem and A*x and places this in res.

Input:

  • p - the Problem used to calculate res, using xin
  • xin - the input "solution" vector used to compute the residual
  • mtype - matrix type (optional). If the matrix is symmetric and only the lower or upper triangle is present, the user must let the routine know this by setting mType to one of: "L" or "l" - when only the lower triangle is present "U" or "u" - when only the upper triangle is present "T" or "t" - when either the lower or upper triangle is present.

Output:

  • res - the calculated residual
source
Sparspak.SpkProblem.makerhs!Function
makerhs!(p::Problem, x::Vector{FT} = FT[], mtype = "T") where {FT}

This routine constructs the RHS of a problem given an x for the equation Ax = rhs. The x must have the same number of elements as the problem (represented by A above) has columns. If x is not present, a right hand side is contructed so that the solution is 1, 2, 3, ...m.

Input Parameter: x - the vector in the equation ``Ax = rhs"" mType - matrix type (optional). If the matrix is symmetric and only the lower or upper triangle is present, the user must let the routine know this by setting mType to one of: "L" or "l" - when only the lower triangle is present "U" or "u" - when only the upper triangle is present "T" or "t" - when either the lower or upper triangle is present. Updated Parameter: p - the problem for which the RHS is being constructed.

source
Sparspak.SpkProblem.makegridproblemFunction
makegridproblem(g::Grid{IT}) where {IT}

This routine fills in a problem object using a given grid.

Input:

  • g - the Grid to be used to fill a Problem matrix

Output:

  • p - the Problem object to be filled
source
makegridproblem(h::IT, k::IT) where {IT}

Construct a problem object based on a grid.

Input:

  • h - the number of rows in the Grid
  • k - the number of columns in the Grid

Output:

  • p - the Problem object to be filled
source

Sparse LU Solver

Main interface

Sparspak.SpkSparseSolver.solve!Function
solve!(s,rhs)

Solves linear system defined with sparse solver and provides the solution in rhs.

source
solve!(s::SparseSolver{IT}) where {IT}

Execute all the steps of the solution process.

Given a symmetric matrix A, the steps are:

  1. Reordering of the matrix A.
  2. Symbolic factorization of the(reordered) matrix A.
  3. Putting numerical values of A into the data structures.
  4. Numerical factorization of A.
  5. Forward and backward substitution (triangular solution).

The solution can be retrieved as p.x.

source

Fine-granularity actions

Sparspak.SpkSparseSolver.findorder!Function
findorder!(s::SparseSolver{IT}, orderfunction::F) where {IT, F}

Find reordering of the coefficient matrix.

  • orderfunction: ordering function

If ordering has already been done for the solver, nothing happens. Otherwise, the order function is applied.

Finding the ordering invalidates symbolic factorization.

source
findorder!(s::SparseSolver{IT}) where {IT}

Find reordering of the coefficient matrix using the default method.

If ordering has already been done for the solver, nothing happens. Otherwise, the order function is applied.

Finding the ordering invalidates symbolic factorization.

source
Sparspak.SpkSparseSolver.findorderperm!Function
findorderperm!(s::SparseSolver{IT}, perm) where {IT}

Find reordering of the coefficient matrix using a given permutation.

If ordering has already been done for the solver, nothing happens. Otherwise, the order function is applied.

Finding the ordering invalidates symbolic factorization.

source
Sparspak.SpkSparseSolver.symbolicfactor!Function
symbolicfactor!(s::SparseSolver{IT})

Symbolic factorization of the(reordered) matrix A.

Create the data structures for the factorization and forward and backward substitution.

A symbolic factorization invalidates the input of the matrix.

source
Sparspak.SpkSparseSolver.inmatrix!Function
inmatrix!(s::SparseSolver{IT}) where {IT}

Put numerical values of the matrix stored in the problem into the data structures of the solver.

If a matrix has been input before, and has not been invalidated by symbolic factorization, nothing is done.

Input of the numerical values of the matrix invalidates the factorization.

source
Sparspak.SpkSparseSolver.factor!Function
factor!(s::SparseSolver{IT}) where {IT}

Numerical factorization of the coefficient matrix.

Numerical factorization invalidates the triangular solve.

source
Sparspak.SpkSparseSolver.triangularsolve!Function
triangularsolve!(s::SparseSolver{IT}) where {IT}

Forward and backward substitution (triangular solution).

The triangular solve is only done if it hasn't been done before; otherwise nothing is done and the solution is the one obtained before.

source
triangularsolve!(s::SparseSolver{IT, FT}, rhs::Vector{FT}) where {IT, FT}

Forward and backward substitution (triangular solution).

Variant where the right-hand side vector is passed in. This always triggers a triangular solve.

source

LU Factorization API

Sparspak.SparseCSCInterface.sparspakluFunction
sparspaklu(m::SparseMatrixCSC; factorize=true) -> lu::SparseSolver

If factorize==true, calculate LU factorization using Sparspak. Steps are findorder, symbolicfactor, factor.

If factorize==false, ordering, symbolic factorization and factorization are delayed to a subsequent call to sparspaklu!.

Returns a SparseSolver instance in the respective state, which has methods for LinearAlgebra.ldiv! and "backslash".

source
Sparspak.SparseCSCInterface.sparspaklu!Function
sparspaklu!(lu::SparseSolver, m::SparseMatrixCSC; allow_pattern_change=true) -> lu::SparseSolver

Calculate LU factorization of a sparse matrix m, reusing ordering and symbolic factorization lu, if that was previously calculated.

If allow_pattern_change = true (the default) the sparse matrix m may have a nonzero pattern different to that of the matrix used to create the LU factorization lu, in which case the ordering and symbolic factorization are updated.

If allow_pattern_change = false an error is thrown if the nonzero pattern of m is different to that of the matrix used to create the LU factorization lu.

If lu has not been factorized (ie it has just been created with option factorize = false) then lu is always updated from m and allow_pattern_change is ignored.

source

Multiple minimum degree (MMD) ordering.

Sparspak.SpkMmd.mmd!Method
mmd!(g::Graph, order::Ordering)

Multiple minimum degree Ordering algorithm (MMD).

Written by Erik Demaine, eddemaine@uwaterloo.ca Based on a Fortran 77 code written by Joseph Liu.

For information on the minimum degree algorithm see the articles:

The evolution of the minimum degree algorithm by Alan George and Joseph Liu, SIAM Rev. 31 pp. 1 - 19, 1989.0

Modification of the minimum degree algorithm by multiple elimination, ACM Trans. Math. Soft. 2 pp.141 - 152, 1985

Input:

  • g: graph

Output:

  • order: updated ordering. Rows and columns are permuted in the same way.
source

Graphs

Sparspak.SpkGraph.GraphMethod
Graph(p::Problem{IT}, diagonal=false) where {IT}

Construct a graph from a problem object.

It does not check that the problem object contains a structurally symmetric matrix, since sometimes only the lower or upper triangle of a symmetric matrix may be stored. There are routines in this module to make a given graph object structurally symmetric.

Input:

  • p - the problem object, used to create the graph
  • diagonal - indicates that the diagonal elements are included. If diagonal is not given, the adjacency structure does not include the diagonal elements.
source
Sparspak.SpkGraph.sortgraph!Method
sortgraph!(g::Graph{IT}) where {IT}

Sort the adjacency lists of the graph.

Important assumption: This works only for graphs that are symmetric.

source

Grid