[pure-lang-svn] SF.net SVN: pure-lang:[827] pure/trunk/lib/primitives.pure
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-09-22 17:46:52
|
Revision: 827
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=827&view=rev
Author: agraef
Date: 2008-09-22 17:46:47 +0000 (Mon, 22 Sep 2008)
Log Message:
-----------
Add operation to pack matrices obtained as slices from larger matrices.
Modified Paths:
--------------
pure/trunk/lib/primitives.pure
Modified: pure/trunk/lib/primitives.pure
===================================================================
--- pure/trunk/lib/primitives.pure 2008-09-22 17:24:18 UTC (rev 826)
+++ pure/trunk/lib/primitives.pure 2008-09-22 17:46:47 UTC (rev 827)
@@ -489,6 +489,14 @@
colcatmap f [] = {};
colcatmap f xs@(_:_) = colcat (map f xs);
+/* 'Pack' a matrix. This creates a copy of the matrix which has the data in
+ contiguous storage. If possible, it also frees up extra memory if the
+ matrix was created as a slice from a bigger matrix. The 'packed' predicate
+ can be used to verify whether a matrix is already packed. */
+
+pack x::matrix = colcat [x,{}];
+packed x::matrix = stride x==dim x!1;
+
/* Transpose a matrix. */
private matrix_transpose;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|