Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.scipy.linalg.solve_triangular

View Source On Gitee
mindspore.scipy.linalg.solve_triangular(a, b, trans=0, lower=False, unit_diagonal=False, overwrite_b=False, debug=None, check_finite=True)[source]

Solve the linear system ax=b for x, Assuming a is a triangular matrix.

Note

  • solve_triangular is currently only used in mindscience scientific computing scenarios and dose not support other usage scenarios.

  • solve_triangular is not supported on Windows platform yet.

Parameters
  • a (Tensor) – A triangular matrix of shape (,M,M) where is zero or more batch dimensions.

  • b (Tensor) – A Tensor of shape (,M) or (,M,N). Right-hand side matrix in ax=b.

  • trans (Union[int, str], optional) –

    Type of system to solve. Default: 0.

    trans

    system

    0 or 'N'

    a x = b

    1 or 'T'

    a^T x = b

    2 or 'C'

    a^H x = b

  • lower (bool, optional) – Use only data contained in the lower triangle of a. Default: False.

  • unit_diagonal (bool, optional) – If True, diagonal elements of a are assumed to be 1 and will not be referenced. Default: False.

  • overwrite_b (bool, optional) – Not implemented now. Default: False.

  • debug (Any, optional) – Not implemented now. Default: None.

  • check_finite (bool, optional) – Not implemented now. Default: True.

Returns

Tensor of shape (,M) or (,M,N), which is the solution to the system ax=b. Shape of x matches b.

Raises
  • ValueError – If a is less than 2 dimension.

  • ValueError – if a is not square matrix.

  • TypeError – If dtype of a and b are not the same.

  • ValueError – If the shape of a and b are not matched.

  • ValueError – If trans is not in set {0, 1, 2, 'N', 'T', 'C'}.

Supported Platforms:

Ascend CPU

Examples

>>> import numpy as onp
>>> import mindspore
>>> from mindspore import Tensor
>>> from mindspore.scipy.linalg import solve_triangular
>>> a = Tensor(onp.array([[3, 0, 0, 0], [2, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 1]], onp.float32))
>>> b = Tensor(onp.array([3, 1, 3, 4], onp.float32))
>>> x = solve_triangular(a, b, lower=True, unit_diagonal=False, trans='N')
>>> print(x)
[ 1. -1.  2.  2.]
>>> print(a @ x)  # Check the result
[3. 1. 3. 4.]