22 #ifndef bempp_index_permutation_hpp
23 #define bempp_index_permutation_hpp
25 #include "../common/common.hpp"
27 #include "../common/armadillo_fwd.hpp"
28 #include "../common/shared_ptr.hpp"
30 class Epetra_CrsMatrix;
43 m_permutedIndices(permutedIndices) {
47 if (m_permutedIndices.size() != other.m_permutedIndices.size())
49 for (
size_t i = 0; i < m_permutedIndices.size(); ++i)
50 if (m_permutedIndices[i] != other.m_permutedIndices[i])
56 return !operator==(other);
59 const std::vector<unsigned int>& permutedIndices()
const {
60 return m_permutedIndices;
63 std::vector<unsigned int> unpermutedIndices()
const {
64 std::vector<unsigned int> result(m_permutedIndices.size());
65 for (
unsigned int o = 0; o < m_permutedIndices.size(); ++o)
66 result[m_permutedIndices[o]] = o;
71 template <
typename ValueType>
73 arma::Col<ValueType>&
permuted)
const
75 const int dim = original.n_elem;
76 permuted.set_size(dim);
77 for (
int i = 0; i < dim; ++i)
78 permuted(m_permutedIndices[i]) = original(i);
82 template <
typename ValueType>
84 arma::Col<ValueType>& original)
const
86 const int dim = permuted.n_elem;
87 original.set_size(dim);
88 for (
int i = 0; i < dim; ++i)
89 original(i) =
permuted(m_permutedIndices[i]);
93 unsigned int permuted(
unsigned int index)
const {
94 return m_permutedIndices[index];
99 return m_permutedIndices.size();
102 shared_ptr<const Epetra_CrsMatrix> permutationMatrix()
const;
105 const std::vector<unsigned int> m_permutedIndices;
size_t size() const
Return length of the vector of indices.
Definition: index_permutation.hpp:98
Permutation of indices.
Definition: index_permutation.hpp:39
unsigned int permuted(unsigned int index) const
Permute index.
Definition: index_permutation.hpp:93
void unpermuteVector(const arma::Col< ValueType > &permuted, arma::Col< ValueType > &original) const
Convert a vector from permuted to original ordering.
Definition: index_permutation.hpp:83
void permuteVector(const arma::Col< ValueType > &original, arma::Col< ValueType > &permuted) const
Convert a vector from original to permuted ordering.
Definition: index_permutation.hpp:72