Thread: [pure-lang-svn] SF.net SVN: pure-lang:[475] pure/trunk/lib/primitives.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-12 19:17:25
|
Revision: 475 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=475&view=rev Author: agraef Date: 2008-08-12 19:17:34 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Cosmetic changes. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-12 13:59:55 UTC (rev 474) +++ pure/trunk/lib/primitives.pure 2008-08-12 19:17:34 UTC (rev 475) @@ -21,8 +21,7 @@ /* Throw an exception. */ -extern void pure_throw(expr*); // IMPURE! -throw x = pure_throw x; +extern void pure_throw(expr*) = throw; // IMPURE! /* Convenience function to ensure a condition p. Returns 1 (true) if p holds, and throws the given exception e otherwise. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-08-14 13:56:38
|
Revision: 497 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=497&view=rev Author: agraef Date: 2008-08-14 13:56:45 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Fix typo. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-14 13:37:16 UTC (rev 496) +++ pure/trunk/lib/primitives.pure 2008-08-14 13:56:45 UTC (rev 497) @@ -105,7 +105,6 @@ uint x::int = if x>=0 then bigint x else x+0x100000000L; ulong x::bigint = if x>=0 then x else x+0x10000000000000000L; - /* Absolute value and sign of a number. */ abs x::int | abs x::bigint | abs x::double This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-08-14 23:14:16
|
Revision: 501 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=501&view=rev Author: agraef Date: 2008-08-14 23:14:26 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Fix some minor glitches in the pow function. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-14 23:10:55 UTC (rev 500) +++ pure/trunk/lib/primitives.pure 2008-08-14 23:14:26 UTC (rev 501) @@ -332,8 +332,8 @@ extern expr* bigint_pow(void*, int), double pow(double, double) = c_pow; pow x::int y::int = bigint_pow (bigint x) y if y>=0; -pow x::bigint y::bigint = bigint_pow x (int y) if int y>=0; -pow x::double y::double = c_pow x y if x>=0 || int y==y; +pow x::bigint y::bigint = bigint_pow x (int y) if y>=0; +pow x::double y::double = c_pow x y if x>=0 || frac y==0.0; // mixed int/bigint pow x::int y::bigint = bigint_pow (bigint x) (int y) if y>=0; @@ -343,12 +343,12 @@ pow x::double y::int | pow x::double y::bigint = c_pow x (double y); pow x::int y::double | -pow x::bigint y::double = c_pow (double x) y if x>=0 || int y==y; +pow x::bigint y::double = c_pow (double x) y if x>=0 || frac y==0.0; /* The ^ operator. Works like pow, but always promotes its operands to double and returns a double result. */ -x::double^y::double = c_pow x y if x>=0 || int y==y; +x::double^y::double = c_pow x y if x>=0 || frac y==0.0; x::int^y::int | x::bigint^y::bigint | x::int^y::bigint | @@ -356,7 +356,7 @@ x::double^y::int | x::double^y::bigint = c_pow x (double y); x::int^y::double | -x::bigint^y::double = c_pow (double x) y if x>=0 || int y==y; +x::bigint^y::double = c_pow (double x) y if x>=0 || frac y==0.0; = double x^y otherwise; /* Pointer arithmetic. We do this using bigints, so that the code is portable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-08-21 22:46:57
|
Revision: 560 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=560&view=rev Author: agraef Date: 2008-08-21 22:47:08 +0000 (Thu, 21 Aug 2008) Log Message: ----------- Add missing nan check to ^ operator. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-21 21:59:02 UTC (rev 559) +++ pure/trunk/lib/primitives.pure 2008-08-21 22:47:08 UTC (rev 560) @@ -359,7 +359,7 @@ /* The ^ operator. Works like pow, but always promotes its operands to double and returns a double result. */ -x::double^y::double = c_pow x y if x>=0 || frac y==0.0; +x::double^y::double = c_pow x y if x>=0 || frac y==0.0 || nanp x || nanp y; x::int^y::int | x::bigint^y::bigint | x::int^y::bigint | @@ -367,7 +367,7 @@ x::double^y::int | x::double^y::bigint = c_pow x (double y); x::int^y::double | -x::bigint^y::double = c_pow (double x) y if x>=0 || frac y==0.0; +x::bigint^y::double = c_pow (double x) y if x>=0 || frac y==0.0 || nanp y; = double x^y otherwise; /* Pointer arithmetic. We do this using bigints, so that the code is portable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-08-28 11:27:37
|
Revision: 652 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=652&view=rev Author: agraef Date: 2008-08-28 11:27:46 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Remove assert convenience function, it's not really worth having trivial stuff like that in the prelude. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-28 11:25:58 UTC (rev 651) +++ pure/trunk/lib/primitives.pure 2008-08-28 11:27:46 UTC (rev 652) @@ -23,11 +23,6 @@ extern void pure_throw(expr*) = throw; // IMPURE! -/* Convenience function to ensure a condition p. Returns 1 (true) if p holds, - and throws the given exception e otherwise. */ - -assert p e = if p then 1 else throw e; - /* Syntactic equality. */ extern bool same(expr* x, expr* y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-08-30 19:51:01
|
Revision: 667 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=667&view=rev Author: agraef Date: 2008-08-30 19:51:11 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Cosmetic changes. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-30 19:37:11 UTC (rev 666) +++ pure/trunk/lib/primitives.pure 2008-08-30 19:51:11 UTC (rev 667) @@ -23,17 +23,6 @@ extern void pure_throw(expr*) = throw; // IMPURE! -/* Sentries. These are expression "guards" which are applied to the target - expression when it is garbage-collected. The sentry function places a - sentry at an expression (and returns the modified expression), clear_sentry - removes, get_sentry returns it. NOTE: In the current implementation - sentries can only be placed at applications and pointer objects. The sentry - itself can be any type of object (but usually it's a function). */ - -extern expr* pure_sentry(expr*,expr*) = sentry; // IMPURE! -extern expr* pure_clear_sentry(expr*) = clear_sentry; // IMPURE! -extern expr* pure_get_sentry(expr*) = get_sentry; - /* Syntactic equality. */ extern bool same(expr* x, expr* y); @@ -424,3 +413,14 @@ put_string x::pointer y::string = pointer_put_string x y; put_pointer x::pointer y::string = pointer_put_pointer x y; put_pointer x::pointer y::pointer = pointer_put_pointer x y; + +/* Sentries. These are expression "guards" which are applied to the target + expression when it is garbage-collected. The sentry function places a + sentry at an expression (and returns the modified expression), clear_sentry + removes, get_sentry returns it. NOTE: In the current implementation + sentries can only be placed at applications and pointer objects. The sentry + itself can be any type of object (but usually it's a function). */ + +extern expr* pure_sentry(expr*,expr*) = sentry; // IMPURE! +extern expr* pure_clear_sentry(expr*) = clear_sentry; // IMPURE! +extern expr* pure_get_sentry(expr*) = get_sentry; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-15 04:40:54
|
Revision: 760 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=760&view=rev Author: agraef Date: 2008-09-15 04:41:02 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Simplify definitions of infp and nanp. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-12 11:39:25 UTC (rev 759) +++ pure/trunk/lib/primitives.pure 2008-09-15 04:41:02 UTC (rev 760) @@ -69,8 +69,8 @@ /* Predicates to check for inf and nan values. */ -infp x = case x of x::double = x!==nan && x-x===nan; _ = 0 end; -nanp x = case x of x::double = x===nan; _ = 0 end; +infp x = case x of x::double = x==inf || x==-inf; _ = 0 end; +nanp x = case x of x::double = not (x==x); _ = 0 end; /* Compute a 32 bit hash code of a Pure expression. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-15 05:34:49
|
Revision: 762 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=762&view=rev Author: agraef Date: 2008-09-15 05:34:59 +0000 (Mon, 15 Sep 2008) Log Message: ----------- Properly handle the case of IEEE 754 negative zeros. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-15 04:56:26 UTC (rev 761) +++ pure/trunk/lib/primitives.pure 2008-09-15 05:34:59 UTC (rev 762) @@ -125,10 +125,13 @@ // Fractional part of x. frac x::int | frac x::bigint | frac x::double = x-trunc x; -/* Absolute value and sign of a number. */ +/* Absolute value and sign of a number. Note that these don't distinguish + between IEEE 754 positive and negative zeros; abs always returns 0.0, sgn 0 + for these. The real sign bit of a floating point zero can be obtained with + sgn (1/x). */ abs x::int | abs x::bigint | abs x::double - = if x>=0 then x else -x; + = if x>0 then x else -x; sgn x::int | sgn x::bigint | sgn x::double = if x>0 then 1 else if x<0 then -1 else 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-18 13:35:50
|
Revision: 786 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=786&view=rev Author: agraef Date: 2008-09-18 20:35:54 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Add some basic matrix operations (type checking predicates for vectors). Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-18 20:19:31 UTC (rev 785) +++ pure/trunk/lib/primitives.pure 2008-09-18 20:35:54 UTC (rev 786) @@ -46,6 +46,22 @@ cmatrixp x = case x of _::cmatrix = 1; _ = 0 end; imatrixp x = case x of _::imatrix = 1; _ = 0 end; +/* Pure represents row and column vectors as matrices with 1 row or column, + respectively. The following predicates allow you to check for these special + kinds of matrices. */ + +vectorp x = matrixp x && (n==1 || m==1 when n::int,m::int = dim x end); +rowvectorp x = matrixp x && dim x!0==1; +colvectorp x = matrixp x && dim x!1==1; + +cvectorp x = cmatrixp x && (n==1 || m==1 when n::int,m::int = dim x end); +rowcvectorp x = cmatrixp x && dim x!0==1; +colcvectorp x = cmatrixp x && dim x!1==1; + +ivectorp x = imatrixp x && (n==1 || m==1 when n::int,m::int = dim x end); +rowivectorp x = imatrixp x && dim x!0==1; +colivectorp x = imatrixp x && dim x!1==1; + /* Predicates to check for function objects, global (unbound) variables, function applications, proper lists, list nodes and tuples. */ @@ -409,7 +425,7 @@ x::imatrix!(i::int,j::int) = matrix_elem x i j if (i>=0 && i<n && j>=0 && j<m - when n,m = dim x end); + when n::int,m::int = dim x end); = throw out_of_bounds otherwise; /* IEEE floating point infinities and NaNs. Place these after the definitions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-20 07:56:36
|
Revision: 800 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=800&view=rev Author: agraef Date: 2008-09-20 07:56:32 +0000 (Sat, 20 Sep 2008) Log Message: ----------- Implement array slicing operations. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-20 07:03:48 UTC (rev 799) +++ pure/trunk/lib/primitives.pure 2008-09-20 07:56:32 UTC (rev 800) @@ -430,6 +430,16 @@ when n::int,m::int = dim x end); = throw out_of_bounds otherwise; +/* Slices. */ + +x::matrix!!(ns,ms) = colcatmap (mth (rowcatmap (nth x) ns)) ms with + nth x n = catch (cst {}) (row x n); + mth x m = catch (cst {}) (col x m); + end; +x::matrix!!ns = colcatmap (nth x) ns with + nth x n = catch (cst {}) {x!n}; + end; + /* Extract rows and columns from a matrix. */ private matrix_slice; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-20 08:20:55
|
Revision: 801 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=801&view=rev Author: agraef Date: 2008-09-20 08:20:26 +0000 (Sat, 20 Sep 2008) Log Message: ----------- Add submatrix operation. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-20 07:56:32 UTC (rev 800) +++ pure/trunk/lib/primitives.pure 2008-09-20 08:20:26 UTC (rev 801) @@ -457,6 +457,11 @@ cols x::matrix = map (col x) (0..m-1) when _,m::int = dim x end; +/* Extract a submatrix of a given size at a given offset. */ + +submat x::matrix (i::int,j::int) (n::int,m::int) + = matrix_slice x i j (i+n) (j+m); + /* Construct matrices from lists of rows and columns. These take either scalars or submatrices as inputs; corresponding dimensions must match. rowcat combines submatrices vertically, like {x;y}; colcat combines them This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-20 09:24:41
|
Revision: 804 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=804&view=rev Author: agraef Date: 2008-09-20 09:24:14 +0000 (Sat, 20 Sep 2008) Log Message: ----------- Comment change. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-20 09:21:34 UTC (rev 803) +++ pure/trunk/lib/primitives.pure 2008-09-20 09:24:14 UTC (rev 804) @@ -470,8 +470,7 @@ extern expr* matrix_rows(expr *x) = rowcat; extern expr* matrix_columns(expr *x) = colcat; -/* Combinations of rowcat/colcat and map, to be used in matrix - comprehensions. */ +/* Combinations of rowcat/colcat and map. */ rowcatmap f [] = {}; rowcatmap f xs@(_:_) = rowcat (map f xs); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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. |
From: <ag...@us...> - 2008-09-22 21:14:19
|
Revision: 830 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=830&view=rev Author: agraef Date: 2008-09-22 21:14:10 +0000 (Mon, 22 Sep 2008) Log Message: ----------- Add matrix reversal operations. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-22 20:53:37 UTC (rev 829) +++ pure/trunk/lib/primitives.pure 2008-09-22 21:14:10 UTC (rev 830) @@ -532,6 +532,13 @@ x::matrix' = matrix_transpose x; +/* Reverse a matrix. rowrev reverses the rows, colrev the columns, reverse + both dimensions. */ + +rowrev x::matrix = rowcat (reverse (rows x)); +colrev x::matrix = colcat (reverse (cols x)); +reverse x::matrix = rowrev (colrev x); + /* Matrix conversions. */ private matrix_double matrix_complex matrix_int; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-22 21:52:50
|
Revision: 831 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=831&view=rev Author: agraef Date: 2008-09-22 21:36:31 +0000 (Mon, 22 Sep 2008) Log Message: ----------- Add matrix/list conversion operations. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-22 21:14:10 UTC (rev 830) +++ pure/trunk/lib/primitives.pure 2008-09-22 21:36:31 UTC (rev 831) @@ -469,6 +469,20 @@ cols x::matrix = map (col x) (0..m-1) when _,m::int = dim x end; +/* Convert a matrix to a list and vice versa. */ + +list x::matrix = [[x!(i,j) | j=0..m-1] | i=0..n-1] + when n::int,m::int = dim x end; +matrix [] = {}; +matrix xs@(x:_) = rowcatmap colcat xs; + +/* Convenience functions to create vectors from lists. */ + +rowvector xs@[] | rowvector xs@(_:_) + = colcat xs; +colvector xs@[] | colvector xs@(_:_) + = rowcat xs; + /* Extract (sub-,super-) diagonals from a matrix. Sub- and super-diagonals for k=0 return the main diagonal. Indices for sub- and super-diagonals can also be negative, in which case the corresponding super- or sub-diagonal is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-09-23 05:31:32
|
Revision: 832 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=832&view=rev Author: agraef Date: 2008-09-23 05:31:30 +0000 (Tue, 23 Sep 2008) Log Message: ----------- Overhaul of matrix/list conversion operations. Modified Paths: -------------- pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-09-22 21:36:31 UTC (rev 831) +++ pure/trunk/lib/primitives.pure 2008-09-23 05:31:30 UTC (rev 832) @@ -433,7 +433,7 @@ when n::int,m::int = dim x end); = throw out_of_bounds otherwise; -/* Slices. */ +/* Matrix slices. */ x::matrix!!(ns,ms) = case ns,ms of // optimize the case of contiguous slices @@ -469,24 +469,26 @@ cols x::matrix = map (col x) (0..m-1) when _,m::int = dim x end; -/* Convert a matrix to a list and vice versa. */ +/* Convert a matrix to a list and vice versa. If x is a row vector then list x + converts it to a list of its elements; otherwise the result is the list of + the rows of the matrix. You can also use list2 to convert a matrix to a + list of lists. Conversely, matrix xs converts a list of lists or matrices + to the corresponding matrix. Otherwise, the result is a row vector. */ -list x::matrix = [[x!(i,j) | j=0..m-1] | i=0..n-1] +list x::matrix = [x!i|i=0..#x-1] if rowvectorp x; + = rows x otherwise; +list2 x::matrix = [[x!(i,j)|j=0..m-1]|i=0..n-1] when n::int,m::int = dim x end; + matrix [] = {}; -matrix xs@(x:_) = rowcatmap colcat xs; +matrix xs@(x:_) = rowcatmap colcat xs if all listp xs; + = rowcat xs if any matrixp xs; + = colcat xs otherwise; -/* Convenience functions to create vectors from lists. */ - -rowvector xs@[] | rowvector xs@(_:_) - = colcat xs; -colvector xs@[] | colvector xs@(_:_) - = rowcat xs; - /* Extract (sub-,super-) diagonals from a matrix. Sub- and super-diagonals for k=0 return the main diagonal. Indices for sub- and super-diagonals can also be negative, in which case the corresponding super- or sub-diagonal is - returned instead. */ + returned instead. In each case the result is a row vector. */ private matrix_diag matrix_subdiag matrix_supdiag; extern expr* matrix_diag(expr* x) = diag; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |