<!--
{
  "availability" : [
    "iOS: 18.5.0 -",
    "iPadOS: 18.5.0 -",
    "macCatalyst: 18.5.0 -",
    "macOS: 15.5.0 -",
    "tvOS: 18.5.0 -",
    "visionOS: 2.5.0 -",
    "watchOS: 11.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/SparseIterate(_:_:_:_:_:_:_:_:_:)-4td1l",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@SparseIterate#$@SA@SparseIterativeMethod#I#*1b#*v#BFv(#b#$@E@CBLAS_TRANSPOSE#$@SA@DenseMatrix_Complex_Float#S6_)#S6_#S6_#S6_#$@SA@SparseOpaquePreconditioner_Complex_Float#"
  },
  "title" : "SparseIterate(_:_:_:_:_:_:_:_:_:)"
}
-->

# SparseIterate(_:_:_:_:_:_:_:_:_:)

Perform a single iteration of the specified iterative method for complex float values with preconditioner.

```
func SparseIterate(_ method: SparseIterativeMethod, _ iteration: Int32, _ converged: UnsafePointer<Bool>, _ state: UnsafeMutableRawPointer, _ ApplyOperator: @escaping (Bool, CBLAS_TRANSPOSE, DenseMatrix_Complex_Float, DenseMatrix_Complex_Float) -> Void, _ B: DenseMatrix_Complex_Float, _ R: DenseMatrix_Complex_Float, _ X: DenseMatrix_Complex_Float, _ Preconditioner: SparseOpaquePreconditioner_Complex_Float)
```

## Parameters

`method`

(input) Iterative method specification, eg return value of
`SparseConjugateGradient()`.

```
 Note that the options related to convergence testing (e.g.
 `maxIterations`, `atol`, `rtol`) are ignored as convergence tests must be
 performed by the user.
```

`iteration`

(input) The current iteration number, starting from 0. If
`iteration<0`, then the current iterate is finalised, and the value of
`X` is updated (note that this may force some methods to restart,
slowing convergence).

`converged`

(input) Convergence status of each solution vector.
`converged[j]=true` indicates that the vector stored as column `j` of `X`
has converged, and it should be ignored in this iteration.

`state`

(input/output) A pointer to a state-space of size returned by
`SparseGetStateSize_Complex_Float()`. This memory must be 16-byte aligned
(any allocation returned by `malloc()` has this property). It must not
be altered by the user between iterations, but may be safely discarded
after the final call to `SparseIterate()`.

`ApplyOperator`

`ApplyOperator(accumulate, trans, X, Y)`
should perform the operation `Y = op(A)X` if `accumulate` is `false`,
or `Y += op(A)X` if `accumulate` is `true`.

- `accumulate` : (input) Indicates whether to perform `Y += op(A)X` (if
  true) or `Y = op(A)X` (if false).
- `trans`: (input) Indicates whether `op(A)` is the application of `A`
  (`trans=CblasNoTrans`) or `A^T` (`trans=CblasTrans`).
-  `X`: The matrix to multiply.
-  `Y`: The matrix in which to accumulate or store the result.

`B`

(input) The right-hand sides to solve for.

`R`

(output) Residual estimate. On entry with `iteration=0`, it must hold
the residuals `b-Ax` (equal to `B` if `X=0`). On return from each call with
`iteration>=0`, the first entry(s) of each vector contain various
estimates of norms to be used in convergence testing.

- For CG and GMRES:
  `R(0,j) `holds an estimate of` || b-Ax ||_2` for the j-th rhs.
- For LSMR - `R(0,j)`:
  `R(0,j)` holds an estimate of` || A^T(b-Ax) ||_2` for the j-th rhs.
- For LSMR  - `R(1,j)`:
  `R(1,j)` holds an estimate of` || b-Ax ||_2` for the j-th rhs.
- For LSMR - `R(2,j)`:
  `R(2,j)` holds an estimate of `|| A ||_F`, the Frobenius norm of `A`,
  estimated using calculations related to the j-th rhs.
- For LSMR - `R(3,j)`:
  `R(3,j) `holds an estimate of `cond(A)`, the condition number of `A`,
  estimated using calculations related to the j-th rhs.
  
  Other entries of `R` may be used by the routine as a workspace.
  On return from a call with `iteration<0`, the exact residual vector
  b-Ax is returned.

`X`

(input/output) The current estimate of the solution vectors X.
On entry with iteration=0, this should be an initial estimate for the
solution. If no good estimate is available, use X = 0.0.
Depending on the method used, X may not be updated at each iteration,
or may be used to store some other vector.
The user should make a call with iteration<0 once convergence has
been achieved to bring X up to date.

`Preconditioner`

(input) Preconditioner to apply.

---

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)