{ } Raw JSON

bundles / scipy latest / scipy / sparse / linalg / _dsolve / linsolve / is_sptriangular

function

scipy.sparse.linalg._dsolve.linsolve:is_sptriangular

source: /scipy/sparse/linalg/_dsolve/linsolve.py :750

Signature

def   is_sptriangular ( A )

Summary

Returns 2-tuple indicating lower/upper triangular structure for sparse A

Extended Summary

Checks for triangular structure in A. The result is summarized in two boolean values lower and upper to designate whether A is lower triangular or upper triangular respectively. Diagonal A will result in both being True. Non-triangular structure results in False for both.

Only the sparse structure is used here. Values are not checked for zeros.

This function will convert a copy of A to CSC format if it is not already CSR or CSC format. So it may be more efficient to convert it yourself if you have other uses for the CSR/CSC version.

If A is not square, the portions outside the upper left square of the matrix do not affect its triangular structure. You probably want to work with the square portion of the matrix, though it is not requred here.

Parameters

A : SciPy sparse array or matrix

A sparse matrix preferrably in CSR or CSC format.

Returns

lower, upper : 2-tuple of bool

Examples

import numpy as np
from scipy.sparse import csc_array, eye_array
from scipy.sparse.linalg import is_sptriangular
A = csc_array([[3, 0, 0], [1, -1, 0], [2, 0, 1]], dtype=float)
is_sptriangular(A)
D = eye_array(3, format='csr')
is_sptriangular(D)

Aliases

  • scipy.sparse.linalg.is_sptriangular