Skip to content

Instantly share code, notes, and snippets.

@ynagatomo
Created June 1, 2022 04:03
Show Gist options
  • Save ynagatomo/b55dae8a1e4b7817ce4e9d90fda68b0d to your computer and use it in GitHub Desktop.
Save ynagatomo/b55dae8a1e4b7817ce4e9d90fda68b0d to your computer and use it in GitHub Desktop.
// SIMD - Initializers
SIMD3<Int>()
SIMD3<Double>(SIMD3<Double>())
SIMD3<Double>(1, 2, 3)
SIMD3<Int8>(SIMD3<Double>(1.9, -1.9, -1.1), rounding: .towardZero)
SIMD3<Int8>(arrayLiteral: 1, 2, 3)
SIMD3<Int8>(clamping: SIMD3<Int>(200, -200, 100))
SIMD3<UInt8>(clamping: SIMD3<Int>(200, -200, 100))
SIMD3<Int8>(truncatingIfNeeded: SIMD3<Int>(512, 511, 100))
SIMD3<Int8>([1, 2, 3])
SIMD3<Int8>(repeating: 1)
// Type properties
SIMD3<Int8>.one
SIMD3<Double>.zero
SIMD8<Int>.scalarCount
// Type methods
SIMD3<Int8>.random(in: 0...100)
SIMD3<Double>.random(in: 0...1)
// Instance properties
SIMD3<Int8>.zero.indices
SIMD3<Int8>.one.scalarCount
// Instance methods
SIMD3<Double>.one.addingProduct(2.0, SIMD3<Double>(1.0, 2.0, 3.0))
SIMD3<Double>.one.addingProduct(SIMD3<Double>(1, 2, 3), SIMD3<Double>(4, 5, 6))
SIMD3<Double>(-0.5, 0.5, 1.5).clamped(lowerBound: SIMD3<Double>.zero, upperBound: SIMD3<Double>.one)
SIMD3<Int>(-2, 0, 2).clamped(lowerBound: SIMD3<Int>.zero, upperBound: SIMD3<Int>.one)
SIMD3<Double>(1, 2, 3).squareRoot()
SIMD3<Int>(1, 2, 3).max()
SIMD3<Double>(0.1, 0.2, 0.3).min()
SIMD3<Double>(1, 2, 3).replacing(with: 4, where: SIMDMask<SIMD3<Double>.MaskStorage>(arrayLiteral: true, true, false))
SIMD3<Double>(1.9, -1.9, 1.1).rounded(.towardZero)
SIMD3<Double>(1, 2, 3).sum()
SIMD3<Int>(1, 2, 3).wrappedSum()
SIMD3<Int8>(127, 1, 1).wrappedSum()
// Operators
SIMD2<Int8>(2, 64) &* SIMD2<Int8>(3, 4)
SIMD2<Int8>(2, 64) &+ SIMD2<Int8>(3, 64)
SIMD2<Int8>(2, -64) &- SIMD2<Int8>(2, 65)
SIMD2<UInt8>(255, 128) & SIMD2<UInt8>(1, 1)
SIMD2<UInt8>(128, 128) | SIMD2<UInt8>(64, 128)
SIMD2<UInt8>(255, 128) ^ SIMD2<UInt8>(128, 255)
~SIMD2<UInt8>(255, 128)
SIMD2<UInt8>(64, 64) &<< SIMD2<UInt8>(1, 2)
SIMD2<UInt8>(128, 128) &>> SIMD2<UInt8>(1, 8)
SIMD2<Int8>(100, 99) % Int8(33)
SIMD2<Int8>(100, 99) / Int8(33)
SIMD2<Double>(1, 2) * Double(10)
SIMD2<Double>(1, 2) * SIMD2<Double>(10, -10)
SIMD2<Double>(1, 2) == SIMD2<Double>(1, 2)
SIMD2<Double>(1, 2) != SIMD2<Double>(1, 3)
SIMD2<Double>(1, 2) .== SIMD2<Double>(1, 3)
SIMD2<Int>(1, 2) .> SIMD2<Int>(1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment