我正在使用 Apple 的 Accelerate 框架,使用稀疏矩阵运算。
因此,我创建了一个稀疏矩阵:
var values: Array<Double> = [0.125, 0.08, -0.01, 0.405, -0.02, 0.005]
var rowIndices: [Int32] = [0, 1, 2, // Column 0
3, 4, // Column 1
5 ] // Column 3
var columnStarts = [0, 3, 5, 6]
let structure: SparseMatrixStructure = rowIndices.withUnsafeMutableBufferPointer { rowIndicesPtr in
columnStarts.withUnsafeMutableBufferPointer { columnStartsPtr in
var attributes = SparseAttributes_t()
attributes.triangle = SparseLowerTriangle
attributes.kind = SparseSymmetric
return SparseMatrixStructure(
rowCount: 3,
columnCount: 3,
columnStarts: columnStartsPtr.baseAddress!,
rowIndices: rowIndicesPtr.baseAddress!,
attributes: attributes,
blockSize: 1
)
}
我正在调用分解矩阵:
let llt: SparseOpaqueFactorization_Double = values.withUnsafeMutableBufferPointer { valuesPtr in
let a = SparseMatrix_Double(
structure: structure,
data: valuesPtr.baseAddress!
)
return SparseFactor(SparseFactorizationCholesky, a)
}
我真的需要检查分解的结果 - 即打印出结果。看不到任何获得结果的方法,更不用说打印出来了。
谁能帮我理解如何检索结果并打印出来?