[swift-users] Swift Initializer Generics
David Turnbull
dturnbull at gmail.com
Mon Jan 18 19:50:18 CST 2016
SwiftGL isn't "naive Swift" except where it can't use the SIMD module.
-david
On Mon, Jan 18, 2016 at 5:09 PM, Dmitri Gribenko <gribozavr at gmail.com>
wrote:
> 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>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160118/1541c310/attachment.html>
More information about the swift-users
mailing list