# Test Matrix Type (G Dataflow)

Version:

Determines whether a matrix is of a specific type.

## matrix type

The specific type of matrix you want to compare the input matrix.

Name Value Description
Symmetric Positive Definite 10 Determines whether the input matrix is symmetric positive definite.
Symmetric Positive Semi-Definite 11 Determines whether the input matrix is symmetric positive semi-definite.
Symmetric 20 Determines whether the input matrix is symmetric.
Hermitian 21 Determines whether the input matrix is Hermitian.

Default: Symmetric Positive Definite

## matrix

A matrix.

This input accepts a 2D array of double-precision, floating point numbers or 2D array of complex double-precision, floating point numbers.

## error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

## relative tolerance

A value that determines how close the input matrix must be to the specified matrix type.

The exact meaning of this input depends on the value of matrix type.

If relative tolerance is less than 0, this node chooses a tolerance based on the input matrix.

Default: -1

## is type?

A Boolean that indicates whether the input matrix is the same type as the specified matrix type.

 True The input matrix matches the specified matrix type. False The input matrix does not match the specified matrix type.

## error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

## How Does This Node Test Matrix Types?

This node uses the following steps to test matrix types:

1. Tests whether the input matrix is symmetric (or Hermitian). If the test fails, the output is type? returns False.
2. Tests whether the symmetric (or Hermitian) matrix is positive definite (or positive semi-definite) by Cholesky factorization. If a symmetric matrix is not positive definite (or positive semi-definite), the algorithm for Cholesky factorization fails when it attempts to calculate the square root of a negative number or divide by zero.

## Algorithm for Testing Positive Definite and Positive Semi-Definite Matrix Types

In real cases, a symmetric matrix A is positive definite if xTAx > 0 for any non-zero vector x.

A symmetric matrix A is positive semi-definite if xTAx ≥ 0 for any non-zero vector x.

In complex cases, a Hermitian matrix A is positive definite if xHAx > 0 for any non-zero vector x.

A Hermitian matrix A is positive semi-definite if xHAx ≥ 0 for any non-zero vector x.

This node uses the input relative tolerance to determine whether a number is small enough that you consider it as zero when performing Cholesky factorization. If the input relative tolerance is less than zero, the tolerance in Cholesky factorization is

$2.22e-16*n*\text{maxdiag}$

where n is the order of the input matrix and maxdiag is the maximum value of diagonal elements of the input matrix.

Otherwise, the tolerance is $\text{relative tolerance}*n*\text{maxdiag}$.

## Algorithm for Testing Symmetric and Hermitian Matrix Types

A real or complex square matrix is symmetric if aij = aji.

A complex square matrix is Hermitian if ${a}_{ij}=\text{conj}\left({a}_{ji}\right)$ where conj is the complex conjugate function.

This node uses the input relative tolerance to determine whether the difference between two elements in the input matrix is small enough to consider them equal. If relative tolerance is less than zero, the tolerance is

$2.22e-16*n*\mathrm{max}$

where n is the order of the input matrix and max is the maximum absolute value of elements in the input matrix. For a complex element, max is the maximum absolute value of its real and imaginary parts.

Otherwise, the tolerance is $\text{relative tolerance}*n*\mathrm{max}$.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application