**Chapter
18. **** Using The Structured Sparse Matrix
Classes** (.NET, C#, CSharp, VB, Visual Basic, F#)

**NMath** provides
a variety of functions that take the structured sparse matrix types described
in Chapter 17
as arguments. Methods are provided either as member functions on the
matrix classes, or as static methods on class **MatrixFunctions**.

As a general rule, **NMath**
only provides functions that preserve the shape of the structured sparse
matrices. In some cases, this means that functions provided for the general
matrix classes are not provided for the structured sparse matrix classes.
For example, **NMath** does
not generally provide trigonometric and transcendental functions for
structured sparse matrix types. Such functions may change unstored zero
values to non-zero values, thus changing a structured sparse matrix type
into a general matrix.

If you want to apply an arbitrary function to all elements of a structured sparse matrix, including unstored zero values, you can always convert the matrix to a general matrix first. A ToGeneralMatrix() method is provided for this purpose. Alternatively, to apply an arbitrary function only to stored values, you can apply the function to the underlying data vector. Both techniques are described in more detail in Section 18.7.

This chapter describes how to create and manipulate
the **NMath** structured sparse
matrix types.