<!--
{
  "availability" : [
    "iOS: 8.0.0 - 14.0.0",
    "iPadOS: 8.0.0 - 14.0.0",
    "macCatalyst: 13.1.0 - 14.0.0",
    "macOS: 10.10.0 - 11.0.0",
    "tvOS: 8.0.0 - 14.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 1.0.0 - 7.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/la_solve(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@la_solve"
  },
  "title" : "la_solve(_:_:)"
}
-->

# la_solve(_:_:)

```
func la_solve(_ matrix_system: la_object_t, _ obj_rhs: la_object_t) -> la_object_t
```

## Parameters

`matrix_system`

A matrix describing the left-hand side of the system.

`obj_rhs`

A vector or matrix describing one or more right-hand sides for which the
equations are to be solved.

## Return Value

A matrix of the solution(s) of the system of equations.

## Discussion\abstract Solves a system of linear equations
\discussion If matrix_system represents a matrix A, and obj_rhs represents a vector
B, la_solve returns a vector X representing a solution to the equation
AX = B, if such a solution exists.  If obj_rhs represents a matrix, then
la_solve returns a matrix representing the solution of the same equation.

There are several different cases, and different algorithms are chosen
depending on the specifics:

If the matrix has a special structure that allows us to solve the system
without factoring (e.g. if the matrix is diagonal or triangular), we may
use that structure to compute the solution.

If the matrix is symmetric and all diagonal entries are positive, or if we
know, either via a hint parameter or by how earlier computations were
structured, that the matrix is positive definite, we attempt a Cholesky
factorization.  If this succeeds, it is used to compute the solution via
forward- and back-substitution.

If the matrix is square, we try to perform Gaussian elimination to construct
a triangular factorization with pivoting.  If this factorization succeeds,
we use it to solve the system.  If it fails, the returned object has the
error status LA_SINGULAR_ERROR.

If the matrix is not square, we return a least-squares solution computed by
performing a QR factorization of the matrix.

If the number of rows of the matrix does not match the number of rows of
the right hand side object, the returned object has status
LA_DIMENSION_MISMATCH_ERROR.

If the object describing the matrix is not a matrix, or if the right hand
side is not a matrix or vector, the returned object has status
LA_INVALID_PARAMETER_ERROR.

If you want to solve the system XA = B, which is less common (but still
occurs fairly frequently), you may accomplish this by transposing A and B,
solving, and then transposing the result of the solve.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)