Search code examples
arraysswiftuint32

UInt32 array to Double array Swift


I need to multiply 2 matrices in swift, so in order to use accelerate I need 2 arrays with type double. The issue is, the two arrays that I need to multiply are type UInt32. Is there anyway to convert a UInt32 array to a double array?

var UInt32TestArray: [UInt32] = [1,4,2,3]
var Int32TestArray: [Double] = [Double](UInt32) //Doesn't work

Solution

  • Use

    UInt32TestArray.map { Double($0) }
    

    to get an array of Double.