Mercurial > octave
annotate libinterp/octave-value/ov-legacy-range.h @ 32060:1203a2d81a42
Add BIST tests for Matlab compatibility for functions which accept negative dimensions.
* data.cc (Fones, Finf, Feps, Feye): Add BIST test for negative dimensions.
* rand.cc (Frand): Add BIST test for negative dimensions.
* ov-cell.cc (Fcell): Add BIST test for negative dimensions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 26 Apr 2023 16:26:32 -0700 |
parents | 21f9b34eb893 |
children | ae4e19c0a2b1 2e484f9f1f18 |
rev | line source |
---|---|
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 // |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30852
diff
changeset
|
3 // Copyright (C) 1996-2023 The Octave Project Developers |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 // This file is part of Octave. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 // (at your option) any later version. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 // GNU General Public License for more details. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 // |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if ! defined (octave_ov_legacy_range_h) |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #define octave_ov_legacy_range_h 1 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "octave-config.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <cstdlib> |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <iosfwd> |
31468
777a42ebe45b
use opaque pointer for octave_legacy_range data member
John W. Eaton <jwe@octave.org>
parents:
31467
diff
changeset
|
34 #include <memory> |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <string> |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "lo-mappers.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "lo-utils.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "mx-base.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "error.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "oct-stream.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "ov-base.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "ov-re-mat.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "ov-typeinfo.h" |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
31468
777a42ebe45b
use opaque pointer for octave_legacy_range data member
John W. Eaton <jwe@octave.org>
parents:
31467
diff
changeset
|
47 class Range; |
777a42ebe45b
use opaque pointer for octave_legacy_range data member
John W. Eaton <jwe@octave.org>
parents:
31467
diff
changeset
|
48 |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 class octave_value_list; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 // Legacy Range values. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 // Provide enough of the old octave_range class to allow Range objects |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 // to be loaded from files. After loading, they are converted to some |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 // other type by a call to octave_value::maybe_mutate in |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 // load_save_system::load_vars so there should no longer be any values |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 // of this type used by the interpreter. The action of maybe_mutate is |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 // performed by octave_legacy_range::try_narrowing_conversion. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 class |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 octave_legacy_range : public octave_base_value |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 { |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 public: |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
65 octave_legacy_range (); |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 octave_legacy_range (const Range& r); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 |
31468
777a42ebe45b
use opaque pointer for octave_legacy_range data member
John W. Eaton <jwe@octave.org>
parents:
31467
diff
changeset
|
69 octave_legacy_range (const octave_legacy_range& r); |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 // No assignment. |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 octave_legacy_range& operator = (const octave_legacy_range&) = delete; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
75 ~octave_legacy_range () = default; |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
77 octave_base_value * clone () const |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 { |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 return new octave_legacy_range (*this); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 } |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 // A range is really just a special kind of real matrix object. In |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 // the places where we need to call empty_clone, it makes more sense |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 // to create an empty matrix (0x0) instead of an empty range (1x0). |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
85 octave_base_value * empty_clone () const { return new octave_matrix (); } |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
87 type_conv_info numeric_conversion_function () const; |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
89 octave_base_value * try_narrowing_conversion (); |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
91 bool is_defined () const { return true; } |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
93 bool is_legacy_object () const { return true; } |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
95 bool is_constant () const { return true; } |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 bool load_ascii (std::istream& is); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 bool load_binary (std::istream& is, bool swap, |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 octave::mach_info::float_format fmt); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 bool load_hdf5 (octave_hdf5_id loc_id, const char *name); |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 private: |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 |
31468
777a42ebe45b
use opaque pointer for octave_legacy_range data member
John W. Eaton <jwe@octave.org>
parents:
31467
diff
changeset
|
106 std::unique_ptr<Range> m_range; |
30852
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 }; |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
95725e6ad9c1
restore part of the old octave_range class as octave_legacy_range
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 #endif |