28 #if defined (HAVE_CONFIG_H)
55 for (
int i = 0; i < nd; i++)
64 m_num_dims = (j > 2 ? j : 2);
70 std::ostringstream buf;
72 for (
int i = 0; i <
ndims (); i++)
80 std::string retval = buf.str ();
90 for (
int i = 0; i <
ndims (); i++)
102 int n_dims =
ndims ();
104 for (
int i = 0; i < n_dims; i++)
110 throw std::bad_alloc ();
123 if (new_dims.
ndims () == 2 &&
xelem(0) == 1 && new_dims.
elem(1) == 1)
124 return new_dims.
as_row ();
142 int orig_nd =
ndims ();
143 int ndb = dvb.
ndims ();
144 int new_nd = (dim < ndb ? ndb : dim + 1);
145 if (new_nd > orig_nd)
152 for (
int i = 0; i < ndb; i++)
154 if (i != dim &&
xelem(i) != dvb(i))
161 for (
int i = ndb; i < new_nd; i++)
163 if (i != dim &&
xelem(i) != 1)
171 xelem(dim) += (dim < ndb ? dvb(dim) : 1);
175 if (ndb == 2 && dvb(0) == 0 && dvb(1) == 0)
177 else if (orig_nd == 2 &&
xelem(0) == 0 &&
xelem(1) == 0)
208 bool e2dvb = dvb(0) + dvb(1) == 1;
228 int n_dims =
ndims ();
236 std::copy_n (m_dims, n_dims, retval.m_dims);
237 std::fill_n (retval.m_dims + n_dims,
n - n_dims, 1);
248 std::copy_n (m_dims,
n-1, retval.m_dims);
252 for (
int i =
n; i < n_dims; i++)
273 retval(i) =
elem (i);
charNDArray max(char d, const charNDArray &m)
Vector representing the dimensions (size) of an Array.
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
octave_idx_type safe_numel() const
The following function will throw a std::bad_alloc () exception if the requested size is larger than ...
std::string str(char sep='x') const
void chop_trailing_singletons()
dim_vector squeeze() const
void resize(int n, int fill_value=0)
static dim_vector alloc(int n)
Array< octave_idx_type > as_array() const
octave_idx_type ndims() const
Number of dimensions.
static octave_idx_type dim_max()
void chop_all_singletons()
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
octave_idx_type & xelem(int i)
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
octave_idx_type & elem(int i)
dim_vector as_row() const