[pure-lang-svn] SF.net SVN: pure-lang:[822] pure/trunk/lib/primitives.pure
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-09-22 00:23:33
|
Revision: 822
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=822&view=rev
Author: agraef
Date: 2008-09-22 00:23:30 +0000 (Mon, 22 Sep 2008)
Log Message:
-----------
Optimize the case of contiguous slices.
Modified Paths:
--------------
pure/trunk/lib/primitives.pure
Modified: pure/trunk/lib/primitives.pure
===================================================================
--- pure/trunk/lib/primitives.pure 2008-09-21 23:02:11 UTC (rev 821)
+++ pure/trunk/lib/primitives.pure 2008-09-22 00:23:30 UTC (rev 822)
@@ -435,7 +435,15 @@
/* Slices. */
-x::matrix!!(ns,ms) = colcatmap (mth (rowcatmap (nth x) ns)) ms with
+x::matrix!!(ns,ms) = case ns,ms of
+ // optimize the case of contiguous slices
+ ns@(n:_),ms@(m:_) = submat x (n,m) (#ns,#ms)
+ if cont ns && cont ms;
+ _ = colcatmap (mth (rowcatmap (nth x) ns)) ms;
+ end with
+ cont [n] = 1;
+ cont (n::int:ns@(m::int:_)) = cont ns if m==n+1;
+ cont _ = 0 otherwise;
nth x n = catch (cst {}) (row x n);
mth x m = catch (cst {}) (col x m);
end;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|