OpendTect  6.3
arrayndalgo.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*@+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Kristofer Tingdahl
8  Date: 07-10-1999
9 ________________________________________________________________________
10 
11 
12 @$*/
13 
14 #include "algomod.h"
15 #include "arrayndimpl.h"
16 #include "coord.h"
17 #include "enums.h"
18 #include "mathfunc.h"
19 #include "periodicvalue.h"
20 #include "posinfo.h"
21 #include "trckeyzsampling.h"
22 #include "uistrings.h"
23 #include "valseries.h"
24 
25 
26 namespace ArrayMath
27 {
28 
30 {
31 public:
32  ArrayOperExecSetup(bool doadd=true,bool dosqinp=false,
33  bool dosqout=false,bool doabs=false,
34  bool donormalizesum=false,
35  bool dosqrtsum=false)
36  : doadd_(doadd)
37  , dosqinp_(dosqinp)
38  , dosqout_(dosqout)
39  , doabs_(doabs)
40  , donormalizesum_(donormalizesum)
41  , dosqrtsum_(dosqrtsum)
42  {}
43 
44  bool doadd_;
45  bool dosqinp_;
46  bool dosqout_;
47  bool doabs_;
49  bool dosqrtsum_;
50 };
51 
52 
62 template <class ArrType,class SumType,class OperType,class RetType>
65 public:
66  CumArrOperExec( const ArrayND<ArrType>& xvals, bool noudf,
67  const ArrayOperExecSetup& setup )
68  : xarr_(xvals)
69  , yarr_(0)
70  , sz_(xvals.info().getTotalSz())
71  , noudf_(noudf)
72  , xshift_(mUdf(SumType))
73  , yshift_(mUdf(SumType))
74  , xfact_(mUdf(OperType))
75  , yfact_(mUdf(OperType))
76  , cumsum_(mUdf(SumType))
77  , count_(0)
78  , setup_(setup)
79  {}
80 
82  uiString message() const { return tr("Cumulative sum executor");}
83 
84  void setYVals( const ArrayND<ArrType>& yvals ) { yarr_ = &yvals; }
87  void setShift( SumType shift, bool forx=true )
88  {
89  if ( forx )
90  xshift_ = shift;
91  else
92  yshift_ = shift;
93  }
96  void setScaler( OperType scaler, bool forx=true )
97  {
98  if ( forx )
99  xfact_ = scaler;
100  else
101  yfact_ = scaler;
102  }
103 
104  RetType getSum() const { return mCast(RetType,cumsum_); }
105 
106 protected:
107 
108  od_int64 nrIterations() const { return sz_; }
109 
110 private:
111 
112  bool doPrepare( int nrthreads )
113  {
114  if ( yarr_ && yarr_->info().getTotalSz() != sz_ )
115  return false;
116 
117  cumsum_ = (SumType)0;
118  count_ = 0;
119 
120  return true;
121  }
122 
123  bool doWork( od_int64 start, od_int64 stop, int threadidx )
124  {
125  SumType sumval = 0, comp = 0;
126  od_uint64 count = 0;
127  const ArrType* xvals = xarr_.getData();
128  const ArrType* yvals = yarr_ ? yarr_->getData() : 0;
129  const ValueSeries<ArrType>* xstor = xarr_.getStorage();
130  const ValueSeries<ArrType>* ystor = yarr_ ? yarr_->getStorage() : 0;
131  ArrayNDIter* xiter = xvals || xstor
132  ? 0 : new ArrayNDIter( xarr_.info() );
133  ArrayNDIter* yiter = ( yarr_ && ( yvals || ystor ) ) || !yarr_
134  ? 0 : new ArrayNDIter( yarr_->info() );
135  if ( xiter ) xiter->setGlobalPos( start );
136  if ( yiter ) yiter->setGlobalPos( start );
137  const bool doshiftxvals = !mIsUdf(xshift_);
138  const bool doscalexvals = !mIsUdf(xfact_);
139  const bool hasyvals = yarr_;
140  const bool doshiftyvals = !mIsUdf(yshift_);
141  const bool doscaleyvals = !mIsUdf(yfact_);
142  for ( od_int64 idx=start; idx<=stop; idx++ )
143  {
144  SumType xvalue = xvals ? xvals[idx]
145  : xstor ? xstor->value(idx)
146  : xarr_.getND( xiter->getPos() );
147  if ( !noudf_ && mIsUdf(xvalue) )
148  {
149  if ( xiter ) xiter->next();
150  if ( yiter ) yiter->next();
151  continue;
152  }
153 
154  if ( setup_.dosqinp_ ) xvalue *= xvalue;
155  if ( doshiftxvals ) xvalue += xshift_;
156  if ( doscalexvals ) xvalue *= xfact_;
157  if ( hasyvals )
158  {
159  SumType yvalue = yvals ? yvals[idx]
160  : ystor ? ystor->value(idx)
161  : yarr_->getND( yiter->getPos());
162  if ( !noudf_ && mIsUdf(yvalue) )
163  {
164  if ( xiter ) xiter->next();
165  if ( yiter ) yiter->next();
166  continue;
167  }
168 
169  if ( setup_.dosqinp_ ) yvalue *= yvalue;
170  if ( doshiftyvals ) yvalue += yshift_;
171  if ( doscaleyvals ) yvalue *= yfact_;
172  if ( setup_.doadd_ )
173  xvalue += yvalue;
174  else
175  xvalue *= yvalue;
176  }
177 
178  if ( setup_.doabs_ )
179  xvalue = Math::Abs( xvalue );
180  else if ( setup_.dosqout_ )
181  xvalue *= xvalue;
182 
183  xvalue -= comp;
184  const SumType t = sumval + xvalue;
185  comp = ( t - sumval ) - xvalue;
186  sumval = t;
187  count++;
188  if ( xiter ) xiter->next();
189  if ( yiter ) yiter->next();
190  }
191 
192  delete xiter; delete yiter;
193  if ( count < 1 )
194  return true;
195 
196  Threads::Locker locker( writelock_ );
197  cumsum_ += sumval;
198  count_ += count;
199 
200  return true;
201  }
202 
203  bool doFinish( bool success )
204  {
205  if ( !success || count_ == 0 )
206  {
207  cumsum_ = mUdf(SumType);
208  return false;
209  }
210 
211  if ( setup_.donormalizesum_ )
212  cumsum_ /= mCast(OperType,count_);
213 
214  if ( setup_.dosqrtsum_ )
216 
217  return true;
218  }
219 
220 private:
221 
224  bool noudf_;
225 
229  SumType xshift_;
230  SumType yshift_;
231  OperType xfact_;
232  OperType yfact_;
233  SumType cumsum_;
235 };
236 
237 
238 
244 template <class ArrType,class SumType,class OperType>
245 class ArrOperExec : public ParallelTask
247 public:
249  const ArrayND<ArrType>* yvals, bool noudf,
250  const ArrayOperExecSetup& setup,
251  ArrayND<ArrType>& outvals )
252  : xarr_(xvals)
253  , yarr_(yvals)
254  , outarr_(outvals)
255  , sz_(xvals.info().getTotalSz())
256  , noudf_(noudf)
257  , xfact_(mUdf(OperType))
258  , yfact_(mUdf(OperType))
259  , shift_(mUdf(OperType))
260  , setup_(setup)
261  {}
262 
264  uiString message() const { return tr("Cumulative sum executor");}
265 
266  void setYVals( const ArrayND<ArrType>& yvals ) { yarr_ = &yvals; }
267  void setScaler( OperType scaler, bool forx=true )
268  {
269  if ( forx )
270  xfact_ = scaler;
271  else
272  yfact_ = scaler;
273  }
274  void setShift( SumType shift ) { shift_ = shift; }
275 
276 protected:
277 
278  od_int64 nrIterations() const { return sz_; }
279 
280 private:
281 
282  bool doPrepare( int )
283  {
284  if ( outarr_.info().getTotalSz() != sz_ )
285  return false;
286 
287  if ( yarr_ && yarr_->info().getTotalSz() != sz_ )
288  return false;
289 
290  return true;
291  }
292 
293  bool doWork( od_int64 start, od_int64 stop, int )
294  {
295  const ArrType* xvals = xarr_.getData();
296  const ArrType* yvals = yarr_ ? yarr_->getData() : 0;
297  ArrType* outvals = outarr_.getData();
298  const ValueSeries<ArrType>* xstor = xarr_.getStorage();
299  const ValueSeries<ArrType>* ystor = yarr_ ? yarr_->getStorage() : 0;
300  ValueSeries<ArrType>* outstor = outarr_.getStorage();
301  ArrayNDIter* xiter = xvals || xstor
302  ? 0 : new ArrayNDIter( xarr_.info() );
303  ArrayNDIter* yiter = ( yarr_ && ( yvals || ystor ) ) || !yarr_
304  ? 0 : new ArrayNDIter( yarr_->info() );
305  ArrayNDIter* outiter = outvals || outstor
306  ? 0 : new ArrayNDIter( outarr_.info() );
307  if ( xiter ) xiter->setGlobalPos( start );
308  if ( yiter ) yiter->setGlobalPos( start );
309  if ( outiter ) outiter->setGlobalPos( start );
310  const bool doscalexvals = !mIsUdf(xfact_);
311  const bool hasyvals = yarr_;
312  const bool doscaleyvals = !mIsUdf(yfact_);
313  const bool doshiftoutvals = !mIsUdf(shift_);
314  for ( od_int64 idx=start; idx<=stop; idx++ )
315  {
316  SumType xvalue = xvals ? xvals[idx]
317  : xstor ? xstor->value(idx)
318  : xarr_.getND( xiter->getPos() );
319  if ( !noudf_ && mIsUdf(xvalue) )
320  {
321  if ( xiter ) xiter->next();
322  if ( yiter ) yiter->next();
323  if ( outiter ) outiter->next();
324  continue;
325  }
326 
327  if ( doscalexvals ) xvalue *= xfact_;
328  if ( hasyvals )
329  {
330  SumType yvalue = yvals ? yvals[idx]
331  : ystor ? ystor->value(idx)
332  : yarr_->getND( yiter->getPos());
333  if ( !noudf_ && mIsUdf(yvalue) )
334  {
335  if ( xiter ) xiter->next();
336  if ( yiter ) yiter->next();
337  if ( outiter ) outiter->next();
338  continue;
339  }
340 
341  if ( doscaleyvals ) yvalue *= yfact_;
342  if ( setup_.doadd_ )
343  xvalue += yvalue;
344  else
345  xvalue *= yvalue;
346  }
347 
348  if ( doshiftoutvals )
349  xvalue += shift_;
350 
351  const ArrType res = mCast(ArrType,xvalue);
352  if ( outvals )
353  outvals[idx] = res;
354  else if ( outstor )
355  outstor->setValue( idx, res );
356  else
357  outarr_.setND( outiter->getPos(), res );
358 
359  if ( xiter ) xiter->next();
360  if ( yiter ) yiter->next();
361  if ( outiter ) outiter->next();
362  }
363 
364  delete xiter; delete yiter; delete outiter;
365 
366  return true;
367  }
368 
369 private:
370 
373  bool noudf_;
374 
378  OperType xfact_;
379  OperType yfact_;
380  SumType shift_;
381 };
382 
383 
384 
385 
386 
390 template <class ArrType,class SumType,class OperType,class RetType>
391 inline RetType getSum( const ArrayND<ArrType>& in, bool noudf, bool parallel )
392 {
393  ArrayOperExecSetup setup;
394  CumArrOperExec<ArrType,SumType,OperType,RetType> sumexec( in, noudf, setup);
395  if ( !sumexec.executeParallel(parallel) )
396  return mUdf(RetType);
397 
398  return sumexec.getSum();
399 }
400 
401 
404 template <class ArrType,class SumType,class OperType,class RetType>
405 inline RetType getAverage( const ArrayND<ArrType>& in, bool noudf,
406  bool parallel )
407 {
408  ArrayOperExecSetup setup;
409  setup.donormalizesum_ = true;
410  CumArrOperExec<ArrType,SumType,OperType,RetType> avgexec( in, noudf, setup);
411  if ( !avgexec.executeParallel(parallel) )
412  return mUdf(ArrType);
413 
414  return avgexec.getSum();
415 }
416 
417 
420 template <class ArrType,class SumType,class OperType>
421 inline void getScaled( const ArrayND<ArrType>& in, ArrayND<ArrType>* out_,
422  OperType fact, SumType shift, bool noudf, bool parallel )
423 {
424  ArrayND<ArrType>& out = out_ ? *out_ : const_cast<ArrayND<ArrType>&>( in );
425  ArrayOperExecSetup setup;
426  ArrOperExec<ArrType,SumType,OperType> scalinngexec( in, 0, noudf, setup,
427  out );
428  scalinngexec.setScaler( fact );
429  scalinngexec.setShift( shift );
430  scalinngexec.executeParallel( parallel );
431 }
432 
433 
436 template <class ArrType,class SumType,class OperType>
437 inline void getSum( const ArrayND<ArrType>& in1, const ArrayND<ArrType>& in2,
438  ArrayND<ArrType>& out, bool noudf, bool parallel )
439 {
440  ArrayOperExecSetup setup;
441  ArrOperExec<ArrType,SumType,OperType> sumexec( in1, &in2, noudf, setup,
442  out );
443  sumexec.executeParallel( parallel );
444 }
445 
446 
449 template <class ArrType,class SumType,class OperType>
450 inline void getSum( const ArrayND<ArrType>& in1, const ArrayND<ArrType>& in2,
451  ArrayND<ArrType>& out, OperType fact1, OperType fact2,
452  bool noudf, bool parallel )
453 {
454  ArrayOperExecSetup setup;
455  ArrOperExec<ArrType,SumType,OperType> sumexec( in1, &in2, noudf, setup,
456  out );
457  sumexec.setScaler( fact1 );
458  sumexec.setScaler( fact2, false );
459  sumexec.executeParallel( parallel );
460 }
461 
462 
465 template <class ArrType,class SumType,class OperType>
466 inline void getProduct( const ArrayND<ArrType>& in1,
467  const ArrayND<ArrType>& in2, ArrayND<ArrType>& out,
468  bool noudf, bool parallel )
469 {
470  ArrayOperExecSetup setup;
471  setup.doadd_ = false;
472  ArrOperExec<ArrType,SumType,OperType> prodexec( in1, &in2, noudf, setup,
473  out );
474  prodexec.executeParallel( parallel );
475 }
476 
477 
480 template <class ArrType,class SumType,class OperType,class RetType>
481 inline RetType getSumProduct( const ArrayND<ArrType>& in1,
482  const ArrayND<ArrType>& in2,
483  bool noudf, bool parallel )
484 {
485  ArrayOperExecSetup setup;
486  setup.doadd_ = false;
487  CumArrOperExec<ArrType,SumType,OperType,RetType> sumprodexec( in1, noudf,
488  setup );
489  sumprodexec.setYVals( in2 );
490  if ( !sumprodexec.executeParallel(parallel) )
491  return mUdf(RetType);
492 
493  return sumprodexec.getSum();
494 }
495 
496 
499 template <class ArrType,class SumType,class OperType,class RetType>
500 inline RetType getSumSq( const ArrayND<ArrType>& in, bool noudf, bool parallel )
501 {
502  ArrayOperExecSetup setup;
503  setup.dosqinp_ = true;
505  setup );
506  if ( !sumsqexec.executeParallel(parallel) )
507  return mUdf(RetType);
508 
509  return sumsqexec.getSum();
510 }
511 
512 
515 template <class ArrType,class SumType,class OperType,class RetType>
516 inline RetType getNorm2( const ArrayND<ArrType>& in, bool noudf, bool parallel )
517 {
518  ArrayOperExecSetup setup;
519  setup.dosqinp_ = true;
520  setup.dosqrtsum_ = true;
522  setup );
523  if ( !norm2exec.executeParallel(parallel) )
524  return mUdf(RetType);
525 
526  return norm2exec.getSum();
527 }
528 
529 
532 template <class ArrType,class SumType,class OperType,class RetType>
533 inline RetType getRMS( const ArrayND<ArrType>& in, bool noudf, bool parallel )
534 {
535  ArrayOperExecSetup setup;
536  setup.dosqinp_ = true;
537  setup.donormalizesum_ = true;
538  setup.dosqrtsum_ = true;
539  CumArrOperExec<ArrType,SumType,OperType,RetType> rmsexec( in, noudf, setup);
540  if ( !rmsexec.executeParallel(parallel) )
541  return mUdf(RetType);
542 
543  return rmsexec.getSum();
544 }
545 
546 
549 template <class ArrType,class SumType,class OperType,class RetType>
550 inline RetType getResidual( const ArrayND<ArrType>& in1,
551  const ArrayND<ArrType>& in2, bool noudf,
552  bool parallel )
553 {
554  ArrayOperExecSetup setup;
555  setup.doabs_ = true;
556  setup.donormalizesum_ = true;
557  CumArrOperExec<ArrType,SumType,OperType,RetType> residualexec( in1, noudf,
558  setup );
559  residualexec.setYVals( in2 );
560  residualexec.setScaler( (OperType)-1, false );
561  if ( !residualexec.executeParallel(parallel) )
562  return mUdf(RetType);
563 
564  return residualexec.getSum();
565 }
566 
567 
570 template <class ArrType,class SumType,class OperType,class RetType>
571 inline RetType getSumXMY2( const ArrayND<ArrType>& in1,
572  const ArrayND<ArrType>& in2, bool noudf,
573  bool parallel )
574 {
575  ArrayOperExecSetup setup;
576  setup.dosqout_ = true;
577  CumArrOperExec<ArrType,SumType,OperType,RetType> sumxmy2exec( in1, noudf,
578  setup );
579  sumxmy2exec.setYVals( in2 );
580  sumxmy2exec.setScaler( (SumType)-1, false );
581  if ( !sumxmy2exec.executeParallel(parallel) )
582  return mUdf(RetType);
583 
584  return sumxmy2exec.getSum();
585 }
586 
587 
590 template <class ArrType,class SumType,class OperType,class RetType>
591 inline RetType getSumX2PY2( const ArrayND<ArrType>& in1,
592  const ArrayND<ArrType>& in2, bool noudf,
593  bool parallel )
594 {
595  ArrayOperExecSetup setup;
596  setup.dosqinp_ = true;
597  CumArrOperExec<ArrType,SumType,OperType,RetType> sumx2py2exec( in1, noudf,
598  setup );
599  sumx2py2exec.setYVals( in2 );
600  if ( !sumx2py2exec.executeParallel(parallel) )
601  return mUdf(RetType);
602 
603  return sumx2py2exec.getSum();
604 }
605 
606 
609 template <class ArrType,class SumType,class OperType,class RetType>
610 inline RetType getSumX2MY2( const ArrayND<ArrType>& in1,
611  const ArrayND<ArrType>& in2, bool noudf,
612  bool parallel )
613 {
614  ArrayOperExecSetup setup;
615  setup.dosqinp_ = true;
616  CumArrOperExec<ArrType,SumType,OperType,RetType> sumx2my2exec( in1, noudf,
617  setup );
618  sumx2my2exec.setYVals( in2 );
619  sumx2my2exec.setScaler( (SumType)-1, false );
620  if ( !sumx2my2exec.executeParallel(parallel) )
621  return mUdf(RetType);
622 
623  return sumx2my2exec.getSum();
624 }
625 
626 
629 template <class ArrType,class SumType,class OperType>
630 inline bool removeBias( const ArrayND<ArrType>& in, ArrayND<ArrType>& out,
631  bool noudf, bool parallel )
632 {
633  const SumType averagevalue =
634  getAverage<ArrType,SumType,OperType,SumType>( in, noudf, parallel );
635  if ( mIsUdf(averagevalue) )
636  return false;
637 
638  getScaled<ArrType,SumType,OperType>( in, &out, (OperType)1, -averagevalue,
639  noudf, parallel );
640  return true;
641 }
642 
643 
646 template <class ArrType,class SumType,class OperType>
647 inline bool removeBias( ArrayND<ArrType>& inout, bool noudf, bool parallel )
648 {
649  const ArrayND<ArrType>& inconst =
650  const_cast<const ArrayND<ArrType>&>( inout );
651  return removeBias<ArrType,SumType,OperType>( inconst, inout, noudf,
652  parallel );
653 }
654 
655 
656 #define mFillTrendXArray() \
657 { \
658  ArrType* trendxvals = trendx.getData(); \
659  ValueSeries<ArrType>* trendstor = trendx.getStorage(); \
660  if ( trendxvals ) \
661  { \
662  for ( od_uint64 idx=0; idx<sz; idx++ ) \
663  trendxvals[idx] = mCast(ArrType,idx); \
664  } \
665  else if ( trendstor ) \
666  { \
667  for ( od_uint64 idx=0; idx<sz; idx++ ) \
668  trendstor->setValue(idx,mCast(ArrType,idx)); \
669  } \
670  else \
671  { \
672  ArrayNDIter iter( trendx.info() ); \
673  od_uint64 idx = 0; \
674  do \
675  { \
676  trendx.setND( iter.getPos(), mCast(ArrType,idx) ); \
677  idx++; \
678  } while ( iter.next() ); \
679  } \
680 }
681 
684 template <class ArrType,class OperType>
685 inline bool getInterceptGradient( const ArrayND<ArrType>& iny,
686  const ArrayND<ArrType>* inx_,
687  OperType& intercept, OperType& gradient,
688  bool parallel )
689 {
690  const OperType avgyvals = getAverage<ArrType,OperType,OperType,OperType>(
691  iny, false, parallel );
692  if ( mIsUdf(avgyvals) )
693  return false;
694 
695  const bool hasxvals = inx_;
696  const ArrayND<ArrType>* inx = hasxvals ? inx_ : 0;
697  if ( !hasxvals )
698  {
699  const od_uint64 sz = iny.info().getTotalSz();
700  Array1DImpl<ArrType>* inxtmp = new Array1DImpl<ArrType>( mCast(int,sz));
701  if ( !inxtmp->isOK() )
702  { delete inxtmp; return false; }
703 
704  Array1DImpl<ArrType>& trendx = *inxtmp;
706 
707  inx = inxtmp;
708  }
709 
710  const OperType avgxvals = getAverage<ArrType,OperType,OperType,OperType>(
711  *inx, false, parallel );
712  if ( mIsUdf(avgxvals) )
713  { if ( !hasxvals) delete inx; return false; }
714 
715  ArrayOperExecSetup numsetup, denomsetup;
716  numsetup.doadd_ = false;
717  denomsetup.dosqout_ = true;
719  numsetup );
720  numgradexec.setYVals( iny );
721  numgradexec.setShift( -avgxvals );
722  numgradexec.setShift( -avgyvals, false );
724  denomsetup);
725  denomgradexec.setShift( -avgxvals );
726  if ( !numgradexec.executeParallel(parallel) ||
727  !denomgradexec.executeParallel(parallel) )
728  { if ( !hasxvals) delete inx; return false; }
729 
730  gradient = numgradexec.getSum() / denomgradexec.getSum();
731  intercept = avgyvals - gradient * avgxvals;
732 
733  if ( !hasxvals)
734  delete inx;
735 
736  return true;
737 }
738 
739 
742 template <class ArrType,class OperType>
743 inline bool removeTrend( const ArrayND<ArrType>& in, ArrayND<ArrType>& out )
744 {
745  const od_uint64 sz = in.info().getTotalSz();
746  Array1DImpl<ArrType> trendx( mCast(int,sz) );
747  if ( !trendx.isOK() )
748  return false;
749 
751  OperType intercept=0, gradient=0;
752  if ( !getInterceptGradient<ArrType,OperType>(in,&trendx,intercept,gradient,
753  true) )
754  {
755  return false;
756  }
757 
758  getScaled<ArrType,OperType,OperType>( trendx, 0, gradient, intercept, true,
759  true );
760  getSum<ArrType,OperType,OperType>( in, trendx, out, (OperType)1,
761  (OperType)-1, false, true );
762 
763  return true;
764 }
765 
766 
769 template <class ArrType,class OperType>
770 inline bool removeTrend( ArrayND<ArrType>& inout )
771 {
772  const ArrayND<ArrType>& inconst =
773  const_cast<const ArrayND<ArrType>&>( inout );
774  return removeTrend<ArrType,OperType>( inconst, inout );
775 }
776 
777 } // namespace ArrayMath
778 
779 
782 template <class fT>
783 inline bool hasUndefs( const ArrayND<fT>& in )
784 {
785  const fT* vals = in.getData();
786  const od_uint64 sz = in.info().getTotalSz();
787  if ( vals )
788  {
789  for ( od_uint64 idx=0; idx<sz; idx++ )
790  {
791  if ( mIsUdf(vals[idx]) )
792  return true;
793  }
794 
795  return false;
796  }
797 
798  const ValueSeries<fT>* stor = in.getStorage();
799  if ( stor )
800  {
801  for ( od_uint64 idx=0; idx<sz; idx++ )
802  {
803  if ( mIsUdf(stor->value(idx)) )
804  return true;
805  }
806 
807  return false;
808  }
809 
810  ArrayNDIter iter( in.info() );
811  do
812  {
813  if ( mIsUdf(in.getND(iter.getPos())) )
814  return true;
815 
816  } while( iter.next() );
817 
818  return false;
819 }
820 
821 
832 template <class fT>
833 inline bool interpUdf( Array1D<fT>& in,
836 {
837  if ( !hasUndefs(in) )
838  return false;
839 
840  BendPointBasedMathFunction<fT,fT> data( ipoltyp );
841  const int sz = in.info().getSize(0);
842  for ( int idx=0; idx<sz; idx++ )
843  {
844  const fT val = in.get( idx );
845  if ( !mIsUdf(val) )
846  data.add( mCast(fT,idx), val );
847  }
848 
849  for ( int idx=0; idx<sz; idx++ )
850  {
851  const fT val = in.get( idx );
852  if ( mIsUdf(val) )
853  in.set( idx, data.getValue( mCast(fT,idx) ) );
854  }
855 
856  return true;
857 }
858 
859 
871 {
872 public:
873  enum WindowType { Box, Hamming, Hanning, Blackman, Bartlett,
874  CosTaper5, CosTaper10, CosTaper20 };
876 
877  ArrayNDWindow(const ArrayNDInfo&,bool rectangular,
878  WindowType=Hamming);
879  ArrayNDWindow(const ArrayNDInfo&,bool rectangular,
880  const char* winnm,
881  float paramval=mUdf(float));
882  ~ArrayNDWindow();
883 
884  bool isOK() const { return window_; }
885 
886  float getParamVal() const { return paramval_; }
887  float* getValues() const { return window_; }
888 
889  void setValue(int idx,float val) { window_[idx]=val; }
890  bool setType(WindowType);
891  bool setType(const char*,float paramval=mUdf(float));
892 
893  bool resize(const ArrayNDInfo&);
894 
895  template <class Type> bool apply( ArrayND<Type>* in,
896  ArrayND<Type>* out_=0 ) const
897  {
898  ArrayND<Type>* out = out_ ? out_ : in;
899 
900  if ( out_ && in->info() != out_->info() ) return false;
901  if ( in->info() != size_ ) return false;
902 
903  const od_int64 totalsz = size_.getTotalSz();
904 
905  Type* indata = in->getData();
906  Type* outdata = out->getData();
907  if ( indata && outdata )
908  {
909  for ( unsigned long idx = 0; idx<totalsz; idx++ )
910  {
911  Type inval = indata[idx];
912  outdata[idx] = mIsUdf( inval ) ? inval : inval * window_[idx];
913  }
914  }
915  else
916  {
917  const ValueSeries<Type>* instorage = in->getStorage();
918  ValueSeries<Type>* outstorage = out->getStorage();
919 
920  if ( instorage && outstorage )
921  {
922  for ( unsigned long idx = 0; idx < totalsz; idx++ )
923  {
924  Type inval = instorage->value(idx);
925  outstorage->setValue(idx,
926  mIsUdf( inval ) ? inval : inval * window_[idx] );
927  }
928  }
929  else
930  {
931  ArrayNDIter iter( size_ );
932  int idx = 0;
933  do
934  {
935  Type inval = in->getND(iter.getPos());
936  out->setND( iter.getPos(),
937  mIsUdf( inval ) ? inval : inval * window_[idx] );
938  idx++;
939  } while ( iter.next() );
940  }
941  }
942 
943  return true;
944  }
945 
946 protected:
947 
948  float* window_;
951 
953  float paramval_;
954 
955  bool buildWindow(const char* winnm,float pval);
956 };
957 
958 
959 template<class T>
960 inline T Array3DInterpolate( const Array3D<T>& array,
961  float p0, float p1, float p2,
962  bool posperiodic = false )
963 {
964  const Array3DInfo& size = array.info();
965  int intpos0 = mNINT32( p0 );
966  float dist0 = p0 - intpos0;
967  int prevpos0 = intpos0;
968  if ( dist0 < 0 )
969  {
970  prevpos0--;
971  dist0++;
972  }
973  if ( posperiodic ) prevpos0 = dePeriodize( prevpos0, size.getSize(0) );
974 
975  int intpos1 = mNINT32( p1 );
976  float dist1 = p1 - intpos1;
977  int prevpos1 = intpos1;
978  if ( dist1 < 0 )
979  {
980  prevpos1--;
981  dist1++;
982  }
983  if ( posperiodic ) prevpos1 = dePeriodize( prevpos1, size.getSize(1) );
984 
985  int intpos2 = mNINT32( p2 );
986  float dist2 = p2 - intpos2;
987  int prevpos2 = intpos2;
988  if ( dist2 < 0 )
989  {
990  prevpos2--;
991  dist2++;
992  }
993 
994  if ( posperiodic ) prevpos2 = dePeriodize( prevpos2, size.getSize(2) );
995 
996  if ( !posperiodic && ( prevpos0 < 0 || prevpos0 > size.getSize(0) -2 ||
997  prevpos1 < 0 || prevpos1 > size.getSize(1) -2 ||
998  prevpos2 < 0 || prevpos2 > size.getSize(2) -2 ))
999  return mUdf(T);
1000 
1001  if ( !posperiodic && ( !prevpos0 || prevpos0 > size.getSize(0) -3 ||
1002  !prevpos1 || prevpos1 > size.getSize(1) -3 ||
1003  !prevpos2 || prevpos2 > size.getSize(2) -3 ))
1004  {
1005  return linearInterpolate3D(
1006  array.get( prevpos0 , prevpos1 , prevpos2 ),
1007  array.get( prevpos0 , prevpos1 , prevpos2+1),
1008  array.get( prevpos0 , prevpos1+1, prevpos2 ),
1009  array.get( prevpos0 , prevpos1+1, prevpos2+1),
1010  array.get( prevpos0+1, prevpos1 , prevpos2 ),
1011  array.get( prevpos0+1, prevpos1 , prevpos2+1),
1012  array.get( prevpos0+1, prevpos1+1, prevpos2 ),
1013  array.get( prevpos0+1, prevpos1+1, prevpos2+1),
1014  dist0, dist1, dist2 );
1015  }
1016 
1017  int firstpos0 = prevpos0 - 1;
1018  int nextpos0 = prevpos0 + 1;
1019  int lastpos0 = prevpos0 + 2;
1020 
1021  if ( posperiodic ) firstpos0 = dePeriodize( firstpos0, size.getSize(0) );
1022  if ( posperiodic ) nextpos0 = dePeriodize( nextpos0, size.getSize(0) );
1023  if ( posperiodic ) lastpos0 = dePeriodize( lastpos0, size.getSize(0) );
1024 
1025  int firstpos1 = prevpos1 - 1;
1026  int nextpos1 = prevpos1 + 1;
1027  int lastpos1 = prevpos1 + 2;
1028 
1029  if ( posperiodic ) firstpos1 = dePeriodize( firstpos1, size.getSize(1) );
1030  if ( posperiodic ) nextpos1 = dePeriodize( nextpos1, size.getSize(1) );
1031  if ( posperiodic ) lastpos1 = dePeriodize( lastpos1, size.getSize(1) );
1032 
1033  int firstpos2 = prevpos2 - 1;
1034  int nextpos2 = prevpos2 + 1;
1035  int lastpos2 = prevpos2 + 2;
1036 
1037  if ( posperiodic ) firstpos2 = dePeriodize( firstpos2, size.getSize(2) );
1038  if ( posperiodic ) nextpos2 = dePeriodize( nextpos2, size.getSize(2) );
1039  if ( posperiodic ) lastpos2 = dePeriodize( lastpos2, size.getSize(2) );
1040 
1041  return polyInterpolate3D (
1042  array.get( firstpos0 , firstpos1 , firstpos2 ),
1043  array.get( firstpos0 , firstpos1 , prevpos2 ),
1044  array.get( firstpos0 , firstpos1 , nextpos2 ),
1045  array.get( firstpos0 , firstpos1 , lastpos2 ),
1046 
1047  array.get( firstpos0 , prevpos1 , firstpos2 ),
1048  array.get( firstpos0 , prevpos1 , prevpos2 ),
1049  array.get( firstpos0 , prevpos1 , nextpos2 ),
1050  array.get( firstpos0 , prevpos1 , lastpos2 ),
1051 
1052  array.get( firstpos0 , nextpos1 , firstpos2 ),
1053  array.get( firstpos0 , nextpos1 , prevpos2 ),
1054  array.get( firstpos0 , nextpos1 , nextpos2 ),
1055  array.get( firstpos0 , nextpos1 , lastpos2 ),
1056 
1057  array.get( firstpos0 , lastpos1 , firstpos2 ),
1058  array.get( firstpos0 , lastpos1 , prevpos2 ),
1059  array.get( firstpos0 , lastpos1 , nextpos2 ),
1060  array.get( firstpos0 , lastpos1 , lastpos2 ),
1061 
1062 
1063  array.get( prevpos0 , firstpos1 , firstpos2 ),
1064  array.get( prevpos0 , firstpos1 , prevpos2 ),
1065  array.get( prevpos0 , firstpos1 , nextpos2 ),
1066  array.get( prevpos0 , firstpos1 , lastpos2 ),
1067 
1068  array.get( prevpos0 , prevpos1 , firstpos2 ),
1069  array.get( prevpos0 , prevpos1 , prevpos2 ),
1070  array.get( prevpos0 , prevpos1 , nextpos2 ),
1071  array.get( prevpos0 , prevpos1 , lastpos2 ),
1072 
1073  array.get( prevpos0 , nextpos1 , firstpos2 ),
1074  array.get( prevpos0 , nextpos1 , prevpos2 ),
1075  array.get( prevpos0 , nextpos1 , nextpos2 ),
1076  array.get( prevpos0 , nextpos1 , lastpos2 ),
1077 
1078  array.get( prevpos0 , lastpos1 , firstpos2 ),
1079  array.get( prevpos0 , lastpos1 , prevpos2 ),
1080  array.get( prevpos0 , lastpos1 , nextpos2 ),
1081  array.get( prevpos0 , lastpos1 , lastpos2 ),
1082 
1083 
1084  array.get( nextpos0 , firstpos1 , firstpos2 ),
1085  array.get( nextpos0 , firstpos1 , prevpos2 ),
1086  array.get( nextpos0 , firstpos1 , nextpos2 ),
1087  array.get( nextpos0 , firstpos1 , lastpos2 ),
1088 
1089  array.get( nextpos0 , prevpos1 , firstpos2 ),
1090  array.get( nextpos0 , prevpos1 , prevpos2 ),
1091  array.get( nextpos0 , prevpos1 , nextpos2 ),
1092  array.get( nextpos0 , prevpos1 , lastpos2 ),
1093 
1094  array.get( nextpos0 , nextpos1 , firstpos2 ),
1095  array.get( nextpos0 , nextpos1 , prevpos2 ),
1096  array.get( nextpos0 , nextpos1 , nextpos2 ),
1097  array.get( nextpos0 , nextpos1 , lastpos2 ),
1098 
1099  array.get( nextpos0 , lastpos1 , firstpos2 ),
1100  array.get( nextpos0 , lastpos1 , prevpos2 ),
1101  array.get( nextpos0 , lastpos1 , nextpos2 ),
1102  array.get( nextpos0 , lastpos1 , lastpos2 ),
1103 
1104 
1105  array.get( lastpos0 , firstpos1 , firstpos2 ),
1106  array.get( lastpos0 , firstpos1 , prevpos2 ),
1107  array.get( lastpos0 , firstpos1 , nextpos2 ),
1108  array.get( lastpos0 , firstpos1 , lastpos2 ),
1109 
1110  array.get( lastpos0 , prevpos1 , firstpos2 ),
1111  array.get( lastpos0 , prevpos1 , prevpos2 ),
1112  array.get( lastpos0 , prevpos1 , nextpos2 ),
1113  array.get( lastpos0 , prevpos1 , lastpos2 ),
1114 
1115  array.get( lastpos0 , nextpos1 , firstpos2 ),
1116  array.get( lastpos0 , nextpos1 , prevpos2 ),
1117  array.get( lastpos0 , nextpos1 , nextpos2 ),
1118  array.get( lastpos0 , nextpos1 , lastpos2 ),
1119 
1120  array.get( lastpos0 , lastpos1 , firstpos2 ),
1121  array.get( lastpos0 , lastpos1 , prevpos2 ),
1122  array.get( lastpos0 , lastpos1 , nextpos2 ),
1123  array.get( lastpos0 , lastpos1 , lastpos2 ),
1124  dist0, dist1, dist2 );
1125 }
1126 
1127 
1128 template <class T>
1129 inline bool ArrayNDCopy( ArrayND<T>& dest, const ArrayND<T>& src,
1130  const TypeSet<int>& copypos, bool srcperiodic=false )
1131 {
1132  const ArrayNDInfo& destsz = dest.info();
1133  const ArrayNDInfo& srcsz = src.info();
1134 
1135  const int ndim = destsz.getNDim();
1136  if ( ndim != srcsz.getNDim() || ndim != copypos.size() ) return false;
1137 
1138  for ( int idx=0; idx<ndim; idx++ )
1139  {
1140  if ( !srcperiodic &&
1141  copypos[idx] + destsz.getSize(idx) > srcsz.getSize(idx) )
1142  return false;
1143  }
1144 
1145  ArrayNDIter destposition( destsz );
1146  TypeSet<int> srcposition( ndim, 0 );
1147 
1148  do
1149  {
1150  for ( int idx=0; idx<ndim; idx++ )
1151  {
1152  srcposition[idx] = copypos[idx] + destposition[idx];
1153  if ( srcperiodic )
1154  srcposition[idx] =
1155  dePeriodize( srcposition[idx], srcsz.getSize(idx) );
1156  }
1157 
1158  dest.setND( destposition.getPos(), src.get( &srcposition[0] ));
1159 
1160 
1161  } while ( destposition.next() );
1162 
1163  return true;
1164 }
1165 
1166 
1167 template <class T>
1168 inline bool Array3DCopy( Array3D<T>& dest, const Array3D<T>& src,
1169  int p0, int p1, int p2, bool srcperiodic=false )
1170 {
1171  const ArrayNDInfo& destsz = dest.info();
1172  const ArrayNDInfo& srcsz = src.info();
1173 
1174  const int destsz0 = destsz.getSize(0);
1175  const int destsz1 = destsz.getSize(1);
1176  const int destsz2 = destsz.getSize(2);
1177 
1178  const int srcsz0 = srcsz.getSize(0);
1179  const int srcsz1 = srcsz.getSize(1);
1180  const int srcsz2 = srcsz.getSize(2);
1181 
1182  if ( !srcperiodic )
1183  {
1184  if ( p0 + destsz0 > srcsz0 ||
1185  p1 + destsz1 > srcsz1 ||
1186  p2 + destsz2 > srcsz2 )
1187  return false;
1188  }
1189 
1190  int idx = 0;
1191  T* ptr = dest.getData();
1192 
1193  for ( int id0=0; id0<destsz0; id0++ )
1194  {
1195  for ( int id1=0; id1<destsz1; id1++ )
1196  {
1197  for ( int id2=0; id2<destsz2; id2++ )
1198  {
1199  ptr[idx++] = src.get( dePeriodize(id0 + p0, srcsz0),
1200  dePeriodize(id1 + p1, srcsz1),
1201  dePeriodize(id2 + p2, srcsz2));
1202 
1203  }
1204  }
1205  }
1206 
1207  return true;
1208 }
1209 
1210 
1211 template <class T>
1212 inline bool ArrayNDPaste( ArrayND<T>& dest, const ArrayND<T>& src,
1213  const TypeSet<int>& pastepos,
1214  bool destperiodic=false )
1215 {
1216  const ArrayNDInfo& destsz = dest.info();
1217  const ArrayNDInfo& srcsz = src.info();
1218 
1219  const int ndim = destsz.getNDim();
1220  if ( ndim != srcsz.getNDim() || ndim != pastepos.size() ) return false;
1221 
1222  for ( int idx=0; idx<ndim; idx++ )
1223  {
1224  if ( !destperiodic &&
1225  pastepos[idx] + srcsz.getSize(idx) > destsz.getSize(idx) )
1226  return false;
1227  }
1228 
1229  ArrayNDIter srcposition( srcsz );
1230  TypeSet<int> destposition( ndim, 0 );
1231 
1232  int ptrpos = 0;
1233  T* ptr = src.getData();
1234 
1235  do
1236  {
1237  for ( int idx=0; idx<ndim; idx++ )
1238  {
1239  destposition[idx] = pastepos[idx] + srcposition[idx];
1240  if ( destperiodic )
1241  destposition[idx] =
1242  dePeriodize( destposition[idx], destsz.getSize(idx) );
1243  }
1244 
1245  dest( destposition ) = ptr[ptrpos++];
1246 
1247  } while ( srcposition.next() );
1248 
1249  return true;
1250 }
1251 
1252 
1253 template <class T>
1254 inline bool Array2DPaste( Array2D<T>& dest, const Array2D<T>& src,
1255  int p0, int p1, bool destperiodic=false )
1256 {
1257  const ArrayNDInfo& destsz = dest.info();
1258  const ArrayNDInfo& srcsz = src.info();
1259 
1260  const int srcsz0 = srcsz.getSize(0);
1261  const int srcsz1 = srcsz.getSize(1);
1262 
1263  const int destsz0 = destsz.getSize(0);
1264  const int destsz1 = destsz.getSize(1);
1265 
1266  if ( !destperiodic )
1267  {
1268  if ( p0 + srcsz0 > destsz0 ||
1269  p1 + srcsz1 > destsz1 )
1270  return false;
1271  }
1272 
1273 
1274  int idx = 0;
1275  const T* ptr = src.getData();
1276 
1277  for ( int id0=0; id0<srcsz0; id0++ )
1278  {
1279  for ( int id1=0; id1<srcsz1; id1++ )
1280  {
1281  dest.set( dePeriodize( id0 + p0, destsz0),
1282  dePeriodize( id1 + p1, destsz1),
1283  ptr[idx++]);
1284  }
1285  }
1286 
1287  return true;
1288 }
1289 
1290 
1291 template <class T>
1292 inline bool Array3DPaste( Array3D<T>& dest, const Array3D<T>& src,
1293  int p0, int p1, int p2,
1294  bool destperiodic=false )
1295 {
1296  const ArrayNDInfo& destsz = dest.info();
1297  const ArrayNDInfo& srcsz = src.info();
1298 
1299  const int srcsz0 = srcsz.getSize(0);
1300  const int srcsz1 = srcsz.getSize(1);
1301  const int srcsz2 = srcsz.getSize(2);
1302 
1303  const int destsz0 = destsz.getSize(0);
1304  const int destsz1 = destsz.getSize(1);
1305  const int destsz2 = destsz.getSize(2);
1306 
1307  if ( !destperiodic )
1308  {
1309  if ( p0 + srcsz0 > destsz0 ||
1310  p1 + srcsz1 > destsz1 ||
1311  p2 + srcsz2 > destsz2 )
1312  return false;
1313  }
1314 
1315 
1316  int idx = 0;
1317  const T* ptr = src.getData();
1318 
1319  for ( int id0=0; id0<srcsz0; id0++ )
1320  {
1321  for ( int id1=0; id1<srcsz1; id1++ )
1322  {
1323  for ( int id2=0; id2<srcsz2; id2++ )
1324  {
1325  dest.set( dePeriodize( id0 + p0, destsz0),
1326  dePeriodize( id1 + p1, destsz1),
1327  dePeriodize( id2 + p2, destsz2), ptr[idx++]);
1328  }
1329  }
1330  }
1331 
1332  return true;
1333 }
1334 
1335 
1338 template <class T>
1341 public:
1342  Array2DCopier( const Array2D<T>& in,
1343  const TrcKeySampling& tksin,
1344  const TrcKeySampling& tksout,
1345  Array2D<T>& out )
1346  : in_(in)
1347  , tksin_(tksin)
1348  , tksout_(tksout)
1349  , out_(out)
1350  {
1351  if ( canCopyAll() )
1352  {
1353  doPrepare(0);
1354  return;
1355  }
1356 
1357  tksin.getInterSection( tksout, commontks_ );
1358  }
1359 
1361  {
1364  uiStrings::sDone().toLower() );
1365  }
1366  uiString message() const { return tr("Transferring grid data");}
1367 
1368 protected:
1369 
1371  {
1372  return canCopyAll() ? 0 : commontks_.nrLines();
1373  }
1374 
1375 private:
1376 
1377  bool canCopyAll() const
1378  {
1379  return tksout_ == tksin_ && in_.getData() &&
1380  ( out_.getData() || out_.getStorage() );
1381  }
1382 
1383  bool doPrepare( int )
1384  {
1385  if ( in_.info().getSize(0) != tksin_.nrLines() ||
1386  in_.info().getSize(1) != tksin_.nrTrcs() )
1387  {
1388  return false;
1389  }
1390 
1391  if ( out_.info().getSize(0) != tksout_.nrLines() ||
1392  out_.info().getSize(1) != tksout_.nrTrcs() )
1393  {
1394  mDynamicCastGet(Array2DImpl<T>*,outimpl,&out_)
1395  if ( !outimpl || !outimpl->setSize( tksout_.nrLines(),
1396  tksout_.nrTrcs() ) )
1397  {
1398  return false;
1399  }
1400 
1401  out_.setAll( mUdf(T) );
1402  }
1403 
1404  if ( canCopyAll() )
1405  {
1406  if ( out_.getData() )
1407  in_.getAll( out_.getData() );
1408  else if ( out_.getStorage() )
1409  in_.getAll( *out_.getStorage() );
1410  }
1411 
1412  return true;
1413  }
1414 
1415  bool doWork( od_int64 start, od_int64 stop, int )
1416  {
1417  const TrcKeySampling tksin( tksin_ );
1418  const TrcKeySampling tksout( tksout_ );
1419  const TrcKeySampling tks( commontks_ );
1420 
1421  const bool usearrayptrs = in_.getData() && out_.getData() &&
1422  in_.getStorage() &&
1423  out_.getStorage();
1424  OffsetValueSeries<T>* invals = !usearrayptrs ? 0 :
1425  new OffsetValueSeries<T>( *in_.getStorage(), 0 );
1426  OffsetValueSeries<T>* outvals = !usearrayptrs ? 0 :
1427  new OffsetValueSeries<T>( *out_.getStorage(), 0 );
1428  const int nrcrl = tks.nrTrcs();
1429  const od_int64 nrbytes = nrcrl * sizeof(T);
1430 
1431  const int startcrl = tks.start_.crl();
1432  const int startcrlidyin = tksin.trcIdx( startcrl );
1433  const int startcrlidyout = tksout.trcIdx( startcrl );
1434  for ( int idx=mCast(int,start); idx<=mCast(int,stop); idx++)
1435  {
1436  const int inl = tks.lineRange().atIndex( idx );
1437  const int inlidxin = tksin.lineIdx( inl );
1438  const int inlidxout = tksout.lineIdx( inl );
1439  if ( usearrayptrs )
1440  {
1441  invals->setOffset(
1442  in_.info().getOffset(inlidxin,startcrlidyin) );
1443  outvals->setOffset(
1444  out_.info().getOffset(inlidxout,startcrlidyout) );
1445  OD::memCopy(outvals->arr(),invals->arr(),nrbytes);
1446  continue;
1447  }
1448  else
1449  {
1450  for ( int idy=0; idy<nrcrl; idy++ )
1451  {
1452  const T val =
1453  in_.get( inlidxin, startcrlidyin+idy );
1454  out_.set( inlidxout, startcrlidyout+idy, val );
1455  }
1456  }
1457  }
1458 
1459  delete invals;
1460  delete outvals;
1461 
1462  return true;
1463  }
1464 
1465  const Array2D<T>& in_;
1470 };
1471 
1472 
1475 template <class T>
1478 public:
1479  Array3DCopier( const Array3D<T>& in, Array3D<T>& out,
1480  const TrcKeyZSampling& tkzsin,
1481  const TrcKeyZSampling& tkzsout )
1482  : ParallelTask("Array 3D Resizer")
1483  , tkzsin_(tkzsin)
1484  , tkzsout_(tkzsout)
1485  , totalnr_(tkzsout.hsamp_.totalNr())
1486  , in_(in)
1487  , out_(out)
1488  {}
1489 
1490  uiString message() const { return tr("Resizing 3D Array"); }
1491 
1493 
1494 protected:
1495 
1496  od_int64 nrIterations() const { return totalnr_; }
1497 
1498 private:
1499 
1500 #define mGetInfo() \
1501  const Array3DInfoImpl infoin( tkzsin_.hsamp_.nrLines(), \
1502  tkzsin_.hsamp_.nrTrcs(), tkzsin_.nrZ() ); \
1503  const Array3DInfoImpl infoout( tkzsout_.hsamp_.nrLines(), \
1504  tkzsout_.hsamp_.nrTrcs(), tkzsout_.nrZ() );
1505 
1506  bool doPrepare( int )
1507  {
1508  mGetInfo()
1509  if ( in_.info() != infoin )
1510  return false;
1511 
1512  if ( out_.info() != infoout && !out_.setInfo(infoout) )
1513  return false;
1514 
1515  if ( tkzsin_.hsamp_.survid_ != tkzsout_.hsamp_.survid_ )
1516  return false;
1517 
1518  if ( !tkzsin_.zsamp_.isCompatible(tkzsout_.zsamp_) )
1519  return false; //Not supported
1520 
1521  out_.setAll( mUdf(T) );
1522 
1523  return true;
1524  }
1525 
1526 
1527  bool doWork( od_int64 start, od_int64 stop, int )
1528  {
1529  mGetInfo()
1530  const TrcKeySampling tksin( tkzsin_.hsamp_ );
1531  const TrcKeySampling tksout( tkzsout_.hsamp_ );
1532  const int nrzout = infoout.getSize(2);
1533  StepInterval<float> zrg( tkzsout_.zsamp_ );
1534  zrg.limitTo( tkzsin_.zsamp_ );
1535  const int nrztocopy = zrg.nrSteps() + 1;
1536  const int z0in = tkzsin_.zsamp_.getIndex( zrg.start );
1537  const int z0out = tkzsout_.zsamp_.getIndex( zrg.start );
1538  const od_int64 nrbytes =
1539  mCast(od_int64,nrztocopy) * sizeof(T);
1540  const T* inptr = in_.getData();
1541  T* outptr = out_.getData();
1542  const ValueSeries<T>* instor = in_.getStorage();
1543  ValueSeries<T>* outstor = out_.getStorage();
1544  const bool hasarrayptr = inptr && outptr;
1545  const bool hasstorage = instor && outstor;
1546  const bool needgetset = !hasarrayptr && !hasstorage;
1547 
1548  const Array2DInfoImpl info2d( infoout.getSize( 0 ),
1549  infoout.getSize( 1 ) );
1550  ArrayNDIter iter( info2d );
1551  iter.setGlobalPos( start );
1552 
1553  const od_int64 offsetout = start * nrzout + z0out;
1554  outptr += offsetout;
1555  od_uint64 validxout = offsetout;
1556 
1557  for ( od_int64 idx=start; idx<=stop; idx++, iter.next(),
1558  outptr+=nrzout, validxout+=nrzout,
1559  quickAddToNrDone(idx) )
1560  {
1561  const int inlidx = iter[0];
1562  const int crlidx = iter[1];
1563  const BinID bid( tksout.atIndex(inlidx,crlidx) );
1564  if ( !tksin.includes(bid) )
1565  continue;
1566 
1567  const int inlidxin = tksin.lineIdx( bid.lineNr() );
1568  const int crlidxin = tksin.trcIdx( bid.trcNr() );
1569  const od_int64 offsetin = needgetset ? 0
1570  : infoin.getOffset( inlidxin, crlidxin, z0in );
1571  if ( hasarrayptr )
1572  {
1573  OD::memCopy( outptr, inptr+offsetin, nrbytes );
1574  }
1575  else if ( hasstorage )
1576  {
1577  for ( int idz=0; idz<nrztocopy; idz++ )
1578  {
1579  outstor->setValue( validxout+idz,
1580  instor->value(offsetin+idz));
1581  }
1582  }
1583  else
1584  {
1585  for ( int idz=0, idzin=z0in; idz<nrztocopy; idz++,
1586  idzin++)
1587  {
1588  const T val =
1589  in_.get( inlidxin, crlidxin, idzin );
1590  out_.set( inlidx, crlidx, idz, val );
1591  }
1592  }
1593  }
1594 
1595  return true;
1596  }
1597 
1601 
1602  const Array3D<T>& in_;
1604 };
1605 
1606 
1614 {
1615 public:
1616  PolyTrend();
1617 
1618  bool operator==(const PolyTrend&) const;
1619 
1620  enum Order { None, Order0, Order1, Order2};
1622 
1623  static const char* sKeyOrder() { return "Polynomial Order"; }
1624 
1625  void setOrder( PolyTrend::Order t ) { order_ = t; }
1626  template <class IDXABLE> bool set(const TypeSet<Coord>&,
1627  const IDXABLE& valuelistj);
1632  Order getOrder() const { return order_; }
1633 
1634  template <class T> void apply(const Coord& pos,bool dir,T&) const;
1640 protected:
1641 
1643  double f0_;
1644  double f1_;
1645  double f2_;
1646  double f11_;
1647  double f12_;
1648  double f22_;
1650 
1651  void initOrder0(const TypeSet<double>&);
1652  void initOrder1(const TypeSet<Coord>&,
1653  const TypeSet<double>&);
1654  void initOrder2(const TypeSet<Coord>&,
1655  const TypeSet<double>&);
1656  void initCenter(const TypeSet<Coord>&);
1657 
1658 };
1659 
1660 
1661 
1662 template <class IDXABLE> inline
1663 bool PolyTrend::set( const TypeSet<Coord>& poslist, const IDXABLE& vals )
1664 {
1665  int sz = poslist.size();
1666  if ( order_ == PolyTrend::None )
1667  return false;
1668 
1669  f0_ = f1_ = f2_ = f11_ = f12_ = f22_ = posc_.x_ = posc_.y_ = 0.;
1670  TypeSet<Coord> posnoudf;
1671  TypeSet<double> valsnoudf;
1672  for ( int idx=0; idx<sz; idx++ )
1673  {
1674  if ( !poslist[idx].isDefined() || mIsUdf(vals[idx]) )
1675  continue;
1676 
1677  posnoudf += poslist[idx];
1678  valsnoudf += (double) vals[idx];
1679  }
1680 
1681  sz = valsnoudf.size();
1682  if ( order_ == Order2 && sz > 5 )
1683  initOrder2( posnoudf, valsnoudf );
1684  else if ( order_ == Order1 && sz > 2 )
1685  initOrder1( posnoudf, valsnoudf );
1686  else
1687  initOrder0( valsnoudf );
1688 
1689  return true;
1690 }
1691 
1692 
1693 template <class T> inline
1694 void PolyTrend::apply( const Coord& pos, bool dir, T& val ) const
1695 {
1696  if ( order_ == None || !pos.isDefined() || mIsUdf(val) )
1697  return;
1698 
1699  const double fact = dir ? -1. : 1;
1700  double inp = (double) val;
1701  inp += fact * f0_;
1702  if ( order_ == Order0 )
1703  {
1704  val = (T)inp;
1705  return;
1706  }
1707 
1708  const double dx = pos.x_ - posc_.x_;
1709  const double dy = pos.y_ - posc_.y_;
1710  inp += fact * ( f1_ * dx + f2_ * dy );
1711  if ( order_ == Order1 )
1712  {
1713  val = (T)inp;
1714  return;
1715  }
1716 
1717  const double dx2 = dx * dx;
1718  const double dxy = dx * dy;
1719  const double dyy = dy * dy;
1720  inp += fact * ( f11_ * dx2 + f12_ * dxy + f22_ * dyy );
1721  val = (T)inp;
1722 }
1723 
1724 
1731 template <class T>
1734 public:
1736  LargeValVec<od_uint64>* undefidxs )
1737  : ParallelTask("Array Udf Replacer")
1738  , inp_(inp)
1739  , replval_(0.f)
1740  , undefidxs_(undefidxs)
1741  , tks_(0)
1742  , trcssampling_(0)
1743  , totalnr_(inp.info().getTotalSz()/inp.info().getSize(1))
1744  {}
1745 
1747  LargeValVec<od_uint64>* undefidxs )
1748  : ParallelTask("Array Udf Replacer")
1749  , inp_(inp)
1750  , replval_(0.f)
1751  , undefidxs_(undefidxs)
1752  , tks_(0)
1753  , trcssampling_(0)
1754  , totalnr_(inp.info().getTotalSz()/inp.info().getSize(2))
1755  {}
1756 
1758  {
1759  return tr("Replacing undefined values");
1760  }
1761 
1763 
1764  void setReplacementValue( T val ) { replval_ = val; }
1765 
1766  void setSampling( const TrcKeySampling& tks,
1767  const PosInfo::CubeData* trcssampling )
1768  {
1769  tks_ = &tks;
1770  trcssampling_ = trcssampling;
1771  }
1772 
1773 protected:
1774 
1775  od_int64 nrIterations() const { return totalnr_; }
1776 
1777 private:
1778 
1779  bool doPrepare( int )
1780  {
1781  if ( undefidxs_ )
1782  undefidxs_->setEmpty();
1783 
1784  return true;
1785  }
1786 
1787  bool doWork( od_int64 start, od_int64 stop, int )
1788  {
1789  const bool isrect = tks_ && trcssampling_
1790  ? trcssampling_->isFullyRectAndReg()
1791  : true;
1792  const ArrayNDInfo& info = inp_.info();
1793  const int nrtrcsp = info.getSize( inp_.get1DDim() );
1794  T* dataptr = inp_.getData();
1795  ValueSeries<T>* datastor = inp_.getStorage();
1796  const bool hasarrayptr = dataptr;
1797  const bool hasstorage = datastor;
1798  const bool neediterator = !hasarrayptr && !hasstorage;
1799  const od_int64 offset = start * nrtrcsp;
1800  dataptr += offset;
1801  od_uint64 validx = offset;
1802  ArrayNDIter* iter = neediterator
1803  ? new ArrayNDIter( info ) : 0;
1804  if ( iter )
1805  iter->setGlobalPos( offset );
1806 
1807  const T replval = replval_;
1808  for ( od_int64 idx=start; idx<=stop; idx++,
1809  quickAddToNrDone(idx))
1810  {
1811  const bool hastrcdata = isrect ? true
1812  : trcssampling_->isValid(idx,*tks_);
1813  if ( hastrcdata )
1814  {
1815  for ( int idz=0; idz<nrtrcsp; idz++ )
1816  {
1817  const int* pos = iter ? iter->getPos() : 0;
1818  const T val = hasarrayptr ? *dataptr
1819  : hasstorage
1820  ? datastor->value( validx )
1821  : inp_.getND( pos );
1822  if ( !mIsUdf(val) )
1823  {
1824  if ( hasarrayptr ) dataptr++;
1825  else if ( hasstorage ) validx++;
1826  else iter->next();
1827 
1828  continue;
1829  }
1830 
1831  if ( undefidxs_ )
1832  {
1833  lck_.lock();
1834  *undefidxs_ += idx*nrtrcsp + idz;
1835  lck_.unLock();
1836  }
1837 
1838  if ( hasarrayptr )
1839  *dataptr++ = replval;
1840  else if ( hasstorage )
1841  datastor->setValue( validx++, replval );
1842  else
1843  {
1844  inp_.setND( pos, replval );
1845  iter->next();
1846  }
1847  }
1848  }
1849  else
1850  {
1851  if ( hasarrayptr )
1852  {
1853  OD::memValueSet(dataptr, replval, nrtrcsp);
1854  dataptr+=nrtrcsp;
1855  }
1856  else if ( hasstorage )
1857  {
1858  for ( int idz=0; idz<nrtrcsp; idz++ )
1859  datastor->setValue( validx++, replval );
1860  }
1861  else
1862  {
1863  for ( int idz=0; idz<nrtrcsp; idz++ )
1864  {
1865  inp_.setND( iter->getPos(), replval );
1866  iter->next();
1867  }
1868  }
1869  }
1870  }
1871 
1872  delete iter;
1873 
1874  return true;
1875  }
1876 
1884 };
1885 
1886 
1889 mGlobal(Algo) void convertUndefinedIndexList(const TrcKeyZSampling& tkzsin,
1890  const TrcKeyZSampling& tkzsout,
1892 
1893 
1896 template <class T>
1899 public:
1900  ArrayUdfValRestorer( const LargeValVec<od_uint64>& undefidxs,
1901  ArrayND<T>& outp )
1902  : ParallelTask("Udf retriever")
1903  , undefidxs_(undefidxs)
1904  , outp_(outp)
1905  , totalnr_(undefidxs.size())
1906  {}
1907 
1908  uiString message() const { return tr("Replacing undefined values"); }
1909 
1911 
1912 protected:
1913 
1914  od_int64 nrIterations() const { return totalnr_; }
1915 
1916 private:
1917 
1918  bool doWork( od_int64 start, od_int64 stop, int )
1919  {
1920  T* outpptr = outp_.getData();
1921  ValueSeries<T>* outpstor = outp_.getStorage();
1922  mDeclareAndTryAlloc(int*,pos,int[outp_.info().getNDim()])
1923  if ( !pos )
1924  return false;
1925 
1926  const T udfval = mUdf(T);
1927  const ArrayNDInfo& info = outp_.info();
1928  for ( od_int64 idx=start; idx<=stop; idx++,
1929  quickAddToNrDone(idx) )
1930  {
1931  const od_uint64 sidx = undefidxs_[idx];
1932  if ( outpptr )
1933  outpptr[sidx] = udfval;
1934  else if ( outpstor )
1935  outpstor->setValue( sidx, udfval );
1936  else
1937  {
1938  info.getArrayPos( sidx, pos );
1939  outp_.setND( pos, udfval );
1940  }
1941  }
1942 
1943  delete [] pos;
1944 
1945  return true;
1946  }
1947 
1951 };
1952 
1953 
1956 template <class T>
1959 public:
1960  Array3DUdfTrcRestorer( const PosInfo::CubeData& trcssampling,
1961  const TrcKeySampling& tks,
1962  Array3D<T>& outp )
1963  : ParallelTask("Udf traces retriever")
1964  , trcssampling_(trcssampling)
1965  , tks_(tks)
1966  , outp_(outp)
1967  , totalnr_(trcssampling.isFullyRectAndReg() ? 0 :
1968  outp.info().getTotalSz()/outp.info().getSize(2))
1969  {}
1970 
1971  uiString message() const { return tr("Restoring undefined values"); }
1972 
1974 
1975 protected:
1976 
1977  od_int64 nrIterations() const { return totalnr_; }
1978 
1979 private:
1980 
1981  bool doWork( od_int64 start, od_int64 stop, int )
1982  {
1983  const Array3DInfo& info = outp_.info();
1984  const int nrtrcsp = info.getSize( outp_.get1DDim() );
1985  T* outpptr = outp_.getData();
1986  ValueSeries<T>* outstor = outp_.getStorage();
1987  const bool hasarrayptr = outpptr;
1988  const bool hasstorage = outstor;
1989  const od_int64 offset = start * nrtrcsp;
1990  outpptr += offset;
1991  od_uint64 validx = offset;
1992  const Array2DInfoImpl hinfo( info.getSize(0),
1993  info.getSize(1) );
1994  ArrayNDIter* hiter = !hasarrayptr && !hasstorage
1995  ? new ArrayNDIter( hinfo ) : 0;
1996  if ( hiter )
1997  hiter->setGlobalPos( start );
1998 
1999  for ( od_int64 idx=start; idx<=stop; idx++ )
2000  {
2001  if ( trcssampling_.isValid(idx,tks_) )
2002  {
2003  if ( hasarrayptr ) outpptr+=nrtrcsp;
2004  else if ( hasstorage ) validx+=nrtrcsp;
2005  else hiter->next();
2006 
2007  continue;
2008  }
2009 
2010  if ( hasarrayptr )
2011  {
2012  OD::memValueSet( outpptr, mUdf(T), nrtrcsp);
2013  outpptr+=nrtrcsp;
2014  }
2015  else if ( hasstorage )
2016  {
2017  for ( int idz=0; idz<nrtrcsp; idz++ )
2018  outstor->setValue( validx++, mUdf(T) );
2019  }
2020  else
2021  {
2022  const int inlidx = (*hiter)[0];
2023  const int crlidx = (*hiter)[1];
2024  for ( int idz=0; idz<nrtrcsp; idz++ )
2025  outp_.set( inlidx, crlidx, idz, mUdf(T) );
2026  }
2027  }
2028 
2029  delete hiter;
2030 
2031  return true;
2032  }
2033 
2037 
2039 };
2040 
2041 
2047 template <class T>
2050 public:
2051  MuteArrayExtracter( const ArrayND<T>& data,
2052  ArrayND<int>& topmute,
2053  ArrayND<int>& tailmute )
2054  : ParallelTask("Mute Array Extracter")
2055  , data_(data)
2056  , topmute_(topmute)
2057  , tailmute_(tailmute)
2058  , tks_(0)
2059  , trcssampling_(0)
2060  , totalnr_(data.info().getTotalSz()/
2061  data.info().getSize(data.get1DDim()))
2062  {}
2063 
2065  {
2066  return tr("Extracting mute positions");
2067  }
2068 
2070 
2071  void setSampling( const TrcKeySampling& tks,
2072  const PosInfo::CubeData* trcssampling )
2073  {
2074  tks_ = &tks;
2075  trcssampling_ = trcssampling;
2076  }
2077 
2078 protected:
2079 
2080  od_int64 nrIterations() const { return totalnr_; }
2081 
2082 private:
2083 
2084  bool doPrepare( int )
2085  {
2086  const int data1ddim = data_.get1DDim();
2087  if ( ( data1ddim != 1 && data1ddim != 2 ) ||
2088  topmute_.get1DDim() != data1ddim-1 ||
2089  tailmute_.get1DDim() != data1ddim-1 )
2090  return false;
2091 
2092  topmute_.setAll( 0 );
2093  const int nrz =
2094  mCast(int,data_.info().getTotalSz()/totalnr_);
2095  tailmute_.setAll( nrz-1 );
2096 
2097  return true;
2098  }
2099 
2100  bool doWork( od_int64 start, od_int64 stop, int )
2101  {
2102  const bool isrect = tks_ && trcssampling_
2103  ? trcssampling_->isFullyRectAndReg()
2104  : true;
2105  const T* dataptr = data_.getData();
2106  int* topmuteptr = topmute_.getData();
2107  int* tailmuteptr = tailmute_.getData();
2108  const ValueSeries<T>* datastor = data_.getStorage();
2109  ValueSeries<int>* topmutestor = topmute_.getStorage();
2110  ValueSeries<int>* tailmutestor = tailmute_.getStorage();
2111  const bool hasarrayptr = dataptr && topmuteptr &&
2112  tailmuteptr;
2113  const bool hasstorage = datastor && topmutestor &&
2114  tailmutestor;
2115  const bool neediterator = !hasarrayptr && !hasstorage;
2116  const ArrayNDInfo& info = data_.info();
2117  const int zidx = data_.get1DDim();
2118  const int nrtrcsp = info.getSize( zidx );
2119  const od_int64 offset = start * nrtrcsp;
2120  if ( hasarrayptr )
2121  {
2122  dataptr += offset;
2123  topmuteptr += start;
2124  tailmuteptr += start;
2125  }
2126 
2127  od_uint64 validx = offset;
2128  const int ndim = info.getNDim();
2129  const bool is2d = ndim == 2;
2130  const int nrlines = is2d ? 1 : info.getSize(0);
2131  const int nrtrcs = info.getSize( is2d ? 0 : 1 );
2132  const Array2DInfoImpl hinfo( nrlines, nrtrcs );
2133  ArrayNDIter* hiter = neediterator
2134  ? new ArrayNDIter( hinfo ) : 0;
2135  if ( hiter )
2136  hiter->setGlobalPos( start );
2137 
2138  const T zeroval = mCast(T,0);
2139  mDeclareAndTryAlloc(int*, pos, int[ndim])
2140  if (!pos)
2141  return false;
2142 
2143  for ( od_int64 idx=start; idx<=stop; idx++,
2144  quickAddToNrDone(idx) )
2145  {
2146  const bool hastrcdata = isrect ? true
2147  : trcssampling_->isValid(idx,*tks_);
2148  if ( !hastrcdata )
2149  {
2150  if ( hasarrayptr )
2151  {
2152  dataptr+=nrtrcsp;
2153  topmuteptr++;
2154  tailmuteptr++;
2155  }
2156  if ( hasstorage ) validx+=nrtrcsp;
2157  else hiter->next();
2158 
2159  continue;
2160  }
2161 
2162  const int* hpos = hiter ? hiter->getPos() : 0;
2163  if ( hiter )
2164  {
2165  for ( int ipos=0; ipos<ndim; ipos++ )
2166  pos[ipos] = hpos[ipos];
2167  hiter->next();
2168  }
2169 
2170  bool allnull = false;
2171  for ( int idz=0; idz<nrtrcsp; idz++ )
2172  {
2173  if ( hiter ) pos[zidx] = idz;
2174  const float val = hasarrayptr
2175  ? *dataptr++
2176  : hasstorage
2177  ? datastor->value( validx++ )
2178  : data_.getND( pos );
2179  if ( val == zeroval )
2180  continue;
2181 
2182  if ( hasarrayptr )
2183  {
2184  *topmuteptr++ = idz;
2185  dataptr += nrtrcsp-idz-2;
2186  }
2187  else if ( hasstorage )
2188  {
2189  topmutestor->setValue( idx, idz );
2190  validx += nrtrcsp-idz-2;
2191  }
2192  else
2193  topmute_.setND( hpos, idz );
2194 
2195  break;
2196  allnull = true;
2197  }
2198 
2199  if ( allnull )
2200  {
2201  if ( hasarrayptr )
2202  {
2203  *topmuteptr++ = nrtrcsp;
2204  *tailmuteptr++ = -1;
2205  }
2206  else if ( hasstorage )
2207  {
2208  topmutestor->setValue( idx, nrtrcsp );
2209  tailmutestor->setValue( idx, -1 );
2210  }
2211  else
2212  {
2213  topmute_.setND( hpos, nrtrcsp );
2214  tailmute_.setND( hpos, -1 );
2215  }
2216 
2217  continue;
2218  }
2219 
2220  for ( int idz=nrtrcsp-1; idz>=0; idz-- )
2221  {
2222  if ( hiter ) pos[zidx] = idz;
2223  const float val = hasarrayptr
2224  ? *dataptr--
2225  : hasstorage
2226  ? datastor->value( validx-- )
2227  : data_.getND( pos );
2228  if ( val == zeroval )
2229  continue;
2230 
2231  if ( hasarrayptr )
2232  {
2233  *tailmuteptr++ = idz;
2234  dataptr += nrtrcsp-idz+1;
2235  }
2236  else if ( hasstorage )
2237  {
2238  tailmutestor->setValue( idx, idz );
2239  validx += nrtrcsp-idz+1;
2240  }
2241  else
2242  tailmute_.setND( hpos, idz );
2243 
2244  break;
2245  }
2246  }
2247 
2248  delete [] pos;
2249 
2250  delete hiter;
2251 
2252  return true;
2253  }
2254 
2260 
2262 };
uiString nrDoneText() const
Definition: arrayndalgo.h:81
Array1D ( Subclass of ArrayND ) is a one dimensional array.
Definition: arraynd.h:97
bool doabs_
Definition: arrayndalgo.h:47
Definition: arrayndalgo.h:1620
const TrcKeySampling * tks_
Definition: arrayndalgo.h:1880
T * arr()
Definition: valseriesimpl.h:202
#define mExpClass(module)
Definition: commondefs.h:157
virtual uint64_t getTotalSz() const
virtual int getNDim() const =0
bool isOK() const
Definition: arrayndalgo.h:884
bool rectangular_
Definition: arrayndalgo.h:950
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:285
uiString message() const
Definition: arrayndalgo.h:1490
virtual T value(int64_t) const =0
static uiString sDone()
Definition: uistrings.h:302
static uiString tr(const char *text, const char *disambiguation=0, int pluralnr=-1)
Definition: paralleltask.h:65
void setYVals(const ArrayND< ArrType > &yvals)
Definition: arrayndalgo.h:266
double f2_
Definition: arrayndalgo.h:1645
mODTextTranslationClass(Array2DCopier) public
Definition: arrayndalgo.h:1340
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:83
Array2D< T > & out_
Definition: arrayndalgo.h:1469
static uiString sTrcFinished()
Definition: paralleltask.h:88
SumType cumsum_
Definition: arrayndalgo.h:233
const od_int64 totalnr_
Definition: arrayndalgo.h:2038
#define mDeclareAndTryAlloc(tp, var, stmt)
Creates variable, try to alloc and catch bad_alloc.
Definition: commondefs.h:251
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:51
ArrayOperExecSetup(bool doadd=true, bool dosqinp=false, bool dosqout=false, bool doabs=false, bool donormalizesum=false, bool dosqrtsum=false)
Definition: arrayndalgo.h:32
bool isOK() const
Definition: arrayndimpl.h:66
InterpolType
Definition: mathfunc.h:153
Definition: arrayndalgo.h:1732
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1787
void getScaled(const ArrayND< ArrType > &in, ArrayND< ArrType > *out_, OperType fact, SumType shift, bool noudf, bool parallel)
returns a scaled array
Definition: arrayndalgo.h:421
float * getValues() const
Definition: arrayndalgo.h:887
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:116
const ArrayND< ArrType > * yarr_
Definition: arrayndalgo.h:376
SumType shift_
Definition: arrayndalgo.h:380
Parallel task for computing the element wise operations of one array and optionally a second input ar...
Definition: arrayndalgo.h:245
#define mGlobal(module)
Definition: commondefs.h:160
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:2100
const ValueSeries< T > * getStorage() const
Definition: arraynd.h:42
#define mCast(tp, v)
Definition: commondefs.h:120
Tapers the N-dimentional ArrayND with a windowFunction.
Definition: arrayndalgo.h:870
bool noudf_
Definition: arrayndalgo.h:224
void setOrder(PolyTrend::Order t)
Definition: arrayndalgo.h:1625
bool doFinish(bool success)
Definition: arrayndalgo.h:203
uiString message() const
Definition: arrayndalgo.h:1366
uiString message() const
Definition: arrayndalgo.h:264
#define od_int64
Definition: plftypes.h:34
bool dosqrtsum_
Definition: arrayndalgo.h:49
Definition: arrayndalgo.h:1957
bool set(const TypeSet< Coord > &, const IDXABLE &valuelistj)
Definition: arrayndalgo.h:1663
virtual void set(int, T)=0
const TrcKeyZSampling & tkzsin_
Definition: arrayndalgo.h:1598
Order getOrder() const
Definition: arrayndalgo.h:1632
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1415
Threads::Lock writelock_
Definition: arrayndalgo.h:226
double f11_
Definition: arrayndalgo.h:1646
void quickAddToNrDone(int64_t loopidx)
bool removeTrend(const ArrayND< ArrType > &in, ArrayND< ArrType > &out)
Fills an ArrayND with a de-trended version of another.
Definition: arrayndalgo.h:743
Implementation of ArrayNDInfo.
Definition: arrayndinfo.h:217
Implementation of Array2D.
Definition: arrayndimpl.h:101
const od_int64 totalnr_
Definition: arrayndalgo.h:2261
int nrSteps() const
Definition: ranges.h:758
bool doPrepare(int nrthreads)
Definition: arrayndalgo.h:112
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:21
double f0_
Definition: arrayndalgo.h:1643
Threads::Mutex lck_
Definition: arrayndalgo.h:1883
TrcKeySampling commontks_
Definition: arrayndalgo.h:1468
OperType yfact_
Definition: arrayndalgo.h:379
BinID atIndex(int i0, int i1) const
RetType getResidual(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, bool noudf, bool parallel)
returns the residual differences of two arrays
Definition: arrayndalgo.h:550
float * window_
Definition: arrayndalgo.h:948
bool Array3DCopy(Array3D< T > &dest, const Array3D< T > &src, int p0, int p1, int p2, bool srcperiodic=false)
Definition: arrayndalgo.h:1168
virtual bool getArrayPos(uint64_t, int *) const
void limitTo(const BasicInterval< X > &i)
Definition: ranges.h:63
Definition: uistring.h:88
T atIndex(int) const
Definition: ranges.h:679
ValueSeries of offsets.
Definition: valseriesimpl.h:22
virtual void setND(const int *, T)=0
mODTextTranslationClass(ArrayUdfValRestorer) public
Definition: arrayndalgo.h:1898
double f1_
Definition: arrayndalgo.h:1644
int lineIdx(Pos::LineID) const
Definition: trckeysampling.h:216
od_uint64 sz_
Definition: arrayndalgo.h:372
BufferString windowtypename_
Definition: arrayndalgo.h:952
ParallelTask(const char *nm=0)
void setReplacementValue(T val)
Definition: arrayndalgo.h:1764
unsigned int Abs(unsigned int i)
Definition: math2.h:78
RetType getSumX2MY2(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, bool noudf, bool parallel)
returns the sum of subtracted squarred amplitudes of two arrays
Definition: arrayndalgo.h:610
virtual int get1DDim() const
Definition: arraynd.h:354
od_int64 nrIterations() const
Definition: arrayndalgo.h:108
#define mDeclareEnumUtils(enm)
Some utilities surrounding the often needed enum <-> string table.
Definition: enums.h:188
virtual void set(int, int, T)=0
const ArrayND< T > & data_
Definition: arrayndalgo.h:2255
FixedString None()
Definition: keystrs.h:90
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:64
mODTextTranslationClass(CumArrOperExec)
const TrcKeySampling & tks_
Definition: arrayndalgo.h:2035
ArrayND< T > & outp_
Definition: arrayndalgo.h:1949
static uiString sInline(int num=1)
Definition: uistrings.h:347
Definition: arrayndalgo.h:29
bool Array2DPaste(Array2D< T > &dest, const Array2D< T > &src, int p0, int p1, bool destperiodic=false)
Definition: arrayndalgo.h:1254
od_int64 nrIterations() const
Definition: arrayndalgo.h:278
bool doPrepare(int)
Definition: arrayndalgo.h:2084
mODTextTranslationClass(ArrayUdfValReplacer) public
Definition: arrayndalgo.h:1733
virtual int getSize(int dim) const =0
const ArrayOperExecSetup & setup_
Definition: arrayndalgo.h:371
Transfers the common samples from one 3D array to another.
Definition: arrayndalgo.h:1476
bool dosqout_
Definition: arrayndalgo.h:46
RetType getSum() const
Definition: arrayndalgo.h:104
bool doadd_
Definition: arrayndalgo.h:44
uiString message() const
Definition: arrayndalgo.h:1757
RetType getSumXMY2(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, bool noudf, bool parallel)
returns the sum of squarred differences of two arrays
Definition: arrayndalgo.h:571
#define mNINT32(x)
Definition: commondefs.h:48
const T * getData() const
Definition: arraynd.h:51
const TrcKeySampling & tksin_
Definition: arrayndalgo.h:1466
const Array2D< T > & in_
Definition: arrayndalgo.h:1465
virtual T getND(const int *) const =0
OperType xfact_
Definition: arrayndalgo.h:231
WindowType
Definition: arrayndalgo.h:873
uiString message() const
Definition: arrayndalgo.h:1971
virtual const Array3DInfo & info() const =0
bool apply(ArrayND< Type > *in, ArrayND< Type > *out_=0) const
Definition: arrayndalgo.h:895
float getParamVal() const
Definition: arrayndalgo.h:886
bool doPrepare(int)
Definition: arrayndalgo.h:282
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:127
bool operator==(const NamedCallBacker &oth) const
Definition: namedobj.h:58
Horizontal sampling (inline and crossline range and steps).
Definition: trckeysampling.h:25
RetType getSumProduct(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, bool noudf, bool parallel)
returns the sum of product amplitudes between two vectors
Definition: arrayndalgo.h:481
Array3D< T > & out_
Definition: arrayndalgo.h:1603
od_uint64 sz_
Definition: arrayndalgo.h:223
SumType yshift_
Definition: arrayndalgo.h:230
int nrTrcs() const
RetType getNorm2(const ArrayND< ArrType > &in, bool noudf, bool parallel)
return the Norm-2 of the array
Definition: arrayndalgo.h:516
static uiString sPosFinished()
Definition: paralleltask.h:87
Definition: arrayndalgo.h:26
float paramval_
Definition: arrayndalgo.h:953
RetType getRMS(const ArrayND< ArrType > &in, bool noudf, bool parallel)
return the RMS of the array
Definition: arrayndalgo.h:533
bool ArrayNDPaste(ArrayND< T > &dest, const ArrayND< T > &src, const TypeSet< int > &pastepos, bool destperiodic=false)
Definition: arrayndalgo.h:1212
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
double f22_
Definition: arrayndalgo.h:1648
Hor+Vert sampling in 3D surveys.
Definition: trckeyzsampling.h:32
Interface to a series of values.
Definition: odmemory.h:15
const ArrayND< ArrType > * yarr_
Definition: arrayndalgo.h:228
bool isDefined() const
Definition: geometry.h:477
od_uint64 count_
Definition: arrayndalgo.h:234
bool setGlobalPos(int64_t)
Definition: arraynd.h:260
void setSampling(const TrcKeySampling &tks, const PosInfo::CubeData *trcssampling)
Definition: arrayndalgo.h:1766
int trcIdx(Pos::TraceID) const
Definition: trckeysampling.h:224
double f12_
Definition: arrayndalgo.h:1647
const ArrayND< ArrType > & xarr_
Definition: arrayndalgo.h:375
ArrayND< int > & tailmute_
Definition: arrayndalgo.h:2259
const TrcKeyZSampling & tkzsout_
Definition: arrayndalgo.h:1599
mODTextTranslationClass(Array3DCopier) public
Definition: arrayndalgo.h:1477
bool ArrayNDCopy(ArrayND< T > &dest, const ArrayND< T > &src, const TypeSet< int > &copypos, bool srcperiodic=false)
Definition: arrayndalgo.h:1129
T x_
Definition: geometry.h:80
bool doPrepare(int)
Definition: arrayndalgo.h:1383
virtual void set(int, int, int, T)=0
void memValueSet(T *, T, int64_t, TaskRunner *taskrun=0)
Definition: odmemory.h:501
bool Array3DPaste(Array3D< T > &dest, const Array3D< T > &src, int p0, int p1, int p2, bool destperiodic=false)
Definition: arrayndalgo.h:1292
SumType xshift_
Definition: arrayndalgo.h:229
const TrcKeySampling * tks_
Definition: arrayndalgo.h:2256
OperType yfact_
Definition: arrayndalgo.h:232
mDeclareEnumUtils(Order) static const char *sKeyOrder()
Definition: arrayndalgo.h:1621
bool removeBias(const ArrayND< ArrType > &in, ArrayND< ArrType > &out, bool noudf, bool parallel)
Fills an ArrayND with an unbiased version of another.
Definition: arrayndalgo.h:630
bool doPrepare(int)
Definition: arrayndalgo.h:1779
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:123
const ArrayND< ArrType > & xarr_
Definition: arrayndalgo.h:227
void setOffset(int64_t no)
Definition: valseriesimpl.h:217
bool doWork(od_int64 start, od_int64 stop, int threadidx)
Definition: arrayndalgo.h:123
virtual bool executeParallel(bool parallel)
void add(xT x, yT y)
Definition: mathfunc.h:404
const PosInfo::CubeData * trcssampling_
Definition: arrayndalgo.h:2257
ArrayND< int > & topmute_
Definition: arrayndalgo.h:2258
virtual T get(int p0, int p1, int p2) const =0
OperType xfact_
Definition: arrayndalgo.h:378
ArrayND< T > & inp_
Definition: arrayndalgo.h:1877
void setShift(SumType shift)
Definition: arrayndalgo.h:274
#define mGetInfo()
Definition: arrayndalgo.h:1500
virtual void setValue(int64_t, T)
Definition: valseries.h:40
const TrcKeySampling & tksout_
Definition: arrayndalgo.h:1467
LargeValVec< od_uint64 > * undefidxs_
Definition: arrayndalgo.h:1879
StepInterval< int > lineRange() const
Type
Definition: angles.h:25
#define od_uint64
Definition: plftypes.h:35
Coord posc_
Definition: arrayndalgo.h:1649
void apply(const Coord &pos, bool dir, T &) const
Definition: arrayndalgo.h:1694
Iterates through all samples in an ArrayND.
Definition: arraynd.h:175
void setValue(int idx, float val)
Definition: arrayndalgo.h:889
void getProduct(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, ArrayND< ArrType > &out, bool noudf, bool parallel)
computes the product array between two arrays
Definition: arrayndalgo.h:466
uiString message() const
Definition: arrayndalgo.h:1908
bool isFullyRectAndReg() const
const ArrayOperExecSetup & setup_
Definition: arrayndalgo.h:222
CumArrOperExec(const ArrayND< ArrType > &xvals, bool noudf, const ArrayOperExecSetup &setup)
Definition: arrayndalgo.h:66
IdxType & crl()
Definition: posidxpair.h:46
bool includes(const TrcKeySampling &, bool ignoresteps=false) const
bool hasUndefs(const ArrayND< fT > &in)
Returns whether there are undefs in the Array.
Definition: arrayndalgo.h:783
bool interpUdf(Array1D< fT > &in, typename BendPointBasedMathFunction< fT, fT >::InterpolType ipoltyp=BendPointBasedMathFunction< fT, fT >::Poly)
Definition: arrayndalgo.h:833
#define mPlural
Definition: uistrings.h:17
bool noudf_
Definition: arrayndalgo.h:373
size_type size() const
Definition: typeset.h:263
od_int64 nrIterations() const
Definition: arrayndalgo.h:1914
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
void setYVals(const ArrayND< ArrType > &yvals)
Definition: arrayndalgo.h:84
T dePeriodize(T val, T period)
Definition: periodicvalue.h:24
bool donormalizesum_
Definition: arrayndalgo.h:48
RetType getSumX2PY2(const ArrayND< ArrType > &in1, const ArrayND< ArrType > &in2, bool noudf, bool parallel)
returns the sum of summed squarred amplitudes of two arrays
Definition: arrayndalgo.h:591
T Array3DInterpolate(const Array3D< T > &array, float p0, float p1, float p2, bool posperiodic=false)
Definition: arrayndalgo.h:960
bool doPrepare(int)
Definition: arrayndalgo.h:1506
bool resize(const char *, int64_t)
Definition: arrayndalgo.h:874
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:28
Is a lock that allows a thread to have exlusive rights to something.
Definition: thread.h:43
uiString nrDoneText() const
Definition: arrayndalgo.h:1910
virtual const Array1DInfo & info() const =0
Definition: arrayndalgo.h:1897
const int * getPos() const
Definition: arraynd.h:187
bool getInterceptGradient(const ArrayND< ArrType > &iny, const ArrayND< ArrType > *inx_, OperType &intercept, OperType &gradient, bool parallel)
returns the intercept and gradient of two arrays
Definition: arrayndalgo.h:685
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1918
virtual T get(int) const =0
void setScaler(OperType scaler, bool forx=true)
Definition: arrayndalgo.h:96
Implementation of Array2DInfo.
Definition: arrayndinfo.h:164
int64_t totalNr() const
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:293
uiString nrDoneText() const
Definition: arrayndalgo.h:1973
const LargeValVec< od_uint64 > & undefidxs_
Definition: arrayndalgo.h:1948
void setScaler(OperType scaler, bool forx=true)
Definition: arrayndalgo.h:267
ArrOperExec(const ArrayND< ArrType > &xvals, const ArrayND< ArrType > *yvals, bool noudf, const ArrayOperExecSetup &setup, ArrayND< ArrType > &outvals)
Definition: arrayndalgo.h:248
Order order_
Definition: arrayndalgo.h:1642
Parallel task for computing the sum of element wise operations of one array and optionally a second i...
Definition: arrayndalgo.h:63
const PosInfo::CubeData & trcssampling_
Definition: arrayndalgo.h:2034
void convertUndefinedIndexList(const TrcKeyZSampling &tkzsin, const TrcKeyZSampling &tkzsout, LargeValVec< od_uint64 > &)
uiString nrDoneText() const
Definition: arrayndalgo.h:263
uiString nrDoneText() const
Definition: arrayndalgo.h:1492
T start
Definition: ranges.h:90
od_int64 nrIterations() const
Definition: arrayndalgo.h:2080
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1527
#define mFillTrendXArray()
Definition: arrayndalgo.h:656
mODTextTranslationClass(MuteArrayExtracter) public
Definition: arrayndalgo.h:2049
uiString nrDoneText() const
Definition: arrayndalgo.h:1762
bool canCopyAll() const
Definition: arrayndalgo.h:1377
od_int64 nrIterations() const
Definition: arrayndalgo.h:1496
bool getInterSection(const TrcKeySampling &, TrcKeySampling &) const
Returns false if intersection is empty.
const Array3D< T > & in_
Definition: arrayndalgo.h:1602
od_int64 nrIterations() const
Definition: arrayndalgo.h:1370
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1981
virtual const ArrayNDInfo & info() const =0
const od_int64 totalnr_
Definition: arrayndalgo.h:1600
MathFunction based on bend points.
Definition: mathfunc.h:149
void setSampling(const TrcKeySampling &tks, const PosInfo::CubeData *trcssampling)
Definition: arrayndalgo.h:2071
static uiString phrJoinStrings(const uiString &a, const uiString &b)
"
const PosInfo::CubeData * trcssampling_
Definition: arrayndalgo.h:1881
uiString uiNrDoneText() const
Definition: arrayndalgo.h:2069
Implementation of Array1D.
Definition: arrayndimpl.h:51
ArrayUdfValReplacer(Array3D< T > &inp, LargeValVec< od_uint64 > *undefidxs)
Definition: arrayndalgo.h:1746
mODTextTranslationClass(Array3DUdfTrcRestorer) public
Definition: arrayndalgo.h:1958
#define mClass(module)
Definition: commondefs.h:161
virtual const Array2DInfo & info() const =0
2D point or vector class.
Definition: commontypes.h:58
RetType getSumSq(const ArrayND< ArrType > &in, bool noudf, bool parallel)
returns the sum of squarred amplitudes of the array
Definition: arrayndalgo.h:500
Order
Definition: arrayndalgo.h:1620
bool dosqinp_
Definition: arrayndalgo.h:45
void setShift(SumType shift, bool forx=true)
Definition: arrayndalgo.h:87
Position info for an entire 3D cube. The LineData&#39;s are not sorted.
Definition: posinfo.h:96
ArrayNDInfoImpl size_
Definition: arrayndalgo.h:949
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:149
const od_int64 totalnr_
Definition: arrayndalgo.h:1882
od_int64 nrIterations() const
Definition: arrayndalgo.h:1775
T y_
Definition: geometry.h:81
RetType getAverage(const ArrayND< ArrType > &in, bool noudf, bool parallel)
returns the average amplitude of the array
Definition: arrayndalgo.h:405
T replval_
Definition: arrayndalgo.h:1878
float Sqrt(float)
const od_int64 totalnr_
Definition: arrayndalgo.h:1950
Polynomial trend with order 0 (mean), 1 (linear) or 2 (parabolic) The trend is derived from a set of ...
Definition: arrayndalgo.h:1613
yT getValue(xT x) const
Definition: mathfunc.h:166
Transfers the common samples from one 2D array to another.
Definition: arrayndalgo.h:1339
od_int64 nrIterations() const
Definition: arrayndalgo.h:1977
Array3D< T > & outp_
Definition: arrayndalgo.h:2036
uiString message() const
Definition: arrayndalgo.h:82
uiString nrDoneText() const
Definition: arrayndalgo.h:1360
ArrayND< ArrType > & outarr_
Definition: arrayndalgo.h:377
uiString uiMessage() const
Definition: arrayndalgo.h:2064
TrcKeySampling hsamp_
Definition: trckeyzsampling.h:57
Definition: arrayndalgo.h:2048
BinID start_
Definition: trckeysampling.h:129

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017