Mercurial > octave
diff src/OPERATORS/op-struct.cc @ 7959:a73b80cd1f10
allow empty matrix by cell (or struct) concatentation
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 21 Jul 2008 16:06:57 -0400 |
parents | a1dbe9d80eee |
children | cc29ef9a2d84 |
line wrap: on
line diff
--- a/src/OPERATORS/op-struct.cc Mon Jul 21 15:27:22 2008 -0400 +++ b/src/OPERATORS/op-struct.cc Mon Jul 21 16:06:57 2008 -0400 @@ -27,6 +27,7 @@ #include "gripes.h" #include "oct-obj.h" #include "ov.h" +#include "ov-re-mat.h" #include "ov-struct.h" #include "ov-typeinfo.h" #include "ops.h" @@ -48,6 +49,36 @@ DEFNDCATOP_FN (struct_struct, struct, struct, map, map, concat) +static octave_value +oct_catop_struct_matrix (octave_base_value& a1, const octave_base_value& a2, + const Array<octave_idx_type>&) +{ + octave_value retval; + CAST_BINOP_ARGS (const octave_struct&, const octave_matrix&); + NDArray tmp = v2.array_value (); + dim_vector dv = tmp.dims (); + if (dv.all_zero ()) + retval = octave_value (v1.map_value ()); + else + error ("invalid concatenation of structure with matrix"); + return retval; +} + +static octave_value +oct_catop_matrix_struct (octave_base_value& a1, const octave_base_value& a2, + const Array<octave_idx_type>&) +{ + octave_value retval; + CAST_BINOP_ARGS (const octave_struct&, const octave_matrix&); + NDArray tmp = v1.array_value (); + dim_vector dv = tmp.dims (); + if (dv.all_zero ()) + retval = octave_value (v2.map_value ()); + else + error ("invalid concatenation of structure with matrix"); + return retval; +} + void install_struct_ops (void) { @@ -55,6 +86,8 @@ INSTALL_UNOP (op_hermitian, octave_struct, transpose); INSTALL_CATOP (octave_struct, octave_struct, struct_struct); + INSTALL_CATOP (octave_struct, octave_matrix, struct_matrix); + INSTALL_CATOP (octave_matrix, octave_struct, matrix_struct); } /*