xtensor
xtensor copied to clipboard
Reshape Array
Currently I am using diff function to get difference but like python diff function (np.diff(WWdx, axis=1, prepend=0, append=0), it doesn't have prepand and append parameter.
I have array defined as below,
xt::xarray
Now I would like to add an extra column with all the value 0. So it would look like below,
xt::xarray
One thing you can do is
xt::xarray<double> b = xt::empty<double>({a.shape(0), a.shape(1) + 1});
xt::view(b, xt::all(), xt::range(3)) = a;
a = b;
but there are probably more efficient solutions