DenseVector_Double
A structure that contains a dense vector of double-precision, floating-point values.
Declaration
struct DenseVector_DoubleMentioned in
Overview
You typically use dense vectors to represent the unknowns vector, x, and the right-hand-side vector, b, in the matrix equation Ax = b. A DenseVector_Double structure provides a pointer to its underlying data and a count of its number of elements.
The following code shows an example of how to create a dense vector structure from an array of double-precision values. In this case, use withUnsafeMutableBufferPointer(_:) to pass a pointer to your collection. The DenseVector_Double structure is valid only during the execution of the closure. Don’t store or return the structure for later use.
var vectorValues: [Double] = [10, 20, 30, 40]
let vectorValuesCount = Int32(vectorValues.count)
vectorValues.withUnsafeMutableBufferPointer { vectorValuesPtr in
let vector = DenseVector_Double(count: vectorValuesCount,
data: vectorValuesPtr.baseAddress!)
// Perform operations using `vector`.
}