comparison src/ov.cc @ 5781:faafc2d98b8d

[project @ 2006-05-02 19:40:19 by jwe]
author jwe
date Tue, 02 May 2006 19:40:21 +0000
parents ace8d8d26933
children 6b9cec830d72
comparison
equal deleted inserted replaced
5780:cbf717bf8150 5781:faafc2d98b8d
80 80
81 // We are likely to have a lot of octave_value objects to allocate, so 81 // We are likely to have a lot of octave_value objects to allocate, so
82 // make the grow_size large. 82 // make the grow_size large.
83 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); 83 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024);
84 84
85 // If TRUE, print a warning for assignments like
86 //
87 // octave> A(1) = 3; A(2) = 5
88 //
89 // for A already defined and a matrix type.
90 bool Vwarn_fortran_indexing;
91
92 // Should we warn about conversions from complex to real?
93 int Vwarn_imag_to_real;
94
95 // FIXME 85 // FIXME
96 86
97 // Octave's value type. 87 // Octave's value type.
98 88
99 std::string 89 std::string
1140 for (octave_idx_type i = 0; i < nr; i++) 1130 for (octave_idx_type i = 0; i < nr; i++)
1141 retval (i) = m (i, 0); 1131 retval (i) = m (i, 0);
1142 } 1132 }
1143 else if (nr > 0 && nc > 0) 1133 else if (nr > 0 && nc > 0)
1144 { 1134 {
1145 // FIXME -- is warn_fortran_indexing the right variable here? 1135 if (! force_vector_conversion)
1146 if (! force_vector_conversion && Vwarn_fortran_indexing) 1136 gripe_implicit_conversion ("Octave:array-as-vector",
1147 gripe_implicit_conversion (type_name (), "real vector"); 1137 type_name (), "real vector");
1148 1138
1149 retval.resize (nr * nc); 1139 retval.resize (nr * nc);
1150 octave_idx_type k = 0; 1140 octave_idx_type k = 0;
1151 for (octave_idx_type j = 0; j < nc; j++) 1141 for (octave_idx_type j = 0; j < nc; j++)
1152 for (octave_idx_type i = 0; i < nr; i++) 1142 for (octave_idx_type i = 0; i < nr; i++)
1215 retval (i) = static_cast<int> (d); 1205 retval (i) = static_cast<int> (d);
1216 } 1206 }
1217 } 1207 }
1218 else if (nr > 0 && nc > 0) 1208 else if (nr > 0 && nc > 0)
1219 { 1209 {
1220 // FIXME -- is warn_fortran_indexing the right variable here? 1210 if (! force_vector_conversion)
1221 if (! force_vector_conversion && Vwarn_fortran_indexing) 1211 gripe_implicit_conversion ("Octave:array-as-vector",
1222 gripe_implicit_conversion (type_name (), "real vector"); 1212 type_name (), "real vector");
1223 1213
1224 retval.resize (nr * nc); 1214 retval.resize (nr * nc);
1225 octave_idx_type k = 0; 1215 octave_idx_type k = 0;
1226 for (octave_idx_type j = 0; j < nc; j++) 1216 for (octave_idx_type j = 0; j < nc; j++)
1227 { 1217 {
1282 retval (i) = m (i, 0); 1272 retval (i) = m (i, 0);
1283 } 1273 }
1284 } 1274 }
1285 else if (nr > 0 && nc > 0) 1275 else if (nr > 0 && nc > 0)
1286 { 1276 {
1287 // FIXME -- is warn_fortran_indexing the right variable here? 1277 if (! force_vector_conversion)
1288 if (! force_vector_conversion && Vwarn_fortran_indexing) 1278 gripe_implicit_conversion ("Octave:array-as-vector",
1289 gripe_implicit_conversion (type_name (), "complex vector"); 1279 type_name (), "complex vector");
1290 1280
1291 retval.resize (nr * nc); 1281 retval.resize (nr * nc);
1292 octave_idx_type k = 0; 1282 octave_idx_type k = 0;
1293 for (octave_idx_type j = 0; j < nc; j++) 1283 for (octave_idx_type j = 0; j < nc; j++)
1294 for (octave_idx_type i = 0; i < nr; i++) 1284 for (octave_idx_type i = 0; i < nr; i++)
1896 print_usage ("sizeof"); 1886 print_usage ("sizeof");
1897 1887
1898 return retval; 1888 return retval;
1899 } 1889 }
1900 1890
1901 static int
1902 warn_fortran_indexing (void)
1903 {
1904 Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing");
1905
1906 liboctave_wfi_flag = Vwarn_fortran_indexing;
1907
1908 return 0;
1909 }
1910
1911 static int
1912 warn_imag_to_real (void)
1913 {
1914 Vwarn_imag_to_real = check_preference ("warn_imag_to_real");
1915
1916 return 0;
1917 }
1918
1919 void
1920 symbols_of_ov (void)
1921 {
1922 DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing,
1923 "-*- texinfo -*-\n\
1924 @defvr {Built-in Variable} warn_fortran_indexing\n\
1925 If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\
1926 printed for expressions which select elements of a two-dimensional matrix\n\
1927 using a single index. The default value is 0.\n\
1928 @end defvr");
1929
1930 DEFVAR (warn_imag_to_real, false, warn_imag_to_real,
1931 "-*- texinfo -*-\n\
1932 @defvr {Built-in Variable} warn_imag_to_real\n\
1933 If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\
1934 printed for implicit conversions of complex numbers to real numbers.\n\
1935 The default value is 0.\n\
1936 @end defvr");
1937 }
1938
1939 /* 1891 /*
1940 ;;; Local Variables: *** 1892 ;;; Local Variables: ***
1941 ;;; mode: C++ *** 1893 ;;; mode: C++ ***
1942 ;;; End: *** 1894 ;;; End: ***
1943 */ 1895 */