/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #pragma once #include #include "eckit/linalg/Matrix.h" #include "eckit/linalg/Vector.h" #include "atlas/array/LocalView.h" #include "atlas/linalg/Introspection.h" namespace atlas { namespace linalg { template using View = array::LocalView; namespace view { template struct Convert { using value_type = typename std::conditional::value, const introspection::value_type, introspection::value_type>::type; using type = array::LocalView()>; static type apply(View& view) { return type(view.data(), view.shape()); } }; template struct Convert { using value_type = typename std::conditional::value, const eckit::linalg::Scalar, eckit::linalg::Scalar>::type; using type = array::LocalView; static type apply(View& v) { return type(v.data(), array::make_shape(v.size())); } }; template struct Convert { using value_type = typename std::conditional::value, const eckit::linalg::Scalar, eckit::linalg::Scalar>::type; using type = array::LocalView; static type apply(View& m) { return type(m.data(), array::make_shape(m.cols(), m.rows())); } }; template struct ConvertView { using type = typename Convert>::type; static type apply(View& v) { return Convert>::apply(v); } }; } // namespace view template using view_type = typename view::ConvertView::type; template view_type make_view(T& view) { return view::ConvertView::apply(view); } } // namespace linalg } // namespace atlas