Diagonal Matrix

class fastmat.Diag

Bases: Matrix

\[x \mapsto {\mathrm{diag}}(d_1,\dots,d_n) \cdot x\]

A diagonal matrix is uniquely defined by the entries of its diagonal.

>>> # import the package
>>> import fastmat as fm
>>> import numpy as np
>>>
>>> # build the parameters
>>> n = 4
>>> d = np.array([1, 0, 3, 6])
>>>
>>> # construct the matrix
>>> D = fm.Diag(d)

This yields

\[d = (1, 0, 3, 6)^\mathrm{T}\]
\[\begin{split}D = \begin{bmatrix} 1 & & & \\ & 0 & & \\ & & 3 & \\ & & & 6 \end{bmatrix}\end{split}\]
__init__()

Initialize a Diag matrix instance.

Parameters
vecDnumpy.ndarray

The generating vector of the diagonal entries of this matrix.

**optionsoptional

Additional keyworded arguments. Supports all optional arguments supported by fastmat.Matrix.

vecD

Return the matrix-defining vector of diagonal entries.

(read-only)