14#include <gsMSplines/gsWeightMapperUtils.h>
23 const bool matSupplied = (permMatrix != NULL);
24 const index_t size=mapper.getNrOfTargets();
25 const index_t start=size-perm.size();
28 std::vector<index_t> reordered (size,flag);
29 for (
size_t i=0; i<perm.size(); ++i)
31 reordered[perm[i]]=start+i;
34 for (
size_t i=0; i<reordered.size(); ++i)
36 if(reordered[i]==flag)
42 gsAsVector<index_t> permVec(reordered);
46 mapper*=m_perm.inverse();
54void copyToBlock (
const gsWeightMapper<T> &src,
typename gsWeightMapper<T>::LToGMatrix &dst,
index_t rowShift,
index_t colShift)
57 for (
index_t r=0; r<src.getNrOfSources(); ++r)
58 for (
typename gsWeightMapper<T>::Iterator entry=src.fastSourceToTarget(r); entry; ++entry)
59 dst.insert(r+rowShift,entry.index()+colShift)=entry.weight();
64gsWeightMapper<T>*
combineMappers (
const std::vector<gsWeightMapper<T>*> &mappers, std::vector<index_t> &shifts,
bool needShifting)
66 gsWeightMapper<T>* result=
new gsWeightMapper<T>();
72void combineMappers (
const std::vector<gsWeightMapper<T>*> &mappers,
bool needShifting, std::vector<index_t> &shifts, gsWeightMapper<T>& result)
74 typename gsWeightMapper<T>::LToGMatrix &resultMatrix=result.asMatrix();
77 shifts.resize(mappers.size()+1);
84 for (
size_t m=0;m<mappers.size();++m)
86 totShift+=mappers[m]->getNrOfSources();
89 totTarSize+=mappers[m]->getNrOfTargets();
91 totTarSize=std::max(totTarSize,mappers[m]->getNrOfTargets());
92 totNNZ+=mappers[m]->asMatrix().nonZeros();
95 resultMatrix.resize(shifts.back(),totTarSize);
96 resultMatrix.reserve(totNNZ);
99 for (
size_t m=0;m<mappers.size();++m)
101 copyToBlock( *mappers[m], resultMatrix, shifts[m], startingGlobal);
103 startingGlobal+= mappers[m]->getNrOfTargets();
#define index_t
Definition gsConfig.h:32
The G+Smo namespace, containing all definitions for the library.
gsEigen::PermutationMatrix< Dynamic, Dynamic, index_t > gsPermutationMatrix
reorderMapperTarget permutes the target indices of mapper according to permutation....
Definition gsWeightMapperUtils.h:36
gsWeightMapper< T > * combineMappers(const std::vector< gsWeightMapper< T > * > &mappers, std::vector< index_t > &shifts, bool needShifting=true)
combineMappers Given a set of mappers it creates a new mapper that combines all. It can be used to co...
Definition gsWeightMapperUtils.hpp:64