71 : count (1), dv (0, 0), all_str (false),
72 all_sq_str (false), all_dq_str (false),
73 some_str (false), all_real (false), all_cmplx (false),
74 all_mt (true), any_cell (false), any_sparse (false),
75 any_class (false), all_1x1 (false),
76 first_elem_is_struct (false), class_nm (), ok (false)
80 : count (1), dv (0, 0), all_str (false), all_sq_str (false),
81 some_str (false), all_real (false), all_cmplx (false),
82 all_mt (true), any_cell (false), any_sparse (false),
83 any_class (false), all_1x1 (! row.empty ()),
84 first_elem_is_struct (false), class_nm (), ok (false)
144 if (
this != &x && rep != x.
rep)
146 if (rep && --rep->count == 0)
160 if (rep && --rep->count == 0)
167 bool empty (
void)
const {
return rep->empty (); }
169 size_t length (
void)
const {
return rep->length (); }
186 std::string
class_name (
void)
const {
return rep->class_nm; }
190 operator bool ()
const {
return (rep && rep->ok); }
192 iterator
begin (
void) {
return rep->begin (); }
193 const_iterator
begin (
void)
const {
return rep->begin (); }
195 iterator
end (
void) {
return rep->end (); }
196 const_iterator
end (
void)
const {
return rep->end (); }
210 else if (c1.empty ())
212 else if (c2.empty ())
214 else if (c1 ==
"class" || c2 ==
"class")
218 bool c1_is_int = (c1 ==
"int8" || c1 ==
"uint8"
219 || c1 ==
"int16" || c1 ==
"uint16"
220 || c1 ==
"int32" || c1 ==
"uint32"
221 || c1 ==
"int64" || c1 ==
"uint64");
222 bool c2_is_int = (c2 ==
"int8" || c2 ==
"uint8"
223 || c2 ==
"int16" || c2 ==
"uint16"
224 || c2 ==
"int32" || c2 ==
"uint32"
225 || c2 ==
"int64" || c2 ==
"uint64");
227 bool c1_is_char = (c1 ==
"char");
228 bool c2_is_char = (c2 ==
"char");
230 bool c1_is_double = (c1 ==
"double");
231 bool c2_is_double = (c2 ==
"double");
233 bool c1_is_single = (c1 ==
"single");
234 bool c2_is_single = (c2 ==
"single");
236 bool c1_is_logical = (c1 ==
"logical");
237 bool c2_is_logical = (c2 ==
"logical");
239 bool c1_is_built_in_type
240 = (c1_is_int || c1_is_char || c1_is_double || c1_is_single
243 bool c2_is_built_in_type
244 = (c2_is_int || c2_is_char || c2_is_double || c2_is_single
249 if (c1 ==
"struct" && c2 == c1)
251 else if (c1 ==
"cell" || c2 ==
"cell")
253 else if (c1_is_char && c2_is_built_in_type)
255 else if (c2_is_char && c1_is_built_in_type)
257 else if (c1_is_int && c2_is_built_in_type)
259 else if (c2_is_int && c1_is_built_in_type)
261 else if (c1_is_single && c2_is_built_in_type)
263 else if (c2_is_single && c1_is_built_in_type)
265 else if (c1_is_double && c2_is_built_in_type)
267 else if (c2_is_double && c1_is_built_in_type)
269 else if (c1_is_logical && c2_is_logical)
279 ::error (
"%s (%s vs %s)", msg, x.
str ().c_str (), y.
str ().c_str ());
286 std::string this_elt_class_nm
351 bool first_elem =
true;
378 do_init_element (tlst(i), first_elem);
382 do_init_element (tmp, first_elem);
386 if (any_cell && ! any_class && ! first_elem_is_struct)
410 else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
412 eval_error (
"horizontal dimensions mismatch", dv, this_elt_dv);
425 bool elt_changed =
false;
441 bool first_elem =
true;
458 else if (! dv.hvcat (this_elt_dv, 1))
475 : dv (0, 0), all_str (false), all_sq_str (false), all_dq_str (false),
476 some_str (false), all_real (false), all_cmplx (false),
477 all_mt (true), any_cell (false), any_sparse (false),
478 any_class (false), class_nm (), ok (false)
502 operator bool ()
const {
return ok; }
544 all_1x1 = ! tm.
empty ();
546 bool first_elem =
true;
547 bool first_elem_is_struct =
false;
569 if (tmp && ! tmp.
empty ())
611 if (any_cell && ! any_class && ! first_elem_is_struct)
632 std::string this_elt_class_nm = elt.
class_name ();
645 else if (all_str && dv.length () == 2
646 && this_elt_dv.
length () == 2)
650 if (this_elt_nc >
cols ())
652 dv(0) += this_elt_nr;
654 else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
656 eval_error (
"vertical dimensions mismatch", dv, this_elt_dv);
671 error (
"invalid number of output arguments for matrix list");
673 retval = rvalue1 (nargout);
681 if (! (all_dq_strings_p || all_sq_strings_p))
683 "concatenation of different character string types may have unintended consequences");
686 template<
class TYPE,
class T>
707 TYPE ra = octave_value_extract<TYPE> (*q);
712 if (! ra.is_empty ())
731 template<
class TYPE,
class T>
753 assert (static_cast<size_t> (result.
numel ()) == row.
length ());
757 result(i++) = octave_value_extract<T> (*q);
772 array_list[i] = octave_value_extract<TYPE> (*q);
782 single_type_concat<TYPE> (result, tmp);
786 template<
class TYPE,
class T>
817 sparse_list[i] = octave_value_extract<TYPE> (*q);
822 sparse_row_list[j] = stmp;
857 map_list[i] = octave_value_extract<MAP> (*q);
862 map_row_list[j] = mtmp;
876 single_type_concat<TYPE> (result, dv, tmp);
888 if (tmp.all_1x1_p ())
889 single_type_concat<octave_scalar_map> (result, dv, tmp);
891 single_type_concat<octave_map> (result, dv, tmp);
926 if (
rows.length () == 1)
947 bool frc_str_conv =
false;
951 if (tmp && ! tmp.
empty ())
971 else if (result_type ==
"double")
976 retval = do_single_type_concat<SparseMatrix> (dv, tmp);
978 retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp);
983 retval = do_single_type_concat<NDArray> (dv, tmp);
985 retval = do_single_type_concat<ComplexNDArray> (dv, tmp);
988 else if (result_type ==
"single")
991 retval = do_single_type_concat<FloatNDArray> (dv, tmp);
993 retval = do_single_type_concat<FloatComplexNDArray> (dv, tmp);
995 else if (result_type ==
"char")
997 char type = all_dq_strings_p ?
'"' :
'\'';
1001 "numeric", result_type);
1007 single_type_concat<charNDArray> (result, tmp);
1011 else if (result_type ==
"logical")
1014 retval = do_single_type_concat<SparseBoolMatrix> (dv, tmp);
1016 retval = do_single_type_concat<boolNDArray> (dv, tmp);
1018 else if (result_type ==
"int8")
1019 retval = do_single_type_concat<int8NDArray> (dv, tmp);
1020 else if (result_type ==
"int16")
1021 retval = do_single_type_concat<int16NDArray> (dv, tmp);
1022 else if (result_type ==
"int32")
1023 retval = do_single_type_concat<int32NDArray> (dv, tmp);
1024 else if (result_type ==
"int64")
1025 retval = do_single_type_concat<int64NDArray> (dv, tmp);
1026 else if (result_type ==
"uint8")
1027 retval = do_single_type_concat<uint8NDArray> (dv, tmp);
1028 else if (result_type ==
"uint16")
1029 retval = do_single_type_concat<uint16NDArray> (dv, tmp);
1030 else if (result_type ==
"uint32")
1031 retval = do_single_type_concat<uint32NDArray> (dv, tmp);
1032 else if (result_type ==
"uint64")
1033 retval = do_single_type_concat<uint64NDArray> (dv, tmp);
1034 else if (result_type ==
"cell")
1035 retval = do_single_type_concat<Cell> (dv, tmp);
1036 else if (result_type ==
"struct")
1079 q != row.
end (); q++)
1086 goto found_non_empty;
1103 int dv_len = dv.
length ();
1138 if (frc_str_conv && ! retval.
is_string ())
1154 new_matrix->
copy_base (*
this, scope, context);
1388 DEFUN (string_fill_char, args, nargout,
1390 @deftypefn {Built-in Function} {@var{val} =} string_fill_char ()\n\
1391 @deftypefnx {Built-in Function} {@var{old_val} =} string_fill_char (@var{new_val})\n\
1392 @deftypefnx {Built-in Function} {} string_fill_char (@var{new_val}, \"local\")\n\
1393 Query or set the internal variable used to pad all rows of a character\n\
1394 matrix to the same length.\n\
1396 The value must be a single character and the default is @qcode{\" \"} (a\n\
1397 single space). For example:\n\
1401 string_fill_char (\"X\");\n\
1402 [ \"these\"; \"are\"; \"strings\" ]\n\
1403 @result{} \"theseXX\"\n\
1409 When called from inside a function with the @qcode{\"local\"} option, the\n\
1410 variable is changed locally for the function and any subroutines it calls.\n\
1411 The original variable value is restored when exiting the function.\n\
tm_row_const & operator=(const tm_row_const &x)
bool any_class_p(void) const
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
bool some_strings_p(void) const
void warning_with_id(const char *id, const char *fmt,...)
bool is_object(void) const
size_t length(void) const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
std::string str(char sep= 'x') const
bool is_real_type(void) const
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value do_cat_op(const octave_value &v1, const octave_value &v2, const Array< octave_idx_type > &ra_idx)
std::string get_concat_class(const std::string &c1, const std::string &c2)
octave_idx_type numel(void) const
Number of elements in the array.
bool all_real_p(void) const
std::string class_name(void) const
octave_idx_type length(void) const
static octave_value do_single_type_concat(const dim_vector &dv, tm_const &tmp)
bool all_dq_strings_p(void) const
bool all_complex_p(void) const
#define DEFUN(name, args_name, nargout_name, doc)
bool any_cell_p(void) const
bool all_empty_p(void) const
void error(const char *fmt,...)
tree_expression * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
#define SET_INTERNAL_VARIABLE(NM)
tm_const(const tree_matrix &tm)
bool all_strings_p(void) const
static Sparse< T > cat(int dim, octave_idx_type n, const Sparse< T > *sparse_list)
octave_value resize(const dim_vector &dv, bool fill=false) const
const_iterator end(void) const
octave_base_list< tree_argument_list * >::const_iterator const_iterator
static std::string static_class_name(void)
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
tm_row_const_rep::iterator iterator
bool any_sparse_p(void) const
std::list< octave_value >::iterator iterator
octave_idx_type columns(void) const
void append(const octave_value &s)
tm_row_const_rep::const_iterator const_iterator
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
bool is_sparse_type(void) const
octave_idx_type numel(const octave_value_list &idx)
static llvm::LLVMContext & context
size_t length(void) const
octave_value do_single_type_concat< octave_map >(const dim_vector &dv, tm_const &tmp)
static Array< T > cat(int dim, octave_idx_type n, const Array< T > *array_list)
Concatenation along a specified (0-based) dimension, equivalent to cat().
bool is_string(void) const
bool all_sq_strings_p(void) const
void accept(tree_walker &tw)
bool is_complex_type(void) const
octave_refcount< int > count
bool all_strings_p(void) const
bool some_strings_p(void) const
static octave_value do_class_concat(tm_const &tmc)
tm_row_const_rep(const tree_argument_list &row)
bool all_1x1_p(void) const
bool all_dq_strings_p(void) const
std::list< octave_value >::const_iterator const_iterator
bool all_zero_dims(void) const
octave_idx_type length(void) const
bool any_zero(void) const
void copy_base(const tree_array_list &array_list)
std::string class_name(void) const
dim_vector dims(void) const
octave_value rvalue1(int nargout=1)
bool first_elem_is_struct
bool all_complex_p(void) const
bool any_class_p(void) const
octave_value resize(const dim_vector &dv, bool=false) const
Handles the reference counting for all the derived classes.
virtual octave_value rvalue1(int nargout=1)
octave_idx_type cols(void) const
bool is_empty(void) const
octave_idx_type rows(void)
bool is_sq_string(void) const
void init(const tree_argument_list &)
bool all_sq_strings_p(void) const
dim_vector dims(void) const
const_iterator begin(void) const
bool is_dq_string(void) const
void do_init_element(const octave_value &, bool &)
bool zero_by_zero(void) const
bool is_cs_list(void) const
bool any_sparse_p(void) const
tm_row_const(const tree_argument_list &row)
bool all_real_p(void) const
bool any_cell_p(void) const
octave_idx_type rows(void) const
std::string class_name(void) const
octave_idx_type cols(void)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool all_1x1_p(void) const
bool is_undefined(void) const
tm_row_const(const tm_row_const &x)
octave_value_list list_value(void) const
void init(const tree_matrix &tm)
bool all_empty_p(void) const
static MArray< double > const octave_idx_type const octave_idx_type octave_idx_type octave_idx_type octave_idx_type c1
bool first_elem_struct_p(void) const
octave_value_list rvalue(int nargout)
static void single_type_concat(Array< T > &result, tm_const &tmp)
virtual void visit_matrix(tree_matrix &)=0
static void eval_error(const char *msg, const dim_vector &x, const dim_vector &y)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
F77_RET_T const double * x
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)