Structure

DenseVector_Float

A structure that contains a dense vector of single-precision, floating-point values.

Declaration

typedef struct {
    ...
} DenseVector_Float;

Overview

The following code shows an example of how to create a dense vector structure from an array of single-precision values. In this case, use withUnsafeMutableBufferPointer(_:) to pass a pointer to your collection. The DenseVector_Float structure is valid only during the execution of the closure. Do not store or return the structure for later use.

var vectorValues: [Float] = [10, 20, 30, 40]
let vectorValuesCount = Int32(vectorValues.count)

vectorValues.withUnsafeMutableBufferPointer { vectorValuesPtr in
    
    let vector = DenseVector_Float(count: vectorValuesCount,
                                   data: vectorValuesPtr.baseAddress!)
    
    // Perform operations using `vector`.
}

Topics

Inspecting a Vector's Structure and Data

count

The number of items in the vector.

data

The array of single-precision, floating-point values.

See Also

Dense Matrices and Vectors

DenseMatrix_Double

A structure that contains a dense matrix of double-precision, floating-point values.

DenseMatrix_Float

A structure that contains a dense matrix of single-precision, floating-point values.

DenseVector_Double

A structure that contains a dense vector of double-precision, floating-point values.