<commit_before>// RUN: %target-run-simple-swift | FileCheck %s
// FIXME: fails on iOS
// REQUIRES: OS=macosx

import GLKit

let x = GLKVector4Make(1, 0, 0, 0)
let y = GLKVector4Make(0, 1, 0, 0)
let z = GLKVector4Make(0, 0, 1, 0)


println(GLKVector4DotProduct(x, y)) // CHECK: 0.0

let z2 = GLKVector4CrossProduct(x, y)
println(GLKVector4AllEqualToVector4(z, z2)) // CHECK-NEXT: true

infix operator • { precedence 150 }
infix operator ⨉ { precedence 150 }
func •(x: GLKVector4, y: GLKVector4) -> Float {
  return GLKVector4DotProduct(x, y)
}
func ⨉(x: GLKVector4, y: GLKVector4) -> GLKVector4 {
  return GLKVector4CrossProduct(x, y)
}
func ==(x: GLKVector4, y: GLKVector4) -> Bool {
  return GLKVector4AllEqualToVector4(x, y)
}

println(x • y) // CHECK-NEXT: 0.0
println(x ⨉ y == z) // CHECK-NEXT: true<commit_msg>Exercise more GLKit APIs.<commit_after>// RUN: %target-run-simple-swift | FileCheck %s
// FIXME: fails on iOS
// FIXME: fails in JIT mode
// REQUIRES: OS=macosx

import GLKit

let x = GLKVector4Make(1, 0, 0, 0)
let y = GLKVector4Make(0, 1, 0, 0)
let z = GLKVector4Make(0, 0, 1, 0)

println(GLKVector4DotProduct(x, y)) // CHECK: 0.0

let z2 = GLKVector4CrossProduct(x, y)
println(GLKVector4AllEqualToVector4(z, z2)) // CHECK-NEXT: true

infix operator • { precedence 150 associativity left }
infix operator ⨉ { precedence 150 }
func •(x: GLKVector4, y: GLKVector4) -> Float {
  return GLKVector4DotProduct(x, y)
}
func ⨉(x: GLKVector4, y: GLKVector4) -> GLKVector4 {
  return GLKVector4CrossProduct(x, y)
}
func ==(x: GLKVector4, y: GLKVector4) -> Bool {
  return GLKVector4AllEqualToVector4(x, y)
}

println(x • y) // CHECK-NEXT: 0.0
println(x ⨉ y == z) // CHECK-NEXT: true

let flipXY = GLKMatrix4Make(0, 1, 0, 0,
                            1, 0, 0, 0,
                            0, 0, 1, 0,
                            0, 0, 0, 1)
// FIXME: GLKMatrix4MakeWithArray takes mutable pointer arguments for no
// good reason. rdar://problem/19124355
var flipYZElements: [Float] = [1, 0, 0, 0,
                               0, 0, 1, 0,
                               0, 1, 0, 0,
                               0, 0, 0, 1]
let flipYZ = GLKMatrix4MakeWithArray(&flipYZElements)

let rotateXYZ = GLKMatrix4Multiply(flipYZ, flipXY)

let y3 = GLKMatrix4MultiplyVector4(flipXY, x)
println(y == y3) // CHECK-NEXT: true

let y4 = GLKMatrix4MultiplyVector4(flipYZ, z)
println(y == y4) // CHECK-NEXT: true

let z3 = GLKMatrix4MultiplyVector4(rotateXYZ, x)
println(z == z3) // CHECK-NEXT: true

func •(x: GLKMatrix4, y: GLKMatrix4) -> GLKMatrix4 {
  return GLKMatrix4Multiply(x, y)
}
func •(x: GLKMatrix4, y: GLKVector4) -> GLKVector4 {
  return GLKMatrix4MultiplyVector4(x, y)
}

println(y == flipXY • x) // CHECK-NEXT: true
println(x == flipXY • y) // CHECK-NEXT: true
println(z == flipXY • z) // CHECK-NEXT: true
println(x == flipYZ • x) // CHECK-NEXT: true
println(z == flipYZ • y) // CHECK-NEXT: true
println(y == flipYZ • z) // CHECK-NEXT: true
println(z == rotateXYZ • x) // CHECK-NEXT: true
println(x == rotateXYZ • y) // CHECK-NEXT: true
println(y == rotateXYZ • z) // CHECK-NEXT: true
println(z == flipYZ • flipXY • x) // CHECK-NEXT: true
println(x == flipYZ • flipXY • y) // CHECK-NEXT: true
println(y == flipYZ • flipXY • z) // CHECK-NEXT: true
{'fraction_non_alphanumeric': 0.14671577655003068, 'fraction_numerical': 0.045733578882750155, 'mean_word_length': 3.162196679438059, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607260', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1266, 'n_words': 366}