       res = matrix_mult m, [[rl], [gl], [bl]]
       [res[0][0], res[1][0], res[2][0]]
   _CIExyY:
-    to: (tuple) ->
-      _X = tuple[0]
-      _Y = tuple[1]
-      _Z = tuple[2]
+    to: (_X, _Y, _Z) ->
       sum = _X + _Y + _Z
       [_X / sum, _Y / sum, _Y]
-    from: (tuple) ->
-      _x = tuple[0]
-      _y = tuple[1]
-      _Y = tuple[2]
+    from: (_x, _y, _Y) ->
       _X = _Y / _y * _x
       _Z = _Y / _y * (1 - _x - _y)
       [_X, _Y, _X]
   _CIELAB:
-    to: (tuple) ->
-      _X = tuple[0]
-      _Y = tuple[1]
-      _Z = tuple[2]
+    to: (_X, _Y, _Z) ->
+      _X = _X / white_point[0]
+      _Y = _Y / white_point[1]
+      _Z = _Z / white_point[2]
       f = (t) ->
         if t > Math.pow(6 / 29, 3)
           Math.pow(t, 1 / 3)

      _a = 500 * (f(_X) - f(_Y))
      _b = 200 * (f(_Y) - f(_Z))
      [_L, _a, _b]
    from: (tuple) ->
      _L = tuple[0]
      _a = tuple[1]
      _b = tuple[2]
      f_inv = (t) ->
        if t > 6 / 29
          Math.pow(t, 3)
        else
          3 * Math.pow(6 / 29, 2) * (t - 4 / 29)
      _Y = f_inv 1 / 116 * (_L + 16)
      _X = f_inv 1 / 116 * (_L + 16) + 1 / 500 * _a
      _Z = f_inv 1 / 116 * (_L + 16) - 1 / 200 * _b
      [_X, _Y, _Z]

get_color = (space, tuple) ->
  color = conv["_" + space].from(tuple)
  as: (space) ->
    conv["_" + space].to(color)

if jQuery?
  exports =

          ab[i].push dot_product get_row(a, i), get_col(b, j)
  return ab

# The D65 standard illuminant
white_point = [95.047, 100.000, 108.883]

# Functions for converting between CIE XYZ and other color spaces
