While FloatingPointType can be initialized from various Int type variants, it seems to be missing an initializer from Double/Float. Similarly, there are no initializers from FloatingPointType to Double/Float. Is this intentional?
I've tried implementing the following: // https://en.wikipedia.org/wiki/Window_function#Tukey_window public func tukeyWindowFunc(index: Int, N: Int) -> Double { let L = N/8 let indexAbs = min(index, N-1-index) if indexAbs >= L { return 1.0 } else { let r = Double(indexAbs) / Double(L) return 0.5*(1.0 + cos(M_PI * (r - 1.0))) } } extension Array where Element: FloatingPointType { public func tukeyWindowArray() -> [Element] { return (0..<count).map{self[$0] * tukeyWindowFunc($0, N: count)} } } The extension failed to compile no matter how I spun it, since Double and FloatingPointType can't multiply each other and neither type can be cast to the other. I would settle for extending just Array<Double>, but that isn't supported yet either ;) Cheers, Dan
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
