<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/SparseConjugateGradient(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@SparseConjugateGradient#$@SA@SparseCGOptions#"
  },
  "title" : "SparseConjugateGradient(_:)"
}
-->

# SparseConjugateGradient(_:)

Returns a conjugate gradient (CG) method with specified options.

```
func SparseConjugateGradient(_ options: SparseCGOptions) -> SparseIterativeMethod
```

## Parameters

`options`

The options to use when creating the conjugate gradient method, such as the maximum number of iterations to perform.

## Return Value

A [`SparseIterativeMethod`](/documentation/Accelerate/SparseIterativeMethod) structure that represents a default conjugate gradient method.

## Discussion

Use CG to solve *Ax = b* when *A* is symmetric positive-definite. The method may break down or fail to converge if *A* isn’t positive-definite.

For square, full-rank, unsymmetric or indefinite equations, use [`SparseGMRES(_:)`](/documentation/Accelerate/SparseGMRES(_:)). For rectangular or singular systems, use [`SparseLSMR(_:)`](/documentation/Accelerate/SparseLSMR(_:)).

---

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)