chromium/third_party/eigen3/src/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2014 Benoit Steiner <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H
#define EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H

// IWYU pragma: private
#include "./InternalHeaderCheck.h"

namespace Eigen {

/** \class TensorLayoutSwap
 * \ingroup CXX11_Tensor_Module
 *
 * \brief Swap the layout from col-major to row-major, or row-major
 * to col-major, and invert the order of the dimensions.
 *
 * Beware: the dimensions are reversed by this operation. If you want to
 * preserve the ordering of the dimensions, you need to combine this
 * operation with a shuffle.
 *
 * \example:
 * Tensor<float, 2, ColMajor> input(2, 4);
 * Tensor<float, 2, RowMajor> output = input.swap_layout();
 * eigen_assert(output.dimension(0) == 4);
 * eigen_assert(output.dimension(1) == 2);
 *
 * array<int, 2> shuffle(1, 0);
 * output = input.swap_layout().shuffle(shuffle);
 * eigen_assert(output.dimension(0) == 2);
 * eigen_assert(output.dimension(1) == 4);
 *
 */
namespace internal {
traits<TensorLayoutSwapOp<XprType>>;

eval<TensorLayoutSwapOp<XprType>, Eigen::Dense>;

nested<TensorLayoutSwapOp<XprType>, 1, typename eval<TensorLayoutSwapOp<XprType>>::type>;

}  // end namespace internal

template <typename XprType>
class TensorLayoutSwapOp : public TensorBase<TensorLayoutSwapOp<XprType>, WriteAccessors> {};

// Eval as rvalue
TensorEvaluator<const TensorLayoutSwapOp<ArgType>, Device>;

// Eval as lvalue
TensorEvaluator<TensorLayoutSwapOp<ArgType>, Device>;

}  // end namespace Eigen

#endif  // EIGEN_CXX11_TENSOR_TENSOR_LAYOUT_SWAP_H