10#include "../myAssert.h"
12#include "../sgrid/sparseGrid.h"
13#include "../indices/index.h"
59 ShiftExpr(
const A& a,
int d, Direction s):a_(a),d_(d), s_(s){
62 ShiftExpr(
const A& a,
int d, Direction s,
int level):a_(a),d_(d), s_(s), level_(level){
67 inline double getValue(
int i,
const IndexDimension& K)
const;
70 ExpressionDescription getDescription()
const {
return ExpressionDescription(
true); }
89 dataInteger* secondTable = sparseGrid->getSecondTable();
90 dataInteger* primeTable = sparseGrid->getPrimeTable();
92 if(secondTable[i]!=0) {
104 if (sparseGrid->
occupied(kk, I.nextLeft(d_)))
108 if (sparseGrid->
occupied(kk, I.nextRight(d_)))
109 II = I.nextRight(d_);
113 unsigned long indArray = sparseGrid->
hash(II);
114 unsigned long k = primeTable[indArray];
118 return a_.getValue(i,K);
124 return a_.getValue(k,K);
126 unsigned long iNext = secondTable[k];
130 return a_.getValue(k,K) ;
133 iNext = secondTable[k];
143 dataInteger* secondTable = sparseGrid->getSecondTable();
144 dataInteger* primeTable = sparseGrid->getPrimeTable();
146 int maxdepth = sparseGrid->getMaxDepth(d_);
152 if(secondTable[i]!=0) {
156 if(I.isNotAtBoundary() ==
false) {
163 II = I.nextLeft(d_,maxdepth);
165 II = I.nextRight(d_,maxdepth);
168 unsigned long indArray = sparseGrid->
hash(II);
169 unsigned long k = primeTable[indArray];
172 maxdepth= maxdepth-1;
174 return a_.getValue(i,K);
180 return a_.getValue(k,K);
182 unsigned long iNext = secondTable[k];
186 return a_.getValue(k,K) ;
189 iNext = secondTable[k];
242 ShiftOperator(
int d, Direction s,
int level):d_(d),s_(s), level_(level){hier =
false;}
266 North, NorthEast, East, SouthEast, South, SouthWest, West, NorthWest, Center
271class ShiftDimensionExpr :
public ExprSparseG<ShiftDimensionExpr<A> >{
282 ShiftDimensionExpr(
const A& a, Compass s,
bool h):a_(a), s_(s),hier(h){}
283 ShiftDimensionExpr(
const A& a, Compass s,
int l,
bool h):a_(a),s_(s),level(l), hier(h){}
286 inline double getValue(
int i,
const IndexDimension& K)
const;
289 ExpressionDescription getDescription()
const {
return ExpressionDescription(
true); }
294template<
typename A>
double ShiftDimensionExpr<A>::getValue(
int i,
const IndexDimension& K)
const
305 dataInteger* secondTable = sparseGrid->getSecondTable();
306 dataInteger* primeTable = sparseGrid->getPrimeTable();
308 if(secondTable[i]!=0) {
309 IndexDimension I = K;
314 if (s_ == North)II = I.nextLeft(1);
315 if (s_== NorthEast) II = (I.nextLeft(1)).nextRight(0);
316 if (s_==East) II = I.nextRight(0);
317 if (s_ == SouthEast) II = (I.nextRight(0)).nextRight(1);
318 if (s_ == South) II = I.nextRight(1);
319 if (s_ == SouthWest) II = (I.nextRight(1)).nextLeft(0);
320 if (s_ == West) II = I.nextLeft(0);
321 if (s_ == NorthWest) II= (I.nextLeft(0)).nextLeft(1);
324 unsigned long indArray = sparseGrid->
hash(II);
325 unsigned long k = primeTable[indArray];
335 return a_.getValue(k,II);
339 unsigned long iNext = secondTable[k];
343 return a_.getValue(k,II) ;
346 iNext = secondTable[k];
357 dataInteger* secondTable = sparseGrid->getSecondTable();
358 dataInteger* primeTable = sparseGrid->getPrimeTable();
364 int maxdepth = level;
366 if(secondTable[i]!=0) {
377 if (s_ == North)II = I.nextLeft(1,maxdepth);
378 if (s_== NorthEast) II = (I.nextLeft(1,maxdepth)).nextRight(0,maxdepth);
379 if (s_==East) II = I.nextRight(0,maxdepth);
380 if (s_ == SouthEast) II = (I.nextRight(0,maxdepth)).nextRight(1,maxdepth);
381 if (s_ == South) II = I.nextRight(1,maxdepth);
382 if (s_ == SouthWest) II = (I.nextRight(1,maxdepth)).nextLeft(0, maxdepth);
385 II = I.nextLeft(0, maxdepth);
388 if (s_ == NorthWest) II= (I.nextLeft(0, maxdepth)).nextLeft(1, maxdepth);
391 unsigned long indArray = sparseGrid->
hash(II);
392 unsigned long k = primeTable[indArray];
407 return a_.getValue(k,II);
409 unsigned long iNext = secondTable[k];
413 return a_.getValue(k,II) ;
416 iNext = secondTable[k];
Definition sparseGrid.h:86
IndexDimension getIndexOfTable(unsigned long i)
Definition sparseGrid.h:566
unsigned long hash(IndexDimension index)
Definition sparseGrid.h:395
bool occupied(unsigned long &indexOfData, IndexDimension I)
Definition sparseGrid.h:465
Definition sparseGrid.h:277
ShiftOperator(int d, Direction s)
Definition shift.h:233
ShiftOperator(int d, Direction s, int level)
Definition shift.h:242