anchor.diff:    (declare (type mat template) (type (or null mat) store))
     (the mat (or store (vec-copy template))))
   
  -;;;; * Matrix Multiplication With a Scalar
  -;;;
  -
  -(defun mat-scale (m s &optional store)
  +
  +;;;; * Scale
  +;;;;
  +
  +(defun make-mat4-from-scale (&key xscale yscale zscale (uniform-scale 1.0))
  +  (let ((xs (or xscale uniform-scale))
  +        (ys (or yscale uniform-scale))
  +        (zs (or zscale uniform-scale)))
  +    (make-mat4 :m00 xs :m11 ys :m22 zs)))
  +
  +(defun mat4<-scale (s)
  +  "Construct a matrix with a scale"
  +  (with-vector-elements (x y z) s
  +    (mat4 x 0.0 0.0 0.0 0.0 y 0.0 0.0 0.0 0.0 z 0.0 0.0 0.0 0.0 1.0)))
  +
  +(defvecfun mat2-scale (((m00 m01 m10 m11) m) s)
  +  ((:documentation "Add a scale component to the 2D transformation."))
  +  (mat2-mul* m00 m01 m10 m11
  +             s   0.0 0.0 s))
  +
  +(defvecfun mat32-scale (((m00 m01 m02 m10 m11 m12 m20 m21 m22) m) s)
  +  ((:documentation "Add a uniform scale component to the 2D transformation."))
  +    (mat3-mul* m00 m01 m02 m10 m11 m12
  +               s   0.0 0.0 0.0 s   0.0))
  +
  +(defvecfun mat3-scale (((m00 m01 m02 m10 m11 m12 m20 m21 m22) m) s)
  +    ((:documentation "Add a uniform scale component to the 3D transformation."))
  +    (mat3-mul* m00 m01 m02 m10 m11 m12 m20 m21 m22
  +               s   0.0 0.0 0.0 s   0.0 0.0 0.0 s))
  +
  +(defvecfun mat4-scale (((m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33) m) s)
  +    ((:documentation "Add a uniform scale component to the 3D transformation."))
  +  (mat4-mul* m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33
  +             s   0.0 0.0 0.0 0.0 s   0.0 0.0 0.0 0.0 s   0.0 0.0 0.0 0.0 1.0))
  +
  +;;;; * Rotation
  +;;;;
  +
  +
  +
  +;;;; * Translation
  +;;;;
  +
  +(defun mat4<-translation (v)
  +  "Construct a matrix with a translation."
  +  (with-vector-elements (x y z) v
  +    (mat4 1.0 0.0 0.0 x
  +          0.0 1.0 0.0 y
  +          0.0 0.0 1.0 z
  +          0.0 0.0 0.0 1.0)))
  +
  +(defvecfun mat4-translate (((m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33) m) x y z)
  +  ((:documentation "Add a translation component to the 3D transformation."))
  +  (mat4-mul* m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33
  +             x   0.0 0.0 0.0 0.0 y   0.0 0.0 0.0 0.0 z   0.0 0.0 0.0 0.0 1.0))
  +
  +;;;; * Matrix Multiplication with a Scalar
  +;;;
  +
  +(defun mat-scalar-mul (m s &optional store)
     "Multiplicate a matrix with a scalar."
     (declare (type mat m) (type scalar s) (type (or null mat) store))
     (map-into (mat-ensure-store m store) #'(lambda (a) (* a s)) m))
   
  -(defvecfun mat2-scale (((m00 m01 m10 m11) m) s)
  +(defvecfun mat2-scalar-mul (((m00 m01 m10 m11) m) s)
       ((:documentation "Multiplicate a two dimensional matrix with a scalar."))
     (values (* m00 s) (* m01 s) (* m10 s) (* m11 s)))
   
  -(defvecfun mat3-scale (((m00 m01 m02 m10 m11 m12 m20 m21 m22) m) s)
  +(defvecfun mat3-scalar-mul (((m00 m01 m02 m10 m11 m12 m20 m21 m22) m) s)
       ((:documentation "Multiplicate a three dimensional matrix with a scalar."))
     (values (* m00 s) (* m01 s) (* m02 s)
             (* m10 s) (* m11 s) (* m12 s)
             (* m20 s) (* m21 s) (* m22 s)))
   
  -(defvecfun mat4-scale (((m00 m01 m02 m03
  -                       m10 m11 m12 m13
  -                       m20 m21 m22 m23
  -                       m30 m31 m32 m33) m) s)
  +(defvecfun mat4-scalar-mul (((m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33) m) s)
       ((:documentation "Multiplicate a matrix in homogenous space with a scalar."))
     (values (* m00 s) (* m01 s) (* m02 s) (* m03 s)
             (* m10 s) (* m11 s) (* m12 s) (* m13 s)
  
positive.code:     (loop for i from 0 below rows do
           (loop for j from 0 below rows do
                (setf (row-major-aref dst (+ (* i rows) j))
                      (loop for k from 0 below rows 
                         sum (* (row-major-aref m (+ (* i rows) k))
                                (row-major-aref n (+ (* k rows) j))))))
           finally (return dst))))
  
negative.code:   (let ((det (mat3-determinant* m00 m01 m02 m10 m11 m12 m20 m21 m22)))
      (if (= +scalar-zero+ det)
          (values m00 m01 m02 m10 m11 m12 m20 m21 m22)
          (mat3-scalar-mul* (- (* m11 m22) (* m12 m21))
                            (- (* m02 m21) (* m01 m22))
                            (- (* m01 m12) (* m02 m11))
                            (- (* m12 m20) (* m10 m22))
                            (- (* m00 m22) (* m02 m20))
                            (- (* m02 m10) (* m00 m12))
                            (- (* m10 m21) (* m11 m20))
                            (- (* m01 m20) (* m00 m21))
                            (- (* m00 m11) (* m01 m10))
                            (invert det)))))
  
  
  ;;;; * Matrix Negation
  ;;;
  
  (defun mat-negate (m &optional store)
    (map-into (mat-ensure-store store) #'negate m))
  
  (defvecfun mat2-negate (((m00 m01 m10 m11) m))
      ((:documentation "Negate the matrix."))
    (values (- m00) (- m01)
            (- m10) (- m11)))
  
  (defvecfun mat3-negate (((m00 m01 m02 m10 m11 m12 m20 m21 m22) m))
  