31 for (
index_t i = 0; i < idx.size(); ++i)
33 result += stride * idx[i];
49 template <
short_t d,
typename T>
58 for (
unsigned i = 0; i < d; ++i)
60 oldSize[i] =
static_cast<unsigned>(B[i].innerSize());
61 newSize[i] =
static_cast<unsigned>(B[i].outerSize());
64 std::vector<InnerIt> it(d);
71 for (
unsigned i = 0; i < d; ++i)
72 it[i] = B[i].begin(v[i]);
79 for (
unsigned i = 0; i < d; ++i)
81 contrib *= it[i].value();
82 v_old[i] = it[i].index();
85 const index_t oldIdx = fromTensorIndex<d>(v_old, oldSize);
86 entries.add( newIdx, oldIdx, contrib );
90 for (
unsigned i = 0; i < d; ++i)
100 it[i] = B[i].begin(v[i]);
106 GISMO_ASSERT( newIdx == (
index_t) newSize.prod(),
"Iteration did not complete as expected." );
108 transfer.resize( newSize.prod(), oldSize.prod() );
109 transfer.setFrom( entries );
110 transfer.makeCompressed();
114 template<
typename VectIn,
typename VectOut>
inline
117 strides.derived().resize(sz.size());
119 for (
index_t i=1; i != sz.size(); ++i )
120 strides[i] = strides[i-1] * sz[i-1];
128 template <
typename T,
int d>
134 "Input error, sizes do not match: "<<sz.prod()<<
"!="<< coefs.rows() );
136 "Invalid directions: "<< k1 <<
", "<< k2 );
148 gsGridIterator<index_t,CUBE,d> it(sz);
150 std::swap( sz[k1], sz[k2] );
153 std::swap(perstr[k1], perstr[k2] );
157 for(
index_t r=0; it; ++it, ++r)
158 tmp.row(perstr.dot(*it)) = coefs.row(r);
168 template <
typename T,
int d>
174 "Input error, sizes do not match: "<<sz.prod()<<
"!="<< coefs.rows() );
176 "Error in the permutation: "<< perm.transpose());
182 gsGridIterator<index_t,CUBE,d> it(sz);
192 for(
index_t r=0; it; ++it, ++r)
193 tmp.row(perstr.dot(*it)) = coefs.row(r);
200 template <
typename T,
int d>
206 "Input error, sizes do not match: "<<sz.prod()<<
"!="<< coefs.rows() );
210 gsGridIterator<index_t,CUBE,d> it(perstr);
212 const index_t cc = sz[dir] - 1;
216 const index_t i1 = perstr.dot(*it);
217 const index_t i2 = i1 + (cc - 2 * it->at(dir)) * perstr[dir];
218 coefs.row( i1 ).swap( coefs.row( i2 ) );
Class that provides a container for triplets (i,j,value) to be filled in a sparse matrix...
Definition: gsSparseMatrix.h:33
void swapTensorDirection(int k1, int k2, gsVector< index_t, d > &sz, gsMatrix< T > &coefs)
Definition: gsTensorTools.h:129
void flipTensorVector(const int dir, const gsVector< index_t, d > &sz, gsMatrix< T > &coefs)
Flips tensor directions in place.
Definition: gsTensorTools.h:201
#define index_t
Definition: gsConfig.h:32
void tensorStrides(const VectIn &sz, VectOut &strides)
Helper to compute the strides of a d-tensor.
Definition: gsTensorTools.h:115
Provides combinatorial unitilies.
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
int fromTensorIndex(const gsVector< unsigned, d > &idx, const gsVector< unsigned, d > &sz)
Helper function to compute a lexicographically numbered index from tensor indices.
Definition: gsTensorTools.h:27
bool nextLexicographic(Vec &cur, const Vec &size)
Iterates through a tensor lattice with the given size. Updates cur and returns true if another entry ...
Definition: gsCombinatorics.h:196
void tensorCombineTransferMatrices(gsSparseMatrix< T, RowMajor > B[d], gsSparseMatrix< T, RowMajor > &transfer)
Combine component-wise transfer matrices into a transfer matrix for the tensor product basis...
Definition: gsTensorTools.h:50
void permuteTensorVector(const gsVector< index_t, d > &perm, gsVector< index_t, d > &sz, gsMatrix< T > &coefs)
Definition: gsTensorTools.h:169
This is the main header file that collects wrappers of Eigen for linear algebra.
Provides iteration over integer or numeric points in a (hyper-)cube.