MakeDenseMatrix makes a new slice for A.elements, then loses it to the garbage collector by assigning the parameter elements. The intent isn't documented and seems ambiguous from the code. Maybe the make should be deleted, or maybe data should be copied from the parameter.