<commit_before>// Vector structs for Swift
// Copyright (c) 2015 phelgo. MIT licensed.

import SceneKit

public struct Vector4D: DebugPrintable, Equatable, Hashable, Printable {
    public let x: Double
    public let y: Double
    public let z: Double
    public let w: Double
    
    public init(_ x: Double, _ y: Double, _ z: Double, _ w: Double) {
        self.x = x
        self.y = y
        self.z = z
        self.w = w
    }
    
    public var magnitude: Double {
        return sqrt(x * x + y * y + z * z + w * w)
    }
    
    public var normalized: Vector4D {
        return Vector4D(x / magnitude, y / magnitude, z / magnitude, w / magnitude)
    }
    
    public var description: String {
        return "Vector4D(\(x), \(y), \(z), \(w))"
    }
    
    public var debugDescription: String {
        return "Vector4D(\(x), \(y), \(z), \(w)), magnitude: \(magnitude)"
    }
    
    public var hashValue: Int {
        return x.hashValue ^ y.hashValue ^ z.hashValue ^ w.hashValue
    }
    
    public static let zero = Vector4D(0, 0, 0, 0)
    public static let one = Vector4D(1, 1, 1, 1)
}

public func == (left: Vector4D, right: Vector4D) -> Bool {
    return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w)
}

public func + (left: Vector4D, right: Vector4D) -> Vector4D {
    return Vector4D(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w)
}

public func - (left: Vector4D, right: Vector4D) -> Vector4D {
    return Vector4D(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w)
}

public func += (inout left: Vector4D, right: Vector4D) {
    left = left + right
}

public func -= (inout left: Vector4D, right: Vector4D) {
    left = left - right
}

public prefix func - (vector: Vector4D) -> Vector4D {
    return Vector4D(-vector.x, -vector.y, -vector.z, -vector.w)
}

public extension SCNVector4 {
    init (_ value: Vector4D) {
        self.x = Float(value.x)
        self.y = Float(value.y)
        self.z = Float(value.z)
        self.w = Float(value.w)
    }
}

public prefix func ~ (vector: Vector4D) -> SCNVector4 {
    return SCNVector4(vector)
}
<commit_msg>Implement multiplication between a Double and a Vector4D<commit_after>// Vector structs for Swift
// Copyright (c) 2015 phelgo. MIT licensed.

import SceneKit

public struct Vector4D: DebugPrintable, Equatable, Hashable, Printable {
    public let x: Double
    public let y: Double
    public let z: Double
    public let w: Double
    
    public init(_ x: Double, _ y: Double, _ z: Double, _ w: Double) {
        self.x = x
        self.y = y
        self.z = z
        self.w = w
    }
    
    public var magnitude: Double {
        return sqrt(x * x + y * y + z * z + w * w)
    }
    
    public var normalized: Vector4D {
        return Vector4D(x / magnitude, y / magnitude, z / magnitude, w / magnitude)
    }
    
    public var description: String {
        return "Vector4D(\(x), \(y), \(z), \(w))"
    }
    
    public var debugDescription: String {
        return "Vector4D(\(x), \(y), \(z), \(w)), magnitude: \(magnitude)"
    }
    
    public var hashValue: Int {
        return x.hashValue ^ y.hashValue ^ z.hashValue ^ w.hashValue
    }
    
    public static let zero = Vector4D(0, 0, 0, 0)
    public static let one = Vector4D(1, 1, 1, 1)
}

public func == (left: Vector4D, right: Vector4D) -> Bool {
    return (left.x == right.x) && (left.y == right.y) && (left.z == right.z) && (left.w == right.w)
}

public func + (left: Vector4D, right: Vector4D) -> Vector4D {
    return Vector4D(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w)
}

public func - (left: Vector4D, right: Vector4D) -> Vector4D {
    return Vector4D(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w)
}

public func += (inout left: Vector4D, right: Vector4D) {
    left = left + right
}

public func -= (inout left: Vector4D, right: Vector4D) {
    left = left - right
}

public func * (value: Double, vector: Vector4D) -> Vector4D {
    return Vector4D(value * vector.x, value * vector.y, value * vector.z, value * vector.w)
}

public func * (vector: Vector4D, value: Double) -> Vector4D {
    return value * vector
}

public prefix func - (vector: Vector4D) -> Vector4D {
    return Vector4D(-vector.x, -vector.y, -vector.z, -vector.w)
}

public extension SCNVector4 {
    init (_ value: Vector4D) {
        self.x = Float(value.x)
        self.y = Float(value.y)
        self.z = Float(value.z)
        self.w = Float(value.w)
    }
}

public prefix func ~ (vector: Vector4D) -> SCNVector4 {
    return SCNVector4(vector)
}

{'fraction_non_alphanumeric': 0.14103946517144705, 'fraction_numerical': 0.01897778736251887, 'mean_word_length': 2.3780043699927167, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7210770', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1629, 'n_words': 485}