Skip to content

Commit

Permalink
Update to xtensor latest version (0.18) (#35)
Browse files Browse the repository at this point in the history
* use view instead of strided_view (fixed upstream)

* assign on views with keep broken or misuse? simpler alternative

* temp fix for python bindings (remove when xtensor 0.18 is out)

* update header xstrided_view.hpp > xmanipulation.hpp

* remove temp fix

* add xtensor minimum version number in docs
  • Loading branch information
benbovy authored Nov 5, 2018
1 parent 3d6c7b2 commit 87a55ab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Install Fastscapelib
====================

This library is header only and uses C++14 standards. It depends on
xtensor_.
xtensor_ (>0.18).

.. _xtensor: https://github.com/QuantStack/xtensor

Expand Down
2 changes: 1 addition & 1 deletion include/fastscapelib/bedrock_channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <type_traits>

#include "xtensor/xtensor.hpp"
#include "xtensor/xstrided_view.hpp"
#include "xtensor/xmanipulation.hpp"

#include "fastscapelib/utils.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/fastscapelib/flow_routing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "xtensor/xtensor.hpp"
#include "xtensor/xview.hpp"
#include "xtensor/xstrided_view.hpp"
#include "xtensor/xmanipulation.hpp"

#include "fastscapelib/utils.hpp"
#include "fastscapelib/consts.hpp"
Expand Down
33 changes: 20 additions & 13 deletions include/fastscapelib/hillslope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "xtensor/xbuilder.hpp"
#include "xtensor/xnoalias.hpp"
#include "xtensor/xview.hpp"
#include "xtensor/xstrided_view.hpp"
#include "xtensor/xmanipulation.hpp"

#include "fastscapelib/utils.hpp"

Expand Down Expand Up @@ -163,10 +163,9 @@ auto solve_diffusion_adi_row(Ei&& elevation,

for (index_t r=1; r<nrows-1; ++r)
{
// TODO use xt::view with xbroadcast (check xtensor #1036 #917)
xt::noalias(lower) = -1 * xt::strided_view(factors_col, {0, r, xt::all()});
xt::noalias(diag) = 1 + 2 * xt::strided_view(factors_col, {1, r, xt::all()});
xt::noalias(upper) = -1 * xt::strided_view(factors_col, {2, r, xt::all()});
xt::noalias(lower) = -1 * xt::view(factors_col, 0, r, xt::all());
xt::noalias(diag) = 1 + 2 * xt::view(factors_col, 1, r, xt::all());
xt::noalias(upper) = -1 * xt::view(factors_col, 2, r, xt::all());

for (index_t c=1; c<ncols-1; ++c)
{
Expand All @@ -176,15 +175,23 @@ auto solve_diffusion_adi_row(Ei&& elevation,
}

// boundary conditions
auto lower_bounds = xt::view(lower, xt::keep(0, -1));
lower_bounds = 0;
auto diag_bounds = xt::view(diag, xt::keep(0, -1));
diag_bounds = 1;
auto upper_bounds = xt::view(upper, xt::keep(0, -1));
upper_bounds = 0;
auto ilast = ncols - 1;

lower(0) = 0;
lower(ilast) = 0;
diag(0) = 1;
diag(ilast) = 1;
upper(0) = 0;
upper(ilast) = 0;
vec(0) = elevation(r, 0);
vec(ncols - 1) = elevation(r, ncols - 1);
// TODO: the code below works with xtensor 0.17.1 but not with 0.17.2
vec(ilast) = elevation(r, ilast);
// TODO: the code below works with xtensor 0.17.1 but not with later versions
// auto lower_bounds = xt::view(lower, xt::keep(0, -1));
// lower_bounds = 0;
// auto diag_bounds = xt::view(diag, xt::keep(0, -1));
// diag_bounds = 1;
// auto upper_bounds = xt::view(upper, xt::keep(0, -1));
// upper_bounds = 0;
// auto vec_bounds = xt::view(vec, xt::keep(0, -1));
// vec_bounds = xt::view(elevation, r, xt::keep(0, -1));

Expand Down

0 comments on commit 87a55ab

Please sign in to comment.