make_row i = generate (lambda i)
+-- | Create an identity matrix with the right dimensions.
+--
+-- Examples:
+--
+-- >>> identity_matrix :: Mat3 Int
+-- ((1,0,0),(0,1,0),(0,0,1))
+-- >>> identity_matrix :: Mat3 Double
+-- ((1.0,0.0,0.0),(0.0,1.0,0.0),(0.0,0.0,1.0))
+--
+identity_matrix :: (Arity m, Ring.C a) => Mat m m a
+identity_matrix =
+ construct (\i j -> if i == j then (fromInteger 1) else (fromInteger 0))
-- | Given a positive-definite matrix @m@, computes the
-- upper-triangular matrix @r@ with (transpose r)*r == m and all