Mercurial > hg > octave-lyh
annotate liboctave/array/MArray-defs.h @ 16169:0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
* libinterp/interpfcn/pr-output.cc(octave_print_internal): print base
or limit of range rather than using expression base+i*increment
which can destroy the signbit of base/limit.
* liboctave/array/Range.cc(Range constructor): Move trivial 2-line constructor
to .h file.
* liboctave/array/Range.cc(matrix_value, checkelem): Return base for first
element of array. Return limit of range for end of array if appropriate.
* liboctave/array/Range.cc(elem): Move function from Range.h Return base for
first element of array. Return limit of range for end of array if appropriate.
* liboctave/array/Range.cc(_rangeindex_helper, index): Return base for first
element of array. Return limit of range for end of array if appropriate.
* liboctave/array/Range.cc(min, max): Use '<=' or '>=' tests to
return base or limit if appropriate.
* liboctave/array/Range.cc(is_sorted): Place more common test first in
if/else if/else tree.
* liboctave/array/Range.cc(operator <<): Return base for first
element of array. Return limit of range for end of array if appropriate.
liboctave/array/Range.h(Range constructor): Put trivial 2-line constructor
in .h file.
liboctave/array/Range.h(elem): Move function which has become more complicated
to Range.cc.
* test/range.tst: Add %!tests for corner cases of base and limit of range.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 01 Mar 2013 14:06:02 -0800 |
parents | 648dabbb4c6b |
children |
rev | line source |
---|---|
7016 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague, a.s. |
7016 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 3 of the License, or (at your | |
11 option) any later version. | |
12 | |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with Octave; see the file COPYING. If not, see | |
20 <http://www.gnu.org/licenses/>. | |
21 | |
22 */ | |
23 | |
3741 | 24 #if !defined (octave_MArray_defs_h) |
25 #define octave_MArray_defs_h 1 | |
26 | |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
27 #include "mx-inlines.cc" |
1988 | 28 |
3573 | 29 // Instantiate the OP= operators. |
6708 | 30 #define MARRAY_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \ |
31 MARRAY_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T) | |
3573 | 32 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
33 #define MARRAY_OP_ASSIGN_DEFS1(A_T, E_T, RHS_T, API) \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
34 MARRAY_OP_ASSIGN_DECLS1 (A_T, E_T, template, API, , RHS_T) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
35 |
3573 | 36 // Instantiate the unary operators. |
6708 | 37 #define MARRAY_UNOP_DEFS(A_T, E_T, API) \ |
38 MARRAY_UNOP_DECLS (A_T, E_T, template, API, ) | |
3573 | 39 |
40 // Instantiate the binary operators. | |
6708 | 41 #define MARRAY_BINOP_DEFS(A_T, E_T, API) \ |
42 MARRAY_BINOP_DECLS (A_T, E_T, template, API, , A_T<E_T>, E_T) \ | |
43 MARRAY_BINOP_DECLS (A_T, E_T, template, API, , E_T, A_T<E_T>) \ | |
44 MARRAY_AA_BINOP_DECLS (A_T, E_T, template, API, ) | |
3573 | 45 |
6708 | 46 #define MDIAGARRAY2_BINOP_DEFS(A_T, E_T, API) \ |
47 MDIAGARRAY2_DAS_BINOP_DECLS (A_T, E_T, template, API, , A_T<E_T>, E_T) \ | |
48 MDIAGARRAY2_SDA_BINOP_DECLS (A_T, E_T, template, API, , E_T, A_T<E_T>) \ | |
49 MDIAGARRAY2_DADA_BINOP_DECLS (A_T, E_T, template, API, ) | |
3580 | 50 |
3573 | 51 // The following macros are for external use. |
52 | |
53 // Instantiate all the MArray friends for MArray element type T. | |
6708 | 54 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \ |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
55 MARRAY_OP_ASSIGN_DEFS1 (MArray, T, T, API) \ |
6708 | 56 MARRAY_OP_ASSIGN_DEFS (MArray, T, MArray<T>, API) \ |
57 MARRAY_UNOP_DEFS (MArray, T, API) \ | |
58 MARRAY_BINOP_DEFS (MArray, T, API) | |
3573 | 59 |
4513 | 60 // Instantiate all the MDiagArray2 friends for MDiagArray2 element type T. |
6708 | 61 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \ |
62 MARRAY_UNOP_DEFS (MDiagArray2, T, API) \ | |
63 MDIAGARRAY2_BINOP_DEFS (MDiagArray2, T, API) | |
3580 | 64 |
3573 | 65 // Now we have all the definitions we need. |
66 | |
3741 | 67 #endif |