DiagonalMatrixQualifier#

class nvmath.linalg.DiagonalMatrixQualifier[source]#

A class which constructs and validates matrix_qualifiers_dtype for a diagonal matrix.

Examples

>>> import numpy as np
>>> from nvmath.linalg import (
...     DiagonalMatrixQualifier,
...     GeneralMatrixQualifier,
...     matrix_qualifiers_dtype,
... )

Create a diagonal matrix qualifier:

>>> DiagonalMatrixQualifier.create()  
array(('dg', False, False, 2, 0, 1),
      dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...

Create a conjugate diagonal matrix qualifier:

>>> DiagonalMatrixQualifier.create(conjugate=True)  
array(('dg', True, False, 2, 0, 1),
      dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...

Create an array of matrix qualifiers with one general and one diagonal matrix:

>>> qualifiers = np.full(
...     2,
...     GeneralMatrixQualifier.create(),
...     dtype=matrix_qualifiers_dtype,
... )
>>> qualifiers[1] = DiagonalMatrixQualifier.create()
>>> qualifiers  
array([('ge', False, False, 2, 0, 0), ('dg', False, False, 2, 0, 1)],
      dtype=[('abbreviation', '<U2'), ('conjugate', '?'), ...

Methods

__init__()[source]#
classmethod create(
conjugate: bool = False,
transpose: bool = False,
incx: Literal[-1, 1] = 1,
)[source]#

Return a np.ndarray of type matrix_qualifiers_dtype whose element describes a diagonal matrix.

Parameters:
  • conjugate – Whether the matrix is conjugate.

  • transpose – Whether the matrix is transpose.

  • incx – The direction to read the diagonal. +1 for forward; -1 for reverse.

classmethod is_valid(other)[source]#

Return True if all elements of other are valid examples of the matrix_qualifiers_dtype constructed by this class.

classmethod to_string(
other: ndarray[tuple[Any, ...], dtype[_ScalarT]],
) str[source]#

Return a pretty string representation of other.

Attributes

abbreviation: ClassVar[str] = 'dg'#