[swift-users] Swift Initializer Generics
Dmitri Gribenko
gribozavr at gmail.com
Mon Jan 18 19:09:18 CST 2016
On Mon, Jan 18, 2016 at 5:06 PM, David Turnbull via swift-users
<swift-users at swift.org> wrote:
> How about this...
>
> public func dot<genType:FloatingPointVectorType>(x:genType, _ y:genType) ->
> genType.Element {
>
> let a = genType(x, y, *)
>
> return a.reduce(genType.Element(0)) { $0 + ($1 as! genType.Element) }
>
> }
This won't be calling into Accelerate. The assumption is that
Accelerate is manually-optimized and heavily tuned, and it will be
faster than a naive Swift implementation.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the swift-users
mailing list