[genius] Mon Aug 30 13:41:49 2010 Jiri (George) Lebl <jirka 5z com>



commit 688f497c4f8fcfc5a882bff4c578f71f9407ae33
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Mon Aug 30 13:49:31 2010 -0700

    Mon Aug 30 13:41:49 2010  Jiri (George) Lebl <jirka 5z com>
    
    	* src/funclib.c: ExpandMatrix,SetMatrixSize,ColumnsOf,RowsOf,
    	  IsMatrix* accept null as the input (0x0) matrix and act accordingly
    
    	* src/geniustests.txt: Add tests

 ChangeLog           |    7 +++++++
 NEWS                |    7 +++++--
 src/funclib.c       |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 src/geniustests.txt |   22 ++++++++++++++++++++++
 4 files changed, 83 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a533f55..20fcc48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Aug 30 13:41:49 2010  Jiri (George) Lebl <jirka 5z com>
+
+	* src/funclib.c: ExpandMatrix,SetMatrixSize,ColumnsOf,RowsOf,
+	  IsMatrix* accept null as the input (0x0) matrix and act accordingly
+
+	* src/geniustests.txt: Add tests
+
 Mon Aug 30 13:28:23 2010  Jiri (George) Lebl <jirka 5z com>
 
 	* src/graphing.c: Add "legend" style parameter to LinePlotDrawLine
diff --git a/NEWS b/NEWS
index 4fbb6c3..8a08b90 100644
--- a/NEWS
+++ b/NEWS
@@ -1,13 +1,16 @@
 Changes to 1.0.10
 
-* Allow changing variable names for all 2D plotting functions
-* Add SlopefieldTicks, VectorfieldTicks, and LinePlotVariableNames parameters
+* Allow changing variable names for all plotting functions
+* Add SlopefieldTicks, VectorfieldTicks, LinePlotVariableNames, and
+  SurfacePlotVariableNames, parameters
 * Add AskButtons interactive function
+* Support for setting legend on LinePlotDrawLine with a "legend" parameter
 * Allow comparisons (== and !=) with null, treating it as an empty matrix
 * Fix compilation without gtksourceview (thanks to Joe Sapp for pointing this
   out)
 * Fix some crashes in plotting code
 * Allow slopefield solutions to leave plot window by a small fudge factor.
+* fix compilation with newer sealed vte (Vincent Untz)
 
 * For some of the changes the author (Jiri) was partially supported by
   NSF grant DMS 0900885 and the University of Illinois at Urbana-Champaign
diff --git a/src/funclib.c b/src/funclib.c
index 81ad8e5..ba31756 100644
--- a/src/funclib.c
+++ b/src/funclib.c
@@ -940,6 +940,9 @@ ExpandMatrix_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
 	GelETree *n;
 
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_null ();
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "ExpandMatrix"))
 		return NULL;
 
@@ -956,6 +959,9 @@ RowsOf_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
 	GelETree *n;
 
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_null ();
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "RowsOf"))
 		return NULL;
 
@@ -971,6 +977,9 @@ ColumnsOf_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
 	GelETree *n;
 
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_null ();
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "ColumnsOf"))
 		return NULL;
 
@@ -1588,6 +1597,9 @@ IsReal_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 static GelETree *
 IsMatrixReal_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_bool (1);
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "IsMatrixReal"))
 		return NULL;
 
@@ -1644,6 +1656,9 @@ IsGaussInteger_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 static GelETree *
 IsMatrixInteger_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_bool (1);
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "IsMatrixInteger"))
 		return NULL;
 
@@ -1677,6 +1692,9 @@ IsComplexRational_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 static GelETree *
 IsMatrixRational_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_bool (1);
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "IsMatrixRational"))
 		return NULL;
 
@@ -2581,6 +2599,9 @@ min_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 static GelETree *
 IsValueOnly_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_bool (1);
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "IsValueOnly"))
 		return NULL;
 	
@@ -2915,6 +2936,9 @@ elements_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 static GelETree *
 IsMatrixSquare_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
 {
+	if (a[0]->type == GEL_NULL_NODE)
+		return gel_makenum_bool (1);
+
 	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "IsMatrixSquare"))
 		return NULL;
 	if (gel_matrixw_width (a[0]->mat.matrix) == gel_matrixw_height (a[0]->mat.matrix))
@@ -3008,7 +3032,7 @@ SetMatrixSize_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 	GelETree *n;
 	long w,h;
 
-	if G_UNLIKELY ( ! check_argument_matrix (a, 0, "SetMatrixSize"))
+	if G_UNLIKELY ( ! check_argument_matrix_or_null (a, 0, "SetMatrixSize"))
 		return NULL;
 	if G_UNLIKELY ( ! check_argument_nonnegative_integer (a, 1, "SetMatrixSize"))
 		return NULL;
@@ -3026,7 +3050,30 @@ SetMatrixSize_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
 		return gel_makenum_null ();
 
 	n = gel_stealnode (a[0]);
-	gel_matrixw_set_size (n->mat.matrix, h, w);
+	if (n->type == GEL_NULL_NODE) {
+		GelMatrixW *m;
+
+		n->type = GEL_MATRIX_NODE;
+		n->mat.matrix = m = gel_matrixw_new();
+		n->mat.quoted = FALSE;
+		gel_matrixw_set_size (m, h, w);
+
+		/* trivially rref */
+		m->rref = 1;
+
+		m->cached_value_only = 1;
+		m->value_only = 1;
+		m->cached_value_only_real = 1;
+		m->value_only_real = 1;
+		m->cached_value_only_rational = 1;
+		m->value_only_rational = 1;
+		m->cached_value_only_integer = 1;
+		m->value_only_integer = 1;
+		m->cached_value_or_bool_only = 1;
+		m->value_or_bool_only = 1;
+	} else {
+		gel_matrixw_set_size (n->mat.matrix, h, w);
+	}
 	return n;
 }
 
diff --git a/src/geniustests.txt b/src/geniustests.txt
index 48095be..a51b2b6 100644
--- a/src/geniustests.txt
+++ b/src/geniustests.txt
@@ -998,6 +998,28 @@ null!=[1,2,3]							true
 1!=null								true
 [1,2,3]!=null							true
 null!=null							false
+RowsOf(null)+1							((null)+1)
+ColumnsOf(null)+1						((null)+1)
+IsValueOnly([0,1;2,4])						true
+IsValueOnly([0,1;"k",4])					false
+IsValueOnly(null)						true
+IsMatrixRational(null)						true
+IsMatrixRational([1,2;3/4,5])					true
+IsMatrixRational([1,2;3/4,5.1])					false
+IsMatrixInteger(null)						true
+IsMatrixInteger([1,2;4,5])					true
+IsMatrixInteger([1,2;3/4,5])					false
+IsMatrixInteger([1,2;3/4,5.1])					false
+IsMatrixReal(null)						true
+IsMatrixReal([1,2;4,5])						true
+IsMatrixReal([1,2;3/4,5.1])					true
+IsMatrixReal([1,2;3/4,5.1+1i])					false
+IsMatrixSquare(null)						true
+IsMatrixSquare([1])						true
+IsMatrixSquare([1,2;3,4])					true
+IsMatrixSquare([1,2,3,4])					false
+SetMatrixSize(null,2,3)						[0,0,0;0,0,0]
+ExpandMatrix(null)+1						((null)+1)
 load "nullspacetest.gel"					true
 load "longtest.gel"						true
 load "testprec.gel"						true



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]