chromium/third_party/eigen3/src/Eigen/src/Core/Transpositions.h

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2010-2011 Gael Guennebaud <[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_TRANSPOSITIONS_H
#define EIGEN_TRANSPOSITIONS_H

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

namespace Eigen {

template <typename Derived>
class TranspositionsBase {};

namespace internal {
traits<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_>>;
}  // namespace internal

/** \class Transpositions
 * \ingroup Core_Module
 *
 * \brief Represents a sequence of transpositions (row/column interchange)
 *
 * \tparam SizeAtCompileTime the number of transpositions, or Dynamic
 * \tparam MaxSizeAtCompileTime the maximum number of transpositions, or Dynamic. This optional parameter defaults to
 * SizeAtCompileTime. Most of the time, you should not have to specify it.
 *
 * This class represents a permutation transformation as a sequence of \em n transpositions
 * \f$[T_{n-1} \ldots T_{i} \ldots T_{0}]\f$. It is internally stored as a vector of integers \c indices.
 * Each transposition \f$ T_{i} \f$ applied on the left of a matrix (\f$ T_{i} M\f$) interchanges
 * the rows \c i and \c indices[i] of the matrix \c M.
 * A transposition applied on the right (e.g., \f$ M T_{i}\f$) yields a column interchange.
 *
 * Compared to the class PermutationMatrix, such a sequence of transpositions is what is
 * computed during a decomposition with pivoting, and it is faster when applying the permutation in-place.
 *
 * To apply a sequence of transpositions to a matrix, simply use the operator * as in the following example:
 * \code
 * Transpositions tr;
 * MatrixXf mat;
 * mat = tr * mat;
 * \endcode
 * In this example, we detect that the matrix appears on both side, and so the transpositions
 * are applied in-place without any temporary or extra copy.
 *
 * \sa class PermutationMatrix
 */

template <int SizeAtCompileTime, int MaxSizeAtCompileTime, typename StorageIndex_>
class Transpositions
    : public TranspositionsBase<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_> > {};

namespace internal {
traits<Map<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_>, PacketAccess_>>;
}  // namespace internal

Map<Transpositions<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_>, PacketAccess>;

namespace internal {
traits<TranspositionsWrapper<IndicesType_>>;
}  // namespace internal

template <typename IndicesType_>
class TranspositionsWrapper : public TranspositionsBase<TranspositionsWrapper<IndicesType_> > {};

/** \returns the \a matrix with the \a transpositions applied to the columns.
 */
template <typename MatrixDerived, typename TranspositionsDerived>
EIGEN_DEVICE_FUNC const Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct> operator*(
    const MatrixBase<MatrixDerived>& matrix, const TranspositionsBase<TranspositionsDerived>& transpositions) {}

/** \returns the \a matrix with the \a transpositions applied to the rows.
 */
template <typename TranspositionsDerived, typename MatrixDerived>
EIGEN_DEVICE_FUNC const Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct> operator*(
    const TranspositionsBase<TranspositionsDerived>& transpositions, const MatrixBase<MatrixDerived>& matrix) {}

// Template partial specialization for transposed/inverse transpositions

namespace internal {

traits<Transpose<TranspositionsBase<Derived>>>;

}  // end namespace internal

Transpose<TranspositionsBase<TranspositionsDerived>>;

}  // end namespace Eigen

#endif  // EIGEN_TRANSPOSITIONS_H