Slide 23
Slide 23 text
import Accelerate
// LUղ͔Β࿈ཱํఔࣜΛղ͘
func solve(_ A: [Double], _ B: [Double]) -> [Double] {
var inMatrix = A, solution = B
var N = __CLPK_integer( sqrt( Double( A.count ) ) )
var N2 = N, N3 = N, LDA = N, LDB = N
var NRHS: __CLPK_integer = 1
var pivots = [__CLPK_integer](repeating: 0, count: Int(N))
var error: __CLPK_integer = 0
dgetrf_(&N, &N2, &inMatrix, &N3, &pivots, &error)
var t = "T".cString(using: .utf8)!.first!
dgetrs_(&t, &N, &NRHS, &inMatrix, &LDA, &pivots, &solution, &LDB, &error)
return solution
}