<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The draft proposal may be easier reading:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md" class="">https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md</a></div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 7, 2016, at 11:16 AM, Max Moiseev via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Dan,</div><div class=""><br class=""></div><div class="">New protocols are in the making for both integers and floating point numbers.</div><div class=""><br class=""></div><div class="">You particular problem is addressed here: <a href="https://github.com/stephentyrone/swift/commits/floating-point-revision" class="">https://github.com/stephentyrone/swift/commits/floating-point-revision</a></div><div class=""><br class=""></div><div class="">max</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 30, 2016, at 6:36 AM, Dan Raviv via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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?<br class=""><br class="">I've tried implementing the following:<br class=""><br class="">// <a href="https://en.wikipedia.org/wiki/Window_function#Tukey_window" class="">https://en.wikipedia.org/wiki/Window_function#Tukey_window</a><div class="">public func tukeyWindowFunc(index: Int, N: Int) -> Double {<br class=""> let L = N/8<br class=""> let indexAbs = min(index, N-1-index)<br class=""> if indexAbs >= L {<br class=""> return 1.0<br class=""> }<br class=""> else {<br class=""> let r = Double(indexAbs) / Double(L)<br class=""> return 0.5*(1.0 + cos(M_PI * (r - 1.0)))<br class=""> }<br class="">}<br class=""><br class="">extension Array where Element: FloatingPointType {<br class=""> public func tukeyWindowArray() -> [Element] {<br class=""> return (0..<count).map{self[$0] * tukeyWindowFunc($0, N: count)}<br class=""> }<br class="">}<br class=""><br class="">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.<div class=""><br class=""></div><div class="">I would settle for extending just Array<Double>, but that isn't supported yet either ;)</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Dan</div></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>