Mercurial > octave
comparison libinterp/octave-value/ov.cc @ 30854:eba0a86471b9
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Mar 2022 00:06:09 -0400 |
parents | 3c9e19cd8896 95725e6ad9c1 |
children | 1be26e9c07e3 |
comparison
equal
deleted
inserted
replaced
30851:a0e13472457d | 30854:eba0a86471b9 |
---|---|
46 #include "ov-float.h" | 46 #include "ov-float.h" |
47 #include "ov-re-mat.h" | 47 #include "ov-re-mat.h" |
48 #include "ov-flt-re-mat.h" | 48 #include "ov-flt-re-mat.h" |
49 #include "ov-re-diag.h" | 49 #include "ov-re-diag.h" |
50 #include "ov-flt-re-diag.h" | 50 #include "ov-flt-re-diag.h" |
51 #include "ov-legacy-range.h" | |
51 #include "ov-perm.h" | 52 #include "ov-perm.h" |
52 #include "ov-bool-sparse.h" | 53 #include "ov-bool-sparse.h" |
53 #include "ov-cx-sparse.h" | 54 #include "ov-cx-sparse.h" |
54 #include "ov-re-sparse.h" | 55 #include "ov-re-sparse.h" |
55 #include "ov-int8.h" | 56 #include "ov-int8.h" |
1074 | 1075 |
1075 // Remove when public constructor that uses this function is removed. | 1076 // Remove when public constructor that uses this function is removed. |
1076 octave_base_value * | 1077 octave_base_value * |
1077 octave_value::make_range_rep_deprecated (double base, double inc, double limit) | 1078 octave_value::make_range_rep_deprecated (double base, double inc, double limit) |
1078 { | 1079 { |
1080 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) | |
1081 # pragma GCC diagnostic push | |
1082 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
1083 #endif | |
1084 | |
1079 return dynamic_cast<octave_base_value *> | 1085 return dynamic_cast<octave_base_value *> |
1080 (new ov_range<double> (octave::range<double> (base, inc, limit))); | 1086 (new octave_legacy_range (Range (base, inc, limit))); |
1087 | |
1088 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) | |
1089 # pragma GCC diagnostic pop | |
1090 #endif | |
1081 } | 1091 } |
1082 | 1092 |
1083 // Remove when public constructor that uses this function is removed. | 1093 // Remove when public constructor that uses this function is removed. |
1084 octave_base_value * | 1094 octave_base_value * |
1085 octave_value::make_range_rep_deprecated (const Range& r, bool force_range) | 1095 octave_value::make_range_rep_deprecated (const Range& r, bool force_range) |
1086 { | 1096 { |
1087 if (! force_range && ! r.ok ()) | 1097 if (! force_range && ! r.ok ()) |
1088 error ("invalid range"); | 1098 error ("invalid range"); |
1089 | 1099 |
1090 if (force_range || Voptimize_range) | 1100 if ((force_range || Voptimize_range)) |
1091 return make_range_rep_deprecated (r.base (), r.increment (), r.limit ()); | 1101 return dynamic_cast<octave_base_value *> (new octave_legacy_range (r)); |
1092 else | 1102 else |
1093 return dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())); | 1103 return dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())); |
1094 } | 1104 } |
1095 | 1105 |
1096 octave_value::octave_value (const octave::range<double>& r, bool force_range) | 1106 octave_value::octave_value (const octave::range<double>& r, bool force_range) |
2348 << prefix << "m_rep info: "; | 2358 << prefix << "m_rep info: "; |
2349 | 2359 |
2350 m_rep->print_info (os, prefix + ' '); | 2360 m_rep->print_info (os, prefix + ' '); |
2351 } | 2361 } |
2352 | 2362 |
2363 bool octave_value::load_ascii (std::istream& is) | |
2364 { | |
2365 bool status = m_rep->load_ascii (is); | |
2366 | |
2367 // Force conversion of legacy objects. | |
2368 if (is_legacy_object ()) | |
2369 maybe_mutate (); | |
2370 | |
2371 return status; | |
2372 } | |
2373 bool octave_value::load_binary (std::istream& is, bool swap, | |
2374 octave::mach_info::float_format fmt) | |
2375 { | |
2376 bool status = m_rep->load_binary (is, swap, fmt); | |
2377 | |
2378 // Force conversion of legacy objects. | |
2379 if (is_legacy_object ()) | |
2380 maybe_mutate (); | |
2381 | |
2382 return status; | |
2383 } | |
2384 | |
2385 bool octave_value::load_hdf5 (octave_hdf5_id loc_id, const char *name) | |
2386 { | |
2387 bool status = m_rep->load_hdf5 (loc_id, name); | |
2388 | |
2389 // Force conversion of legacy objects. | |
2390 if (is_legacy_object ()) | |
2391 maybe_mutate (); | |
2392 | |
2393 return status; | |
2394 } | |
2395 | |
2353 const void * | 2396 const void * |
2354 octave_value::mex_get_data (mxClassID class_id, mxComplexity complexity) const | 2397 octave_value::mex_get_data (mxClassID class_id, mxComplexity complexity) const |
2355 { | 2398 { |
2356 // If class_id is set to mxUNKNOWN_CLASS, return data for any type. | 2399 // If class_id is set to mxUNKNOWN_CLASS, return data for any type. |
2357 // Otherwise, require that REP matches the requested type and | 2400 // Otherwise, require that REP matches the requested type and |
3593 octave_complex::register_type (ti); | 3636 octave_complex::register_type (ti); |
3594 octave_matrix::register_type (ti); | 3637 octave_matrix::register_type (ti); |
3595 octave_diag_matrix::register_type (ti); | 3638 octave_diag_matrix::register_type (ti); |
3596 octave_complex_matrix::register_type (ti); | 3639 octave_complex_matrix::register_type (ti); |
3597 octave_complex_diag_matrix::register_type (ti); | 3640 octave_complex_diag_matrix::register_type (ti); |
3641 | |
3642 // Legacy range type, preserved to allow loading "constant" ranges | |
3643 // from data files. | |
3644 octave_legacy_range::register_type (ti); | |
3645 | |
3598 ov_range<double>::register_type (ti); | 3646 ov_range<double>::register_type (ti); |
3599 | 3647 |
3600 // For now, disable all but ov_range<double>. | 3648 // For now, disable all but ov_range<double>. |
3601 | 3649 |
3602 #if 0 | 3650 #if 0 |
4076 %! base = 1; | 4124 %! base = 1; |
4077 %! limit = 13; | 4125 %! limit = 13; |
4078 %! r = base:limit; | 4126 %! r = base:limit; |
4079 %!endfunction | 4127 %!endfunction |
4080 | 4128 |
4081 %!assert (typeinfo (__test_dr__ (true)), "range") | 4129 %!assert (typeinfo (__test_dr__ (true)), "double_range") |
4082 %!assert (typeinfo (__test_dr__ (false)), "matrix") | 4130 %!assert (typeinfo (__test_dr__ (false)), "matrix") |
4083 */ | 4131 */ |
4084 | 4132 |
4085 OCTAVE_NAMESPACE_END | 4133 OCTAVE_NAMESPACE_END |