comparison src/data.cc @ 2188:64dbd9cb5e5a

[project @ 1996-05-14 03:21:01 by jwe]
author jwe
date Tue, 14 May 1996 03:21:01 +0000
parents dbbbb3559ee8
children 6abec42e52f6
comparison
equal deleted inserted replaced
2187:755b1cd2e914 2188:64dbd9cb5e5a
56 56
57 #ifndef ABS 57 #ifndef ABS
58 #define ABS(x) (((x) < 0) ? (-x) : (x)) 58 #define ABS(x) (((x) < 0) ? (-x) : (x))
59 #endif 59 #endif
60 60
61 // Should expressions like ones (-1, 5) result in an empty matrix or
62 // an error? A positive value means yes. A negative value means
63 // yes, but print a warning message. Zero means it should be
64 // considered an error.
65 static int Vtreat_neg_dim_as_zero;
66
61 DEFUN (all, args, , 67 DEFUN (all, args, ,
62 "all (X): are all elements of X nonzero?") 68 "all (X): are all elements of X nonzero?")
63 { 69 {
64 octave_value_list retval; 70 octave_value_list retval;
65 71
802 static void 808 static void
803 check_dimensions (int& nr, int& nc, const char *warnfor) 809 check_dimensions (int& nr, int& nc, const char *warnfor)
804 { 810 {
805 if (nr < 0 || nc < 0) 811 if (nr < 0 || nc < 0)
806 { 812 {
807 if (user_pref.treat_neg_dim_as_zero) 813 if (Vtreat_neg_dim_as_zero)
808 { 814 {
809 nr = (nr < 0) ? 0 : nr; 815 nr = (nr < 0) ? 0 : nr;
810 nc = (nc < 0) ? 0 : nc; 816 nc = (nc < 0) ? 0 : nc;
811 817
812 if (user_pref.treat_neg_dim_as_zero < 0) 818 if (Vtreat_neg_dim_as_zero < 0)
813 warning ("%s: converting negative dimension to zero", 819 warning ("%s: converting negative dimension to zero",
814 warnfor); 820 warnfor);
815 } 821 }
816 else 822 else
817 error ("%s: can't create a matrix with negative dimensions", 823 error ("%s: can't create a matrix with negative dimensions",
1092 } 1098 }
1093 1099
1094 return retval; 1100 return retval;
1095 } 1101 }
1096 1102
1103 static int
1104 treat_neg_dim_as_zero (void)
1105 {
1106 Vtreat_neg_dim_as_zero = check_preference ("treat_neg_dim_as_zero");
1107
1108 return 0;
1109 }
1110
1097 void 1111 void
1098 symbols_of_data (void) 1112 symbols_of_data (void)
1099 { 1113 {
1100 DEFCONST (I, Complex (0.0, 1.0), 0, 0, 1114 DEFCONST (I, Complex (0.0, 1.0), 0, 0,
1101 "sqrt (-1)"); 1115 "sqrt (-1)");
1145 DEFCONST (realmax, DBL_MAX, 0, 0, 1159 DEFCONST (realmax, DBL_MAX, 0, 0,
1146 "realmax (): return largest representable floating point number"); 1160 "realmax (): return largest representable floating point number");
1147 1161
1148 DEFCONST (realmin, DBL_MIN, 0, 0, 1162 DEFCONST (realmin, DBL_MIN, 0, 0,
1149 "realmin (): return smallest representable floating point number"); 1163 "realmin (): return smallest representable floating point number");
1164
1165 DEFVAR (treat_neg_dim_as_zero, 0.0, 0, treat_neg_dim_as_zero,
1166 "convert negative dimensions to zero");
1150 } 1167 }
1151 1168
1152 /* 1169 /*
1153 ;;; Local Variables: *** 1170 ;;; Local Variables: ***
1154 ;;; mode: C++ *** 1171 ;;; mode: C++ ***