The article does not give complete code, so you probably had to complete for your own code.
If I understood it correctly, the SparseSolve function changes x, which in turn changes xPtr and xValues.
x is passed as a parameter (and const) to the function, so it is not modified by SparseSolve.
To be clear, I did not analyse nor understand the details of how SparseSolve works, but I looked at the doc for SparseSolve (however I did not find one that returns a status), and it seems to be a bit different:
let xValues = [Double](unsafeUninitializedCapacity: n) {
buffer, count in
bValues.withUnsafeMutableBufferPointer { bPtr in
let b = DenseVector_Double(count: 3,
data: bPtr.baseAddress!)
let x = DenseVector_Double(count: 3,
data: buffer.baseAddress!)
SparseSolve(factorization, b, x)
count = n
}
}
On return, xValues contains the values [1.0, 2.0, 3.0].
Here, xValues is changed in the completion handler.
Could you try to replicate this ?