[pure-lang-svn] SF.net SVN: pure-lang:[849] pure/trunk/lib
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-24 13:08:22
|
Revision: 849 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=849&view=rev Author: agraef Date: 2008-09-24 13:08:16 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Fix some minor glitches, comment changes. Modified Paths: -------------- pure/trunk/lib/matrices.pure pure/trunk/lib/prelude.pure Modified: pure/trunk/lib/matrices.pure =================================================================== --- pure/trunk/lib/matrices.pure 2008-09-24 07:57:03 UTC (rev 848) +++ pure/trunk/lib/matrices.pure 2008-09-24 13:08:16 UTC (rev 849) @@ -130,7 +130,8 @@ nth x n = catch (cst {}) (row x n); mth x m = catch (cst {}) (col x m); end; -x::matrix!!ns = if packed x then rowvector x!!([0],ns) +x::matrix!!ns = if all intp ns && packed x + then rowvector x!!([0],ns) else colcatmap (nth x) ns with nth x n = catch (cst {}) {x!n}; end; @@ -243,7 +244,10 @@ /* Pack a matrix. This creates a copy of the matrix which has the data in contiguous storage. It also frees up extra memory if the matrix was created as a slice from a bigger matrix (see 'submat' above). The 'packed' - predicate can be used to verify whether a matrix is already packed. */ + predicate can be used to verify whether a matrix is already packed. Note + that even if a matrix is already packed, 'pack' will make a copy of it + anyway, so this routine also provides a quick way to copy a matrix, e.g., + if you want to pass it as an input/output parameter to a GSL routine. */ pack x::matrix = colcat [x,{}]; packed x::matrix = stride x==dim x!1; Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-09-24 07:57:03 UTC (rev 848) +++ pure/trunk/lib/prelude.pure 2008-09-24 13:08:16 UTC (rev 849) @@ -243,13 +243,14 @@ stream () = []; stream xs@(_,_) = stream (list xs); -/* Slicing. xs!!ns returns the list of xs!n for all members n of the index - list ns which are in the valid index range. This is a generic definition - which will work with any kind of container data structure which defines (!) - in such a manner that it throws an exception when the index is out of - bounds. */ +/* Slicing. xs!!ns returns the list (or tuple) of xs!n for all members n of + the index list ns which are in the valid index range. This is a generic + definition which will work with any kind of container data structure which + defines (!) in such a manner that it throws an exception when the index is + out of bounds. */ -xs!!ns = catmap (nth xs) ns +xs!!ns = if tuplep xs then tuple ys else ys + when ys = catmap (nth xs) ns end with nth xs n = catch (cst []) [xs!n] end; /* Arithmetic sequences. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |