         let _blue = blue * normalizeMatrix
         let _white = white * normalizeMatrix
         
-        let s = _white * Matrix(a: _red.X, b: _green.X, c: _blue.X, d: 0,
-                                e: _red.Y, f: _green.Y, g: _blue.Y, h: 0,
-                                i: _red.Z, j: _green.Z, k: _blue.Z, l: 0).inverse
+        let s = _white * Matrix(a: _red.x, b: _green.x, c: _blue.x, d: 0,
+                                e: _red.y, f: _green.y, g: _blue.y, h: 0,
+                                i: _red.z, j: _green.z, k: _blue.z, l: 0).inverse
         
-        return Matrix(a: s.X * _red.X, b: s.Y * _green.X, c: s.Z * _blue.X, d: 0,
-                      e: s.X * _red.Y, f: s.Y * _green.Y, g: s.Z * _blue.Y, h: 0,
-                      i: s.X * _red.Z, j: s.Y * _green.Z, k: s.Z * _blue.Z, l: 0)
+        return Matrix(a: s.x * _red.x, b: s.y * _green.x, c: s.z * _blue.x, d: 0,
+                      e: s.x * _red.y, f: s.y * _green.y, g: s.z * _blue.y, h: 0,
+                      i: s.x * _red.z, j: s.y * _green.z, k: s.z * _blue.z, l: 0)
     }
     
     public var cieXYZ: CIEXYZColorSpace {

public struct XYZColorModel : ColorModelProtocol {
    
    /// The Y luminance component.
    public var X: Double
    /// The Cb chroma component.
    public var Y: Double
    /// The Cr chroma component.
    public var Z: Double
    
    public var x: Double {
        get {
            return X / (X + Y + Z)
        }
        set {
            self = XYZColorModel(x: newValue, y: y, luminance: luminance)
        }
    }
    public var y: Double {
        get {
            return Y / (X + Y + Z)
        }
        set {
            self = XYZColorModel(x: x, y: newValue, luminance: luminance)
        }
    }
    
    public var luminance: Double {
        get {
            return Y
        }
        set {
            self.Y = newValue
        }
    }
    
    public init(x: Double, y: Double, z: Double) {
        self.X = x
        self.Y = y
        self.Z = z
    }
    
    public init(x: Double, y: Double, luminance: Double) {
        let _y = 1 / y
        self.X = x * _y * luminance
        self.Y = luminance
        self.Z = (1 - x - y) * _y * luminance
    }
}

extension XYZColorModel : CustomStringConvertible {
    
    public var description: String {
        return "XYZColorModel(x: \(X), y: \(Y), z: \(Z))"
    }
}

public func * <T: MatrixProtocol>(lhs: XYZColorModel, rhs: T) -> XYZColorModel {
    return XYZColorModel(x: lhs.X * rhs.a + lhs.Y * rhs.b + lhs.Z * rhs.c + rhs.d, y: lhs.X * rhs.e + lhs.Y * rhs.f + lhs.Z * rhs.g + rhs.h, z: lhs.X * rhs.i + lhs.Y * rhs.j + lhs.Z * rhs.k + rhs.l)
}

public func *= <T: MatrixProtocol>(lhs: inout XYZColorModel, rhs: T) {

        let matrix = algorithm.matrix
        let _s = self.white * matrix
        let _d = other.white * matrix
        return color * matrix * Matrix.Scale(x: _d.x / _s.x, y: _d.y / _s.y, z: _d.z / _s.z) * matrix.inverse
    }
}

