26 #if defined (HAVE_CONFIG_H)
54 OCTAVE_NORETURN
static
58 error (
"%s (%s vs %s)", msg,
x.str ().c_str (), y.
str ().c_str ());
65 bool elt_changed =
false;
67 for (
auto& elt : m_values)
85 bool first_elem =
true;
87 for (
const auto& val : m_values)
100 else if (! m_dv.hvcat (this_elt_dv, 1))
101 eval_error (
"horizontal dimensions mismatch", m_dv, this_elt_dv);
107 tm_row_const::init_element (
const octave_value& val,
bool& first_elem)
109 std::string this_elt_class_name
131 m_values.push_back (val);
174 bool first_elem =
true;
176 for (
auto *elt : row)
184 error (
"undefined element in matrix list");
194 init_element (tlst(i), first_elem);
198 init_element (tmp, first_elem);
206 for (
const auto& val : m_values)
222 eval_error (
"horizontal dimensions mismatch",
m_dv, this_elt_dv);
230 if (m_tm_rows.empty ())
238 return class_concat ();
239 else if (result_type ==
"double")
244 return sparse_array_concat<SparseMatrix> ();
246 return sparse_array_concat<SparseComplexMatrix> ();
251 return array_concat<NDArray> ();
253 return array_concat<ComplexNDArray> ();
256 else if (result_type ==
"single")
259 return array_concat<FloatNDArray> ();
261 return array_concat<FloatComplexNDArray> ();
263 else if (result_type ==
"char")
267 "numeric", result_type);
271 return char_array_concat (string_fill_char);
273 else if (result_type ==
"logical")
276 return sparse_array_concat<SparseBoolMatrix> ();
278 return array_concat<boolNDArray> ();
280 else if (result_type ==
"int8")
281 return array_concat<int8NDArray> ();
282 else if (result_type ==
"int16")
283 return array_concat<int16NDArray> ();
284 else if (result_type ==
"int32")
285 return array_concat<int32NDArray> ();
286 else if (result_type ==
"int64")
287 return array_concat<int64NDArray> ();
288 else if (result_type ==
"uint8")
289 return array_concat<uint8NDArray> ();
290 else if (result_type ==
"uint16")
291 return array_concat<uint16NDArray> ();
292 else if (result_type ==
"uint32")
293 return array_concat<uint32NDArray> ();
294 else if (result_type ==
"uint64")
295 return array_concat<uint64NDArray> ();
296 else if (result_type ==
"cell")
297 return array_concat<Cell> ();
298 else if (result_type ==
"struct")
301 return map_concat<octave_scalar_map> ();
303 return map_concat<octave_map> ();
306 return generic_concat ();
322 bool first_elem =
true;
323 bool first_elem_is_struct =
false;
329 for (
const auto *elt : tm)
337 first_elem_is_struct = row.first_elem_struct_p ();
377 m_tm_rows.push_back (row);
382 for (
auto& elt : m_tm_rows)
392 for (
const auto& elt : m_tm_rows)
399 std::string this_elt_class_name = elt.class_name ();
413 && this_elt_dv.
ndims () == 2)
425 if (this_elt_nc >
cols ())
426 m_dv(1) = this_elt_nc;
427 m_dv(0) += this_elt_nr;
431 eval_error (
"vertical dimensions mismatch",
m_dv, this_elt_dv);
436 tm_const::char_array_concat (
char string_fill_char)
const
442 array_concat_internal<charNDArray> (result);
448 tm_const::class_concat ()
const
455 for (
const auto& tmrc : m_tm_rows)
459 if (tmrc.length () == 1)
460 rows(j++) = *(tmrc.begin ());
466 for (
const auto& elt : tmrc)
473 if (
rows.length () == 1)
482 tm_const::generic_concat ()
const
515 for (
const auto& row : m_tm_rows)
519 for (
const auto& elt : row)
526 goto found_non_empty;
530 ctmp = (*(m_tm_rows.begin () -> begin ()));
549 for (
const auto& row : m_tm_rows)
553 for (
const auto& elt : row)
584 template <
typename TYPE>
586 tm_const::array_concat_internal (TYPE& result)
const
591 for (
const auto& row : m_tm_rows)
594 if (row.dims ().any_zero ())
597 for (
const auto& elt : row)
601 TYPE ra = octave_value_extract<TYPE> (elt);
607 result.insert (ra,
r, c);
618 template <
typename TYPE>
620 tm_const::array_concat ()
const
622 typedef typename TYPE::element_type ELT_T;
627 if (m_tm_rows.size () == 1)
638 panic_unless (
static_cast<std::size_t
> (result.numel ())
641 for (
const auto& elt : row)
642 result(i++) = octave_value_extract<ELT_T> (elt);
651 for (
const auto& elt : row)
655 array_list[i++] = octave_value_extract<TYPE> (elt);
658 return TYPE::cat (-2, ncols, array_list);
663 array_concat_internal<TYPE> (result);
668 template <
typename TYPE>
670 tm_const::sparse_array_concat ()
const
681 for (
const auto& row : m_tm_rows)
687 for (
auto& elt : row)
691 sparse_list[i] = octave_value_extract<TYPE> (elt);
695 TYPE stmp = TYPE::cat (-2, ncols, sparse_list);
696 sparse_row_list[j] = stmp;
700 return TYPE::cat (-1, nrows, sparse_row_list);
703 template <
typename MAP>
705 tm_const::map_concat ()
const
713 for (
const auto& row : m_tm_rows)
719 for (
auto& elt : row)
723 map_list[i] = octave_value_extract<MAP> (elt);
728 map_row_list[j] = mtmp;
735 OCTAVE_END_NAMESPACE(
octave)
Vector representing the dimensions (size) of an Array.
std::string str(char sep='x') const
octave_idx_type ndims() const
Number of dimensions.
bool zero_by_zero() const
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
type_info & get_type_info()
octave_value resize(const dim_vector &dv, bool=false) const
octave_idx_type rows() const
octave_idx_type columns() const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
octave_idx_type length() const
octave_value_list list_value() const
bool all_zero_dims() const
bool is_undefined() const
std::string class_name() const
bool is_dq_string() const
bool is_sq_string() const
octave_idx_type numel() const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
octave_value resize(const dim_vector &dv, bool fill=false) const
octave_value concat(char string_fill_char) const
bool m_first_elem_is_struct
octave_idx_type cols() const
octave_idx_type rows() const
std::size_t length() const
interpreter & get_interpreter()
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave_value do_class_concat(const octave_value_list &ovl, const std::string &cattype, int dim)
void() error(const char *fmt,...)
#define panic_unless(cond)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
F77_RET_T const F77_DBLE * x
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value cat_op(type_info &ti, const octave_value &a, const octave_value &b, const Array< octave_idx_type > &ra_idx)
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
std::string get_concat_class(const std::string &c1, const std::string &c2)