comparison libinterp/operators/op-struct.cc @ 15195:2fc554ffbc28

split libinterp from src * libinterp: New directory. Move all files from src directory here except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc, mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh. * libinterp/Makefile.am: New file, extracted from src/Makefile.am. * src/Makefile.am: Delete everything except targets and definitions needed to build and link main and utility programs. * Makefile.am (SUBDIRS): Include libinterp in the list. * autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not src/dldfcn directory. * configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not src/octave.cc. (DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src. (AC_CONFIG_FILES): Include libinterp/Makefile in the list. * find-docstring-files.sh: Look in libinterp, not src. * gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in libinterp, not src.
author John W. Eaton <jwe@octave.org>
date Sat, 18 Aug 2012 16:23:39 -0400
parents src/operators/op-struct.cc@46b19589b593
children d63878346099
comparison
equal deleted inserted replaced
15194:0f0b795044c3 15195:2fc554ffbc28
1 /*
2
3 Copyright (C) 1996-2012 John W. Eaton
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include "gripes.h"
28 #include "oct-obj.h"
29 #include "ov.h"
30 #include "ov-re-mat.h"
31 #include "ov-struct.h"
32 #include "ov-typeinfo.h"
33 #include "ops.h"
34
35 // struct ops.
36
37 DEFUNOP (transpose, struct)
38 {
39 CAST_UNOP_ARG (const octave_struct&);
40
41 if (v.ndims () > 2)
42 {
43 error ("transpose not defined for N-d objects");
44 return octave_value ();
45 }
46 else
47 return octave_value (v.map_value ().transpose ());
48 }
49
50 DEFUNOP (scalar_transpose, scalar_struct)
51 {
52 CAST_UNOP_ARG (const octave_scalar_struct&);
53
54 return octave_value (v.scalar_map_value ());
55 }
56
57 DEFNDCATOP_FN (s_s_concat, struct, struct, map, map, concat)
58 DEFNDCATOP_FN (s_ss_concat, struct, scalar_struct, map, map, concat)
59 DEFNDCATOP_FN (ss_s_concat, scalar_struct, struct, map, map, concat)
60 DEFNDCATOP_FN (ss_ss_concat, scalar_struct, scalar_struct, map, map, concat)
61
62 static octave_value
63 oct_catop_struct_matrix (octave_base_value& a1, const octave_base_value& a2,
64 const Array<octave_idx_type>&)
65 {
66 octave_value retval;
67 CAST_BINOP_ARGS (const octave_struct&, const octave_matrix&);
68 NDArray tmp = v2.array_value ();
69 dim_vector dv = tmp.dims ();
70 if (dv.all_zero ())
71 retval = octave_value (v1.map_value ());
72 else
73 error ("invalid concatenation of structure with matrix");
74 return retval;
75 }
76
77 static octave_value
78 oct_catop_matrix_struct (octave_base_value& a1, const octave_base_value& a2,
79 const Array<octave_idx_type>&)
80 {
81 octave_value retval;
82 CAST_BINOP_ARGS (const octave_matrix&, const octave_struct&);
83 NDArray tmp = v1.array_value ();
84 dim_vector dv = tmp.dims ();
85 if (dv.all_zero ())
86 retval = octave_value (v2.map_value ());
87 else
88 error ("invalid concatenation of structure with matrix");
89 return retval;
90 }
91
92 void
93 install_struct_ops (void)
94 {
95 INSTALL_UNOP (op_transpose, octave_struct, transpose);
96 INSTALL_UNOP (op_hermitian, octave_struct, transpose);
97
98 INSTALL_UNOP (op_transpose, octave_scalar_struct, scalar_transpose);
99 INSTALL_UNOP (op_hermitian, octave_scalar_struct, scalar_transpose);
100
101 INSTALL_CATOP (octave_struct, octave_struct, s_s_concat);
102 INSTALL_CATOP (octave_struct, octave_scalar_struct, s_ss_concat)
103 INSTALL_CATOP (octave_scalar_struct, octave_struct, ss_s_concat)
104 INSTALL_CATOP (octave_scalar_struct, octave_scalar_struct, ss_ss_concat)
105
106 INSTALL_CATOP (octave_struct, octave_matrix, struct_matrix);
107 INSTALL_CATOP (octave_matrix, octave_struct, matrix_struct);
108 }