Mercurial > octave
annotate libinterp/operators/op-struct.cc @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
4939 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 1996-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
7 |
4939 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 (at your option) any later version. |
4939 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
19 GNU General Public License for more details. |
4939 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
4939 | 24 |
25 */ | |
26 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
28 # include "config.h" |
4939 | 29 #endif |
30 | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21014
diff
changeset
|
31 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20833
diff
changeset
|
32 #include "ovl.h" |
4939 | 33 #include "ov.h" |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
34 #include "ov-re-mat.h" |
4939 | 35 #include "ov-struct.h" |
36 #include "ov-typeinfo.h" | |
37 #include "ops.h" | |
38 | |
39 // struct ops. | |
40 | |
12646
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 DEFUNOP (transpose, struct) |
5571 | 42 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
43 const octave_struct& v = dynamic_cast<const octave_struct&> (a); |
5571 | 44 |
45 if (v.ndims () > 2) | |
21014
b9d4c3615e89
maint: Capitalize D for dimension in messages and comments.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
46 error ("transpose not defined for N-D objects"); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
47 |
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
48 return octave_value (v.map_value ().transpose ()); |
5571 | 49 } |
50 | |
12646
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 DEFUNOP (scalar_transpose, scalar_struct) |
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
52 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
53 const octave_scalar_struct& v = dynamic_cast<const octave_scalar_struct&> (a); |
12646
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
54 |
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
55 return octave_value (v.scalar_map_value ()); |
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 } |
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 |
12760
e8fe03bfc051
allow concatenation of scalar structures with []
John W. Eaton <jwe@octave.org>
parents:
12646
diff
changeset
|
58 DEFNDCATOP_FN (s_s_concat, struct, struct, map, map, concat) |
e8fe03bfc051
allow concatenation of scalar structures with []
John W. Eaton <jwe@octave.org>
parents:
12646
diff
changeset
|
59 DEFNDCATOP_FN (s_ss_concat, struct, scalar_struct, map, map, concat) |
e8fe03bfc051
allow concatenation of scalar structures with []
John W. Eaton <jwe@octave.org>
parents:
12646
diff
changeset
|
60 DEFNDCATOP_FN (ss_s_concat, scalar_struct, struct, map, map, concat) |
e8fe03bfc051
allow concatenation of scalar structures with []
John W. Eaton <jwe@octave.org>
parents:
12646
diff
changeset
|
61 DEFNDCATOP_FN (ss_ss_concat, scalar_struct, scalar_struct, map, map, concat) |
4939 | 62 |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
63 static octave_value |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
64 oct_catop_struct_matrix (octave_base_value& a1, const octave_base_value& a2, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
65 const Array<octave_idx_type>&) |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
66 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
67 const octave_struct& v1 = dynamic_cast<const octave_struct&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
68 const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
69 |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
70 NDArray tmp = v2.array_value (); |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
71 dim_vector dv = tmp.dims (); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
72 |
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
73 if (! dv.all_zero ()) |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
74 error ("invalid concatenation of structure with matrix"); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
75 |
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
76 return octave_value (v1.map_value ()); |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
77 } |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
78 |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
79 static octave_value |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
80 oct_catop_matrix_struct (octave_base_value& a1, const octave_base_value& a2, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
81 const Array<octave_idx_type>&) |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
82 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
83 const octave_matrix& v1 = dynamic_cast<const octave_matrix&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
84 const octave_struct& v2 = dynamic_cast<const octave_struct&> (a2); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
85 |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
86 NDArray tmp = v1.array_value (); |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
87 dim_vector dv = tmp.dims (); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
88 |
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
89 if (! dv.all_zero ()) |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
90 error ("invalid concatenation of structure with matrix"); |
20833
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
91 |
9c4c87679985
restructure calls to error
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
92 return octave_value (v2.map_value ()); |
7959
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
93 } |
a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
94 |
4939 | 95 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
96 install_struct_ops (octave::type_info& ti) |
4939 | 97 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
98 INSTALL_UNOP_TI (ti, op_transpose, octave_struct, transpose); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
99 INSTALL_UNOP_TI (ti, op_hermitian, octave_struct, transpose); |
5571 | 100 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
101 INSTALL_UNOP_TI (ti, op_transpose, octave_scalar_struct, scalar_transpose); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
102 INSTALL_UNOP_TI (ti, op_hermitian, octave_scalar_struct, scalar_transpose); |
12646
eaba9d671fb7
Allow transpose to work for scalar structs (bug #33218)
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
103 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
104 INSTALL_CATOP_TI (ti, octave_struct, octave_struct, s_s_concat); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 INSTALL_CATOP_TI (ti, octave_struct, octave_scalar_struct, s_ss_concat) |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 INSTALL_CATOP_TI (ti, octave_scalar_struct, octave_struct, ss_s_concat) |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
107 INSTALL_CATOP_TI (ti, octave_scalar_struct, octave_scalar_struct, ss_ss_concat) |
12760
e8fe03bfc051
allow concatenation of scalar structures with []
John W. Eaton <jwe@octave.org>
parents:
12646
diff
changeset
|
108 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 INSTALL_CATOP_TI (ti, octave_struct, octave_matrix, struct_matrix); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 INSTALL_CATOP_TI (ti, octave_matrix, octave_struct, matrix_struct); |
4939 | 111 } |