6 #ifndef MYRAMATH_DENSE_SWAPS_H     7 #define MYRAMATH_DENSE_SWAPS_H    14 #include <myramath/MYRAMATH_EXPORT.h>    18 #include <myramath/utility/detail/ssize.h>    19 #include <myramath/utility/detail/sdistance.h>    30 template<
class Number> 
class VectorRange;
    31 template<
class Number> 
class MatrixRange;
    32 template<
class Number> 
class Matrix;
    37 MYRAMATH_EXPORT 
void inverse_perm(
const intCRange& perm, 
const intRange& iperm);
    39 MYRAMATH_EXPORT std::vector<int> inverse_perm(
const intCRange& perm);
    43 MYRAMATH_EXPORT 
void swaps2iswaps(
const intCRange& swaps, 
const intRange& iswaps);
    45 MYRAMATH_EXPORT std::vector<int> swaps2iswaps(
const intCRange& swaps);
    49 MYRAMATH_EXPORT 
void perm2swaps(
const intCRange& perm, 
const intRange& swaps);
    51 MYRAMATH_EXPORT std::vector<int> perm2swaps(
const intCRange& perm);
    55 MYRAMATH_EXPORT 
void swaps2perm (
const intCRange& swaps, 
const intRange& perm);
    57 MYRAMATH_EXPORT std::vector<int> swaps2perm (
const intCRange& swaps);
    63 MYRAMATH_EXPORT 
void swaps2iperm (
const intCRange& swaps, 
const intRange& perm);
    64 MYRAMATH_EXPORT std::vector<int> swaps2iperm (
const intCRange& swaps);
    68 template<
class Number> Matrix<Number> 
swaps2Matrix (
const intCRange& swaps);
    70 template<> MYRAMATH_EXPORT Matrix<NumberS> swaps2Matrix<NumberS> (
const intCRange& swaps);
    71 template<> MYRAMATH_EXPORT Matrix<NumberD> swaps2Matrix<NumberD> (
const intCRange& swaps);
    72 template<> MYRAMATH_EXPORT Matrix<NumberC> swaps2Matrix<NumberC> (
const intCRange& swaps);
    73 template<> MYRAMATH_EXPORT Matrix<NumberZ> swaps2Matrix<NumberZ> (
const intCRange& swaps);
    79 MYRAMATH_EXPORT 
void swap_rows(
const intCRange& swaps, 
const MatrixRange<NumberS>& X);
    81 MYRAMATH_EXPORT 
void swap_rows(
const intCRange& swaps, 
const MatrixRange<NumberD>& X);
    82 MYRAMATH_EXPORT 
void swap_rows(
const intCRange& swaps, 
const MatrixRange<NumberC>& X);
    83 MYRAMATH_EXPORT 
void swap_rows(
const intCRange& swaps, 
const MatrixRange<NumberZ>& X);
    87 MYRAMATH_EXPORT 
void iswap_rows(
const intCRange& swaps, 
const MatrixRange<NumberS>& X);
    89 MYRAMATH_EXPORT 
void iswap_rows(
const intCRange& swaps, 
const MatrixRange<NumberD>& X);
    90 MYRAMATH_EXPORT 
void iswap_rows(
const intCRange& swaps, 
const MatrixRange<NumberC>& X);
    91 MYRAMATH_EXPORT 
void iswap_rows(
const intCRange& swaps, 
const MatrixRange<NumberZ>& X);
    95 MYRAMATH_EXPORT 
void swap_columns(
const intCRange& swaps, 
const MatrixRange<NumberS>& X);
    97 MYRAMATH_EXPORT 
void swap_columns(
const intCRange& swaps, 
const MatrixRange<NumberD>& X);
    98 MYRAMATH_EXPORT 
void swap_columns(
const intCRange& swaps, 
const MatrixRange<NumberC>& X);
    99 MYRAMATH_EXPORT 
void swap_columns(
const intCRange& swaps, 
const MatrixRange<NumberZ>& X);
   103 MYRAMATH_EXPORT 
void iswap_columns(
const intCRange& swaps, 
const MatrixRange<NumberS>& X);
   105 MYRAMATH_EXPORT 
void iswap_columns(
const intCRange& swaps, 
const MatrixRange<NumberD>& X);
   106 MYRAMATH_EXPORT 
void iswap_columns(
const intCRange& swaps, 
const MatrixRange<NumberC>& X);
   107 MYRAMATH_EXPORT 
void iswap_columns(
const intCRange& swaps, 
const MatrixRange<NumberZ>& X);
   111 MYRAMATH_EXPORT 
void swap_vector(
const intCRange& swaps, 
const VectorRange<NumberS>& x);
   113 MYRAMATH_EXPORT 
void swap_vector(
const intCRange& swaps, 
const VectorRange<NumberD>& x);
   114 MYRAMATH_EXPORT 
void swap_vector(
const intCRange& swaps, 
const VectorRange<NumberC>& x);
   115 MYRAMATH_EXPORT 
void swap_vector(
const intCRange& swaps, 
const VectorRange<NumberZ>& x);
   119 MYRAMATH_EXPORT 
void swap_vector(
const intCRange& swaps, 
const intRange& x);
   122 MYRAMATH_EXPORT 
void iswap_vector(
const intCRange& swaps, 
const VectorRange<NumberS>& x);
   124 MYRAMATH_EXPORT 
void iswap_vector(
const intCRange& swaps, 
const VectorRange<NumberD>& x);
   125 MYRAMATH_EXPORT 
void iswap_vector(
const intCRange& swaps, 
const VectorRange<NumberC>& x);
   126 MYRAMATH_EXPORT 
void iswap_vector(
const intCRange& swaps, 
const VectorRange<NumberZ>& x);
   130 MYRAMATH_EXPORT 
void iswap_vector(
const intCRange& swaps, 
const intRange& x);
   136   if (swaps.
N != sdistance(begin,end))
   137     throw eprintf(
"swap_range(): size mismatch, swaps.N != range size [%d != %d]", swaps.
N, sdistance(begin,end));
   139   for (
int n = 0; n < N; ++n)
   140     std::swap( begin[n], begin[swaps[n]] );
   146   if (swaps.
N != sdistance(begin,end))
   147     throw eprintf(
"iswap_range(): size mismatch, swaps.N != range size [%d != %d]", swaps.
N, sdistance(begin,end));
   149   for (
int n = N-1; n >= 0; --n)
   150     std::swap( begin[n], begin[swaps[n]] ); 
   154 template<
class T> 
void swap_vector(
const intCRange& swaps, std::vector<T>& v)
   158 template<
class T> 
void iswap_vector(
const intCRange& swaps, std::vector<T>& v)
 Returns a std::runtime_error() whose message has been populated using printf()-style formatting...
Matrix< Number > swaps2Matrix(const intCRange &swaps)
Given a swaps sequence, returns an equivalent permutation Matrix, P. 
void iswap_range(const intCRange &swaps, T *begin, T *end)
Inverts swaps on a range of T*. 
Definition: swaps.h:144
int size() const
Size inspector. 
Definition: intRange.cpp:205
void swap_range(const intCRange &swaps, T *begin, T *end)
Applies swaps on a range of T*. 
Definition: swaps.h:134
Various utility functions/classes related to scalar Number types. 
int N
---------— Data members, all public ----------------— 
Definition: intRange.h:149
Represents a const intRange. 
Definition: intRange.h:142
Interface class for representing subranges of contiguous int's.