OpendTect  6.6
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  RCS: $Id$
10 ________________________________________________________________________
11 
12 
13 @$*/
14 
15 #include "algomod.h"
16 #include "arrayndimpl.h"
17 #include "coord.h"
18 #include "enums.h"
19 #include "arrayndslice.h"
20 #include "mathfunc.h"
21 #include "periodicvalue.h"
22 #include "posinfo.h"
23 #include "trckeyzsampling.h"
24 #include "uistrings.h"
25 
26 
27 #define mComputeTrendAandB( sz ) { \
28  aval = mCast(T,( (fT)sz * crosssum - sum * sumindexes ) / \
29  ( (fT)sz * sumsqidx - sumindexes * sumindexes ) );\
30  bval = mCast(T,( sum * sumsqidx - sumindexes * crosssum ) / \
31  ( (fT)sz * sumsqidx - sumindexes * sumindexes ) ); }
32 
33 
36 template <class T, class fT>
37 inline bool removeLinPart( const ArrayND<T>& in_, ArrayND<T>* out, bool trend )
38 {
39  ArrayND<T>& out_ = out ? *out : const_cast<ArrayND<T>&>(in_);
40  if ( out && in_.info() != out_.info() )
41  return false;
42 
43  T avg = 0;
44  T sum = 0;
45  fT sumindexes = 0;
46  fT sumsqidx = 0;
47  T crosssum = 0;
48  T aval = mUdf(T);
49  T bval = mUdf(T);
50 
51  const od_int64 sz = in_.info().getTotalSz();
52 
53  const T* inpptr = in_.getData();
54  T* outptr = out_.getData();
55 
56  if ( inpptr && outptr )
57  {
58  int count = 0;
59  for ( int idx=0; idx<sz; idx++ )
60  {
61  const T value = inpptr[idx];
62  if ( mIsUdf(value) )
63  continue;
64 
65  sum += inpptr[idx];
66  count++;
67  if ( !trend )
68  continue;
69 
70  const fT fidx = mCast(fT,idx);
71  sumindexes += fidx;
72  sumsqidx += fidx * fidx;
73  crosssum += inpptr[idx] * fidx;
74  }
75 
76  if ( count <= 1 )
77  return false;
78 
79  if ( trend )
80  mComputeTrendAandB(count)
81  else
82  avg = sum / (fT)count;
83 
84  for ( int idx=0; idx<sz; idx++ )
85  {
86  const T value = inpptr[idx];
87  outptr[idx] = mIsUdf(value) ? mUdf(T)
88  : (trend ? value - (aval*(fT)idx+bval)
89  : value - avg);
90  }
91  }
92  else
93  {
94  ArrayNDIter iter( in_.info() );
95  int index = 0, count = 0;
96 
97  do
98  {
99  const T value = in_.getND( iter.getPos() );
100  index++;
101  if ( mIsUdf(value) )
102  continue;
103 
104  sum += value;
105  count++;
106  if ( !trend )
107  continue;
108 
109  sumindexes += index;
110  sumsqidx += index * index;
111  crosssum += value * (fT)index;
112  } while ( iter.next() );
113 
114  iter.reset();
115  if ( count <= 1 )
116  return false;
117 
118  if ( trend )
119  mComputeTrendAandB(count)
120  else
121  avg = sum / (fT)count;
122 
123  index = 0;
124  do
125  {
126  const T inpval = in_.getND( iter.getPos() );
127  const T outval = mIsUdf(inpval) ? mUdf(T)
128  : (trend ? inpval - avg-(aval*(fT)index+bval)
129  : inpval - avg);
130  out_.setND(iter.getPos(), outval );
131  index++;
132  } while ( iter.next() );
133  }
134 
135  return true;
136 }
137 
138 
141 template <class T, class fT>
142 inline bool removeBias( ArrayND<T>& inout )
143 {
144  return removeLinPart<T,fT>( inout, 0, false );
145 }
146 
149 template <class T, class fT>
150 inline bool removeBias( const ArrayND<T>& in, ArrayND<T>& out )
151 {
152  return removeLinPart<T,fT>( in, &out, false );
153 }
154 
157 template <class T, class fT>
158 inline bool removeTrend( ArrayND<T>& inout )
159 {
160  return removeLinPart<T,fT>( inout, 0, true );
161 }
162 
165 template <class T, class fT>
166 inline bool removeTrend( const ArrayND<T>& in, ArrayND<T>& out )
167 {
168  return removeLinPart<T,fT>( in, &out, true );
169 }
170 
171 
175 template <class T>
176 inline T getAverage( const ArrayND<T>& in )
177 {
178  const int sz = in.info().getTotalSz();
179  if ( sz < 1 )
180  return mUdf(T);
181 
182  T sum = 0; int count = 0;
183  for ( int idx=0; idx<sz; idx++ )
184  {
185  const T val = in.get( idx );
186  if ( !mIsUdf(val) )
187  { sum += val; count++; }
188  }
189 
190  if ( count == 0 )
191  return mUdf(T);
192 
193  return sum / count;
194 }
195 
196 
200 template <class T>
201 inline T getMax( const ArrayND<T>& in )
202 {
203  const int sz = in.info().getTotalSz();
204  const T* data = in.getData();
205  if ( sz < 1 || !data )
206  return mUdf(T);
207 
208  T maxval = -mUdf(T);
209  for ( int idx=0; idx<sz; idx++ )
210  {
211  const T val = data[idx];
212  if ( !mIsUdf(val) && val > maxval )
213  maxval = val;
214  }
215 
216  return mIsUdf(-maxval) ? mUdf(T) : maxval;
217 }
218 
219 
223 template <class T>
224 inline T getMin( const ArrayND<T>& in )
225 {
226  const int sz = in.info().getTotalSz();
227  const T* data = in.getData();
228  if ( sz < 1 || !data )
229  return mUdf(T);
230 
231  T minval = mUdf(T);
232  for ( int idx=0; idx<sz; idx++ )
233  {
234  const T val = data[idx];
235  if ( !mIsUdf(val) && val < minval )
236  minval = val;
237  }
238 
239  return mIsUdf(minval) ? mUdf(T) : minval;
240 }
241 
242 
245 template <class fT>
246 inline bool hasUndefs( const Array1D<fT>& in )
247 {
248  const int sz = in.info().getSize(0);
249  for ( int idx=0; idx<sz; idx++ )
250  {
251  const fT val = in.get( idx );
252  if ( mIsUdf(val) )
253  return true;
254  }
255 
256  return false;
257 }
258 
259 
260 template <class fT>
261 inline bool hasUndefs( const ArrayND<fT>& in )
262 {
263  const fT* vals = in.getData();
264  typedef ArrayNDInfo::total_size_type total_size_type;
265  const total_size_type sz = in.totalSize();
266  if ( vals )
267  {
268  for ( total_size_type idx=0; idx<sz; idx++ )
269  {
270  if ( mIsUdf(vals[idx]) )
271  return true;
272  }
273 
274  return false;
275  }
276 
277  const ValueSeries<fT>* stor = in.getStorage();
278  if ( stor )
279  {
280  for ( total_size_type idx=0; idx<sz; idx++ )
281  {
282  if ( mIsUdf(stor->value(idx)) )
283  return true;
284  }
285 
286  return false;
287  }
288 
289  ArrayNDIter iter( in.info() );
290  do
291  {
292  if ( mIsUdf(in.getND(iter.getPos())) )
293  return true;
294 
295  } while( iter.next() );
296 
297  return false;
298 }
299 
310 template <class fT>
311 inline bool interpUdf( Array1D<fT>& in,
314 {
315  if ( !hasUndefs(in) )
316  return false;
317 
318  BendPointBasedMathFunction<fT,fT> data( ipoltyp );
319  const int sz = in.info().getSize(0);
320  for ( int idx=0; idx<sz; idx++ )
321  {
322  const fT val = in.get( idx );
323  if ( !mIsUdf(val) )
324  data.add( mCast(fT,idx), val );
325  }
326 
327  for ( int idx=0; idx<sz; idx++ )
328  {
329  const fT val = in.get( idx );
330  if ( mIsUdf(val) )
331  in.set( idx, data.getValue( mCast(fT,idx) ) );
332  }
333 
334  return true;
335 }
336 
337 
349 {
350 public:
351  enum WindowType { Box, Hamming, Hanning, Blackman, Bartlett,
352  CosTaper5, CosTaper10, CosTaper20 };
354 
355  ArrayNDWindow(const ArrayNDInfo&,bool rectangular,
356  WindowType=Hamming);
357  ArrayNDWindow(const ArrayNDInfo&,bool rectangular,
358  const char* winnm,
359  float paramval=mUdf(float));
361 
362  bool isOK() const { return window_; }
363 
364  float getParamVal() const { return paramval_; }
365  float* getValues() const { return window_; }
366 
367  void setValue(int idx,float val) { window_[idx]=val; }
369  bool setType(const char*,float paramval=mUdf(float));
370 
371  bool resize(const ArrayNDInfo&);
372 
373  template <class Type> bool apply( ArrayND<Type>* in,
374  ArrayND<Type>* out_=0 ) const
375  {
376  ArrayND<Type>* out = out_ ? out_ : in;
377 
378  if ( out_ && in->info() != out_->info() ) return false;
379  if ( in->info() != size_ ) return false;
380 
381  const od_int64 totalsz = size_.getTotalSz();
382 
383  Type* indata = in->getData();
384  Type* outdata = out->getData();
385  if ( indata && outdata )
386  {
387  for ( unsigned long idx = 0; idx<totalsz; idx++ )
388  {
389  Type inval = indata[idx];
390  outdata[idx] = mIsUdf( inval ) ? inval : inval * window_[idx];
391  }
392  }
393  else
394  {
395  const ValueSeries<Type>* instorage = in->getStorage();
396  ValueSeries<Type>* outstorage = out->getStorage();
397 
398  if ( instorage && outstorage )
399  {
400  for ( unsigned long idx = 0; idx < totalsz; idx++ )
401  {
402  Type inval = instorage->value(idx);
403  outstorage->setValue(idx,
404  mIsUdf( inval ) ? inval : inval * window_[idx] );
405  }
406  }
407  else
408  {
409  ArrayNDIter iter( size_ );
410  int idx = 0;
411  do
412  {
413  Type inval = in->getND(iter.getPos());
414  out->setND( iter.getPos(),
415  mIsUdf( inval ) ? inval : inval * window_[idx] );
416  idx++;
417 
418  } while ( iter.next() );
419  }
420  }
421 
422  return true;
423  }
424 
425 protected:
426 
427  float* window_;
430 
432  float paramval_;
433 
434  bool buildWindow(const char* winnm,float pval);
435 };
436 
437 
438 template<class T>
439 inline T Array3DInterpolate( const Array3D<T>& array,
440  float p0, float p1, float p2,
441  bool posperiodic = false )
442 {
443  const Array3DInfo& size = array.info();
444  int intpos0 = mNINT32( p0 );
445  float dist0 = p0 - intpos0;
446  int prevpos0 = intpos0;
447  if ( dist0 < 0 )
448  {
449  prevpos0--;
450  dist0++;
451  }
452  if ( posperiodic ) prevpos0 = dePeriodize( prevpos0, size.getSize(0) );
453 
454  int intpos1 = mNINT32( p1 );
455  float dist1 = p1 - intpos1;
456  int prevpos1 = intpos1;
457  if ( dist1 < 0 )
458  {
459  prevpos1--;
460  dist1++;
461  }
462  if ( posperiodic ) prevpos1 = dePeriodize( prevpos1, size.getSize(1) );
463 
464  int intpos2 = mNINT32( p2 );
465  float dist2 = p2 - intpos2;
466  int prevpos2 = intpos2;
467  if ( dist2 < 0 )
468  {
469  prevpos2--;
470  dist2++;
471  }
472 
473  if ( posperiodic ) prevpos2 = dePeriodize( prevpos2, size.getSize(2) );
474 
475  if ( !posperiodic && ( prevpos0 < 0 || prevpos0 > size.getSize(0) -2 ||
476  prevpos1 < 0 || prevpos1 > size.getSize(1) -2 ||
477  prevpos2 < 0 || prevpos2 > size.getSize(2) -2 ))
478  return mUdf(T);
479 
480  if ( !posperiodic && ( !prevpos0 || prevpos0 > size.getSize(0) -3 ||
481  !prevpos1 || prevpos1 > size.getSize(1) -3 ||
482  !prevpos2 || prevpos2 > size.getSize(2) -3 ))
483  {
484  return linearInterpolate3D(
485  array.get( prevpos0 , prevpos1 , prevpos2 ),
486  array.get( prevpos0 , prevpos1 , prevpos2+1),
487  array.get( prevpos0 , prevpos1+1, prevpos2 ),
488  array.get( prevpos0 , prevpos1+1, prevpos2+1),
489  array.get( prevpos0+1, prevpos1 , prevpos2 ),
490  array.get( prevpos0+1, prevpos1 , prevpos2+1),
491  array.get( prevpos0+1, prevpos1+1, prevpos2 ),
492  array.get( prevpos0+1, prevpos1+1, prevpos2+1),
493  dist0, dist1, dist2 );
494  }
495 
496  int firstpos0 = prevpos0 - 1;
497  int nextpos0 = prevpos0 + 1;
498  int lastpos0 = prevpos0 + 2;
499 
500  if ( posperiodic ) firstpos0 = dePeriodize( firstpos0, size.getSize(0) );
501  if ( posperiodic ) nextpos0 = dePeriodize( nextpos0, size.getSize(0) );
502  if ( posperiodic ) lastpos0 = dePeriodize( lastpos0, size.getSize(0) );
503 
504  int firstpos1 = prevpos1 - 1;
505  int nextpos1 = prevpos1 + 1;
506  int lastpos1 = prevpos1 + 2;
507 
508  if ( posperiodic ) firstpos1 = dePeriodize( firstpos1, size.getSize(1) );
509  if ( posperiodic ) nextpos1 = dePeriodize( nextpos1, size.getSize(1) );
510  if ( posperiodic ) lastpos1 = dePeriodize( lastpos1, size.getSize(1) );
511 
512  int firstpos2 = prevpos2 - 1;
513  int nextpos2 = prevpos2 + 1;
514  int lastpos2 = prevpos2 + 2;
515 
516  if ( posperiodic ) firstpos2 = dePeriodize( firstpos2, size.getSize(2) );
517  if ( posperiodic ) nextpos2 = dePeriodize( nextpos2, size.getSize(2) );
518  if ( posperiodic ) lastpos2 = dePeriodize( lastpos2, size.getSize(2) );
519 
520  return polyInterpolate3D (
521  array.get( firstpos0 , firstpos1 , firstpos2 ),
522  array.get( firstpos0 , firstpos1 , prevpos2 ),
523  array.get( firstpos0 , firstpos1 , nextpos2 ),
524  array.get( firstpos0 , firstpos1 , lastpos2 ),
525 
526  array.get( firstpos0 , prevpos1 , firstpos2 ),
527  array.get( firstpos0 , prevpos1 , prevpos2 ),
528  array.get( firstpos0 , prevpos1 , nextpos2 ),
529  array.get( firstpos0 , prevpos1 , lastpos2 ),
530 
531  array.get( firstpos0 , nextpos1 , firstpos2 ),
532  array.get( firstpos0 , nextpos1 , prevpos2 ),
533  array.get( firstpos0 , nextpos1 , nextpos2 ),
534  array.get( firstpos0 , nextpos1 , lastpos2 ),
535 
536  array.get( firstpos0 , lastpos1 , firstpos2 ),
537  array.get( firstpos0 , lastpos1 , prevpos2 ),
538  array.get( firstpos0 , lastpos1 , nextpos2 ),
539  array.get( firstpos0 , lastpos1 , lastpos2 ),
540 
541 
542  array.get( prevpos0 , firstpos1 , firstpos2 ),
543  array.get( prevpos0 , firstpos1 , prevpos2 ),
544  array.get( prevpos0 , firstpos1 , nextpos2 ),
545  array.get( prevpos0 , firstpos1 , lastpos2 ),
546 
547  array.get( prevpos0 , prevpos1 , firstpos2 ),
548  array.get( prevpos0 , prevpos1 , prevpos2 ),
549  array.get( prevpos0 , prevpos1 , nextpos2 ),
550  array.get( prevpos0 , prevpos1 , lastpos2 ),
551 
552  array.get( prevpos0 , nextpos1 , firstpos2 ),
553  array.get( prevpos0 , nextpos1 , prevpos2 ),
554  array.get( prevpos0 , nextpos1 , nextpos2 ),
555  array.get( prevpos0 , nextpos1 , lastpos2 ),
556 
557  array.get( prevpos0 , lastpos1 , firstpos2 ),
558  array.get( prevpos0 , lastpos1 , prevpos2 ),
559  array.get( prevpos0 , lastpos1 , nextpos2 ),
560  array.get( prevpos0 , lastpos1 , lastpos2 ),
561 
562 
563  array.get( nextpos0 , firstpos1 , firstpos2 ),
564  array.get( nextpos0 , firstpos1 , prevpos2 ),
565  array.get( nextpos0 , firstpos1 , nextpos2 ),
566  array.get( nextpos0 , firstpos1 , lastpos2 ),
567 
568  array.get( nextpos0 , prevpos1 , firstpos2 ),
569  array.get( nextpos0 , prevpos1 , prevpos2 ),
570  array.get( nextpos0 , prevpos1 , nextpos2 ),
571  array.get( nextpos0 , prevpos1 , lastpos2 ),
572 
573  array.get( nextpos0 , nextpos1 , firstpos2 ),
574  array.get( nextpos0 , nextpos1 , prevpos2 ),
575  array.get( nextpos0 , nextpos1 , nextpos2 ),
576  array.get( nextpos0 , nextpos1 , lastpos2 ),
577 
578  array.get( nextpos0 , lastpos1 , firstpos2 ),
579  array.get( nextpos0 , lastpos1 , prevpos2 ),
580  array.get( nextpos0 , lastpos1 , nextpos2 ),
581  array.get( nextpos0 , lastpos1 , lastpos2 ),
582 
583 
584  array.get( lastpos0 , firstpos1 , firstpos2 ),
585  array.get( lastpos0 , firstpos1 , prevpos2 ),
586  array.get( lastpos0 , firstpos1 , nextpos2 ),
587  array.get( lastpos0 , firstpos1 , lastpos2 ),
588 
589  array.get( lastpos0 , prevpos1 , firstpos2 ),
590  array.get( lastpos0 , prevpos1 , prevpos2 ),
591  array.get( lastpos0 , prevpos1 , nextpos2 ),
592  array.get( lastpos0 , prevpos1 , lastpos2 ),
593 
594  array.get( lastpos0 , nextpos1 , firstpos2 ),
595  array.get( lastpos0 , nextpos1 , prevpos2 ),
596  array.get( lastpos0 , nextpos1 , nextpos2 ),
597  array.get( lastpos0 , nextpos1 , lastpos2 ),
598 
599  array.get( lastpos0 , lastpos1 , firstpos2 ),
600  array.get( lastpos0 , lastpos1 , prevpos2 ),
601  array.get( lastpos0 , lastpos1 , nextpos2 ),
602  array.get( lastpos0 , lastpos1 , lastpos2 ),
603  dist0, dist1, dist2 );
604 }
605 
606 
607 template <class T>
608 inline bool ArrayNDCopy( ArrayND<T>& dest, const ArrayND<T>& src,
609  const TypeSet<int>& copypos, bool srcperiodic=false )
610 {
611  const ArrayNDInfo& destsz = dest.info();
612  const ArrayNDInfo& srcsz = src.info();
613 
614  const int ndim = destsz.getNDim();
615  if ( ndim != srcsz.getNDim() || ndim != copypos.size() ) return false;
616 
617  for ( int idx=0; idx<ndim; idx++ )
618  {
619  if ( !srcperiodic &&
620  copypos[idx] + destsz.getSize(idx) > srcsz.getSize(idx) )
621  return false;
622  }
623 
624  ArrayNDIter destposition( destsz );
625  TypeSet<int> srcposition( ndim, 0 );
626 
627  do
628  {
629  for ( int idx=0; idx<ndim; idx++ )
630  {
631  srcposition[idx] = copypos[idx] + destposition[idx];
632  if ( srcperiodic )
633  srcposition[idx] =
634  dePeriodize( srcposition[idx], srcsz.getSize(idx) );
635  }
636 
637  dest.setND( destposition.getPos(), src.get( &srcposition[0] ));
638 
639 
640  } while ( destposition.next() );
641 
642  return true;
643 }
644 
645 
646 template <class T>
647 inline bool Array3DCopy( Array3D<T>& dest, const Array3D<T>& src,
648  int p0, int p1, int p2, bool srcperiodic=false )
649 {
650  const ArrayNDInfo& destsz = dest.info();
651  const ArrayNDInfo& srcsz = src.info();
652 
653  const int destsz0 = destsz.getSize(0);
654  const int destsz1 = destsz.getSize(1);
655  const int destsz2 = destsz.getSize(2);
656 
657  const int srcsz0 = srcsz.getSize(0);
658  const int srcsz1 = srcsz.getSize(1);
659  const int srcsz2 = srcsz.getSize(2);
660 
661  if ( !srcperiodic )
662  {
663  if ( p0 + destsz0 > srcsz0 ||
664  p1 + destsz1 > srcsz1 ||
665  p2 + destsz2 > srcsz2 )
666  return false;
667  }
668 
669  int idx = 0;
670  T* ptr = dest.getData();
671 
672  for ( int id0=0; id0<destsz0; id0++ )
673  {
674  for ( int id1=0; id1<destsz1; id1++ )
675  {
676  for ( int id2=0; id2<destsz2; id2++ )
677  {
678  ptr[idx++] = src.get( dePeriodize(id0 + p0, srcsz0),
679  dePeriodize(id1 + p1, srcsz1),
680  dePeriodize(id2 + p2, srcsz2));
681 
682  }
683  }
684  }
685 
686  return true;
687 }
688 
689 
690 template <class T>
691 inline bool ArrayNDPaste( ArrayND<T>& dest, const ArrayND<T>& src,
692  const TypeSet<int>& pastepos,
693  bool destperiodic=false )
694 {
695  const ArrayNDInfo& destsz = dest.info();
696  const ArrayNDInfo& srcsz = src.info();
697 
698  const int ndim = destsz.getNDim();
699  if ( ndim != srcsz.getNDim() || ndim != pastepos.size() ) return false;
700 
701  for ( int idx=0; idx<ndim; idx++ )
702  {
703  if ( !destperiodic &&
704  pastepos[idx] + srcsz.getSize(idx) > destsz.getSize(idx) )
705  return false;
706  }
707 
708  ArrayNDIter srcposition( srcsz );
709  TypeSet<int> destposition( ndim, 0 );
710 
711  int ptrpos = 0;
712  T* ptr = src.getData();
713 
714  do
715  {
716  for ( int idx=0; idx<ndim; idx++ )
717  {
718  destposition[idx] = pastepos[idx] + srcposition[idx];
719  if ( destperiodic )
720  destposition[idx] =
721  dePeriodize( destposition[idx], destsz.getSize(idx) );
722  }
723 
724  dest( destposition ) = ptr[ptrpos++];
725 
726  } while ( srcposition.next() );
727 
728  return true;
729 }
730 
731 
732 template <class T>
733 inline bool Array2DPaste( Array2D<T>& dest, const Array2D<T>& src,
734  int p0, int p1, bool destperiodic=false )
735 {
736  const ArrayNDInfo& destsz = dest.info();
737  const ArrayNDInfo& srcsz = src.info();
738 
739  const int srcsz0 = srcsz.getSize(0);
740  const int srcsz1 = srcsz.getSize(1);
741 
742  const int destsz0 = destsz.getSize(0);
743  const int destsz1 = destsz.getSize(1);
744 
745  if ( !destperiodic )
746  {
747  if ( p0 + srcsz0 > destsz0 ||
748  p1 + srcsz1 > destsz1 )
749  return false;
750  }
751 
752 
753  int idx = 0;
754  const T* ptr = src.getData();
755 
756  for ( int id0=0; id0<srcsz0; id0++ )
757  {
758  for ( int id1=0; id1<srcsz1; id1++ )
759  {
760  dest.set( dePeriodize( id0 + p0, destsz0),
761  dePeriodize( id1 + p1, destsz1),
762  ptr[idx++]);
763  }
764  }
765 
766  return true;
767 }
768 
769 
770 template <class T>
771 inline bool Array3DPaste( Array3D<T>& dest, const Array3D<T>& src,
772  int p0, int p1, int p2,
773  bool destperiodic=false )
774 {
775  const ArrayNDInfo& destsz = dest.info();
776  const ArrayNDInfo& srcsz = src.info();
777 
778  const int srcsz0 = srcsz.getSize(0);
779  const int srcsz1 = srcsz.getSize(1);
780  const int srcsz2 = srcsz.getSize(2);
781 
782  const int destsz0 = destsz.getSize(0);
783  const int destsz1 = destsz.getSize(1);
784  const int destsz2 = destsz.getSize(2);
785 
786  if ( !destperiodic )
787  {
788  if ( p0 + srcsz0 > destsz0 ||
789  p1 + srcsz1 > destsz1 ||
790  p2 + srcsz2 > destsz2 )
791  return false;
792  }
793 
794 
795  int idx = 0;
796  const T* ptr = src.getData();
797 
798  for ( int id0=0; id0<srcsz0; id0++ )
799  {
800  for ( int id1=0; id1<srcsz1; id1++ )
801  {
802  for ( int id2=0; id2<srcsz2; id2++ )
803  {
804  dest.set( dePeriodize( id0 + p0, destsz0),
805  dePeriodize( id1 + p1, destsz1),
806  dePeriodize( id2 + p2, destsz2), ptr[idx++]);
807  }
808  }
809  }
810 
811  return true;
812 }
813 
814 
817 template <class T>
820 public:
822  const TrcKeySampling& tksin,
823  const TrcKeySampling& tksout,
824  Array2D<T>& out )
825  : in_(in)
826  , tksin_(tksin)
827  , tksout_(tksout)
828  , out_(out)
829  {
830  if ( canCopyAll() )
831  {
832  doPrepare(0);
833  return;
834  }
835 
836  tksin.getInterSection( tksout, commontks_ );
837  }
838 
840  {
843  uiStrings::sDone().toLower() );
844  }
845  uiString uiMessage() const { return tr("Transferring grid data");}
846 
847 protected:
848 
850  {
851  return canCopyAll() ? 0 : commontks_.nrLines();
852  }
853 
854 private:
855 
856  bool canCopyAll() const
857  {
858  return tksout_ == tksin_ && in_.getData() &&
859  ( out_.getData() || out_.getStorage() );
860  }
861 
862  bool doPrepare( int )
863  {
864  if ( in_.info().getSize(0) != tksin_.nrLines() ||
865  in_.info().getSize(1) != tksin_.nrTrcs() )
866  {
867  return false;
868  }
869 
870  if ( out_.info().getSize(0) != tksout_.nrLines() ||
871  out_.info().getSize(1) != tksout_.nrTrcs() )
872  {
874  if ( !outimpl || !outimpl->setSize( tksout_.nrLines(),
875  tksout_.nrTrcs() ) )
876  {
877  return false;
878  }
879 
880  out_.setAll( mUdf(T) );
881  }
882 
883  if ( canCopyAll() )
884  {
885  if ( out_.getData() )
886  in_.getAll( out_.getData() );
887  else if ( out_.getStorage() )
888  in_.getAll( *out_.getStorage() );
889  }
890 
891  return true;
892  }
893 
894  bool doWork( od_int64 start, od_int64 stop, int )
895  {
896  const TrcKeySampling tksin( tksin_ );
897  const TrcKeySampling tksout( tksout_ );
898  const TrcKeySampling tks( commontks_ );
899 
900  const bool usearrayptrs = in_.getData() && out_.getData() &&
901  in_.getStorage() &&
902  out_.getStorage();
903  OffsetValueSeries<T>* invals = !usearrayptrs ? 0 :
904  new OffsetValueSeries<T>( *in_.getStorage(), 0 );
905  OffsetValueSeries<T>* outvals = !usearrayptrs ? 0 :
906  new OffsetValueSeries<T>( *out_.getStorage(), 0 );
907  const int nrcrl = tks.nrTrcs();
908  const od_int64 nrbytes = nrcrl * sizeof(T);
909 
910  const int startcrl = tks.start_.crl();
911  const int startcrlidyin = tksin.trcIdx( startcrl );
912  const int startcrlidyout = tksout.trcIdx( startcrl );
913  for ( int idx=mCast(int,start); idx<=mCast(int,stop); idx++)
914  {
915  const int inl = tks.lineRange().atIndex( idx );
916  const int inlidxin = tksin.lineIdx( inl );
917  const int inlidxout = tksout.lineIdx( inl );
918  if ( usearrayptrs )
919  {
920  invals->setOffset(
921  in_.info().getOffset(inlidxin,startcrlidyin) );
922  outvals->setOffset(
923  out_.info().getOffset(inlidxout,startcrlidyout) );
924  OD::sysMemCopy(outvals->arr(),invals->arr(),
925  nrbytes);
926  continue;
927  }
928  else
929  {
930  for ( int idy=0; idy<nrcrl; idy++ )
931  {
932  const T val =
933  in_.get( inlidxin, startcrlidyin+idy );
934  out_.set( inlidxout, startcrlidyout+idy, val );
935  }
936  }
937  }
938 
939  delete invals;
940  delete outvals;
941 
942  return true;
943  }
944 
945  const Array2D<T>& in_;
950 };
951 
952 
955 template <class T>
958 public:
959  Array3DCopier( const Array3D<T>& in, Array3D<T>& out,
960  const TrcKeyZSampling& tkzsin,
961  const TrcKeyZSampling& tkzsout )
962  : ParallelTask("Array 3D Resizer")
963  , tkzsin_(tkzsin)
964  , tkzsout_(tkzsout)
965  , totalnr_(tkzsout.hsamp_.totalNr())
966  , in_(in)
967  , out_(out)
968  {}
969 
970  uiString uiMessage() const { return tr("Resizing 3D Array"); }
971 
973 
974 protected:
975 
976  od_int64 nrIterations() const { return totalnr_; }
977 
978 private:
979 
980 #define mGetInfo() \
981  const Array3DInfoImpl infoin( tkzsin_.hsamp_.nrLines(), \
982  tkzsin_.hsamp_.nrTrcs(), tkzsin_.nrZ() ); \
983  const Array3DInfoImpl infoout( tkzsout_.hsamp_.nrLines(), \
984  tkzsout_.hsamp_.nrTrcs(), tkzsout_.nrZ() );
985 
986  bool doPrepare( int )
987  {
988  mGetInfo()
989  if ( in_.info() != infoin )
990  return false;
991 
992  if ( out_.info() != infoout && !out_.setInfo(infoout) )
993  return false;
994 
995  if ( tkzsin_.hsamp_.survid_ != tkzsout_.hsamp_.survid_ )
996  return false;
997 
998  if ( !tkzsin_.zsamp_.isCompatible(tkzsout_.zsamp_) )
999  return false; //Not supported
1000 
1001  out_.setAll( mUdf(T) );
1002 
1003  return true;
1004  }
1005 
1006 
1007  bool doWork( od_int64 start, od_int64 stop, int )
1008  {
1009  mGetInfo()
1010  const TrcKeySampling tksin( tkzsin_.hsamp_ );
1011  const TrcKeySampling tksout( tkzsout_.hsamp_ );
1012  const int nrzout = infoout.getSize(2);
1013  StepInterval<float> zrg( tkzsout_.zsamp_ );
1014  zrg.limitTo( tkzsin_.zsamp_ );
1015  const int nrztocopy = zrg.nrSteps() + 1;
1016  const int z0in = tkzsin_.zsamp_.nearestIndex( zrg.start );
1017  const int z0out = tkzsout_.zsamp_.nearestIndex( zrg.start );
1018  const od_int64 nrbytes =
1019  mCast(od_int64,nrztocopy) * sizeof(T);
1020  const T* inptr = in_.getData();
1021  T* outptr = out_.getData();
1022  const ValueSeries<T>* instor = in_.getStorage();
1023  ValueSeries<T>* outstor = out_.getStorage();
1024  const bool hasarrayptr = inptr && outptr;
1025  const bool hasstorage = instor && outstor;
1026  const bool needgetset = !hasarrayptr && !hasstorage;
1027 
1028  const Array2DInfoImpl info2d( infoout.getSize( 0 ),
1029  infoout.getSize( 1 ) );
1030  ArrayNDIter iter( info2d );
1031  iter.setGlobalPos( start );
1032 
1033  const od_int64 offsetout = start * nrzout + z0out;
1034  outptr += offsetout;
1035  od_uint64 validxout = offsetout;
1036 
1037  for ( od_int64 idx=start; idx<=stop; idx++, iter.next(),
1038  outptr+=nrzout, validxout+=nrzout,
1039  quickAddToNrDone(idx) )
1040  {
1041  const int inlidx = iter[0];
1042  const int crlidx = iter[1];
1043  const BinID bid( tksout.atIndex(inlidx,crlidx) );
1044  if ( !tksin.includes(bid) )
1045  continue;
1046 
1047  const int inlidxin = tksin.lineIdx( bid.lineNr() );
1048  const int crlidxin = tksin.trcIdx( bid.trcNr() );
1049  const od_int64 offsetin = needgetset ? 0
1050  : infoin.getOffset( inlidxin, crlidxin, z0in );
1051  if ( hasarrayptr )
1052  {
1053  OD::sysMemCopy( outptr, inptr+offsetin, nrbytes );
1054  }
1055  else if ( hasstorage )
1056  {
1057  for ( int idz=0; idz<nrztocopy; idz++ )
1058  {
1059  outstor->setValue( validxout+idz,
1060  instor->value(offsetin+idz));
1061  }
1062  }
1063  else
1064  {
1065  for ( int idz=0, idzin=z0in; idz<nrztocopy; idz++,
1066  idzin++)
1067  {
1068  const T val =
1069  in_.get( inlidxin, crlidxin, idzin );
1070  out_.set( inlidx, crlidx, idz, val );
1071  }
1072  }
1073  }
1074 
1075  return true;
1076  }
1077 
1081 
1082  const Array3D<T>& in_;
1084 };
1085 
1086 
1095 public:
1097 
1098  bool operator==(const PolyTrend&) const;
1099 
1100  enum Order { None, Order0, Order1, Order2};
1102 
1103  static const char* sKeyOrder() { return "Polynomial Order"; }
1104  static bool getOrder(int nrpoints,Order&,uiString* =0);
1105 
1106  void setOrder( PolyTrend::Order t ) { order_ = t; }
1107  template <class IDXABLE> bool set(const TypeSet<Coord>&,
1108  const IDXABLE& valuelistj);
1113  Order getOrder() const { return order_; }
1114 
1115  template <class T> void apply(const Coord& pos,bool dir,T&) const;
1121 protected:
1122 
1124  double f0_;
1125  double f1_;
1126  double f2_;
1127  double f11_;
1128  double f12_;
1129  double f22_;
1131 
1134  const TypeSet<double>&);
1136  const TypeSet<double>&);
1138 
1139 };
1140 
1141 
1142 
1143 template <class IDXABLE> inline
1144 bool PolyTrend::set( const TypeSet<Coord>& poslist, const IDXABLE& vals )
1145 {
1146  int sz = poslist.size();
1147  if ( order_ == PolyTrend::None )
1148  return false;
1149 
1150  f0_ = f1_ = f2_ = f11_ = f12_ = f22_ = posc_.x = posc_.y = 0.;
1151  TypeSet<Coord> posnoudf;
1152  TypeSet<double> valsnoudf;
1153  for ( int idx=0; idx<sz; idx++ )
1154  {
1155  if ( !poslist[idx].isDefined() || mIsUdf(vals[idx]) )
1156  continue;
1157 
1158  posnoudf += poslist[idx];
1159  valsnoudf += (double) vals[idx];
1160  }
1161 
1162  sz = valsnoudf.size();
1163  getOrder( sz, order_ );
1164  if ( order_ == Order0 )
1165  initOrder0( valsnoudf );
1166  else if ( order_ == Order1 )
1167  initOrder1( posnoudf, valsnoudf );
1168  else if ( order_ == Order2 )
1169  initOrder2( posnoudf, valsnoudf );
1170  else
1171  return false;
1172 
1173  return true;
1174 }
1175 
1176 
1177 template <class T> inline
1178 void PolyTrend::apply( const Coord& pos, bool dir, T& val ) const
1179 {
1180  if ( order_ == None || !pos.isDefined() || mIsUdf(val) )
1181  return;
1182 
1183  const double fact = dir ? -1. : 1;
1184  double inp = (double) val;
1185  inp += fact * f0_;
1186  if ( order_ == Order0 )
1187  {
1188  val = (T)inp;
1189  return;
1190  }
1191 
1192  const double dx = pos.x - posc_.x;
1193  const double dy = pos.y - posc_.y;
1194  inp += fact * ( f1_ * dx + f2_ * dy );
1195  if ( order_ == Order1 )
1196  {
1197  val = (T)inp;
1198  return;
1199  }
1200 
1201  const double dx2 = dx * dx;
1202  const double dxy = dx * dy;
1203  const double dyy = dy * dy;
1204  inp += fact * ( f11_ * dx2 + f12_ * dxy + f22_ * dyy );
1205  val = (T)inp;
1206 }
1207 
1208 
1209 
1210 namespace ArrayMath
1211 {
1212 
1214 {
1215 public:
1216  ArrayOperExecSetup(bool doadd=true,bool dosqinp=false,
1217  bool dosqout=false,bool doabs=false,
1218  bool donormalizesum=false,
1219  bool dosqrtsum=false)
1220  : doadd_(doadd)
1221  , dosqinp_(dosqinp)
1222  , dosqout_(dosqout)
1223  , doabs_(doabs)
1224  , donormalizesum_(donormalizesum)
1225  , dosqrtsum_(dosqrtsum)
1226  {}
1227 
1228  bool doadd_;
1229  bool dosqinp_;
1230  bool dosqout_;
1231  bool doabs_;
1234 };
1235 
1236 
1242 template <class RT,class AT>
1245 public:
1246  CumArrOperExec( const ArrayND<AT>& xvals, bool noudf,
1247  const ArrayOperExecSetup& setup )
1248  : xarr_(xvals)
1249  , yarr_(0)
1250  , sz_(xvals.info().getTotalSz())
1251  , xfact_(mUdf(double))
1252  , yfact_(mUdf(double))
1253  , noudf_(noudf)
1254  , cumsum_(mUdf(RT))
1255  , setup_(setup)
1256  {}
1257 
1259  uiString uiMessage() const { return tr("Cumulative sum executor");}
1260 
1261  void setYVals( const ArrayND<AT>& yvals ) { yarr_ = &yvals; }
1262  void setScaler( double scaler, bool forx )
1263  {
1264  if ( forx )
1265  xfact_ = scaler;
1266  else
1267  yfact_ = scaler;
1268  }
1269 
1270  RT getSum() const { return cumsum_; }
1271 
1272 protected:
1273 
1274  od_int64 nrIterations() const { return sz_; }
1275 
1276 private:
1277 
1278  bool doPrepare( int nrthreads )
1279  {
1280  if ( yarr_ && yarr_->info().getTotalSz() != sz_ )
1281  return false;
1282 
1283  return sumvals_.setSize( nrthreads );
1284  }
1285 
1286  bool doWork(od_int64,od_int64,int);
1287 
1288  bool doFinish( bool success )
1289  {
1290  if ( !success )
1291  return false;
1292 
1293  int count = 0;
1294  cumsum_ = 0;
1295  for ( int idx=0; idx<sumvals_.size(); idx++ )
1296  {
1297  if ( mIsUdf(sumvals_[idx]) )
1298  continue;
1299 
1300  cumsum_ += sumvals_[idx];
1301  count++;
1302  }
1303 
1304  if ( count == 0 )
1305  cumsum_ = mUdf(RT);
1306 
1307  if ( setup_.donormalizesum_ )
1308  cumsum_ /= mCast(RT,xarr_.info().getTotalSz());
1309 
1310  if ( setup_.dosqrtsum_ )
1311  cumsum_ = Math::Sqrt( cumsum_ );
1312 
1313  return true;
1314  }
1315 
1316 private:
1317 
1320  bool noudf_;
1321 
1325  double xfact_;
1326  double yfact_;
1328 };
1329 
1330 
1331 template <class RT,class AT> inline
1333  int threadidx )
1334 {
1335  RT sumval = 0, comp = 0;
1336  od_uint64 count = 0;
1337  const AT* xvals = xarr_.getData();
1338  const AT* yvals = yarr_ ? yarr_->getData() : 0;
1339  const ValueSeries<AT>* xstor = xarr_.getStorage();
1340  const ValueSeries<AT>* ystor = yarr_ ? yarr_->getStorage() : 0;
1341  ArrayNDIter* xiter = xvals || xstor ? 0 : new ArrayNDIter( xarr_.info() );
1342  ArrayNDIter* yiter = ( yarr_ && ( yvals || ystor ) ) || !yarr_
1343  ? 0 : new ArrayNDIter( yarr_->info() );
1344  if ( xiter ) xiter->setGlobalPos( start );
1345  if ( yiter ) yiter->setGlobalPos( start );
1346  const bool doscalexvals = !mIsUdf(xfact_);
1347  const bool hasyvals = yarr_;
1348  const bool doscaleyvals = !mIsUdf(yfact_);
1349  for ( od_int64 idx=start; idx<=stop; idx++ )
1350  {
1351  RT xvalue = xvals ? xvals[idx]
1352  : xstor ? xstor->value(idx)
1353  : xarr_.getND( xiter->getPos() );
1354  if ( !noudf_ && mIsUdf(xvalue) )
1355  {
1356  if ( xiter ) xiter->next();
1357  if ( yiter ) yiter->next();
1358  continue;
1359  }
1360 
1361  if ( setup_.dosqinp_ ) xvalue *= xvalue;
1362  if ( doscalexvals ) xvalue *= xfact_;
1363  if ( hasyvals )
1364  {
1365  RT yvalue = yvals ? yvals[idx]
1366  : ystor ? ystor->value(idx)
1367  : yarr_->getND( yiter->getPos() );
1368  if ( !noudf_ && mIsUdf(yvalue) )
1369  {
1370  if ( xiter ) xiter->next();
1371  if ( yiter ) yiter->next();
1372  continue;
1373  }
1374 
1375  if ( setup_.dosqinp_ ) yvalue *= yvalue;
1376  if ( doscaleyvals ) yvalue *= yfact_;
1377  if ( setup_.doadd_ )
1378  xvalue += yvalue;
1379  else
1380  xvalue *= yvalue;
1381  }
1382 
1383  if ( setup_.doabs_ )
1384  xvalue = Math::Abs( xvalue );
1385  else if ( setup_.dosqout_ )
1386  xvalue *= xvalue;
1387 
1388  xvalue -= comp;
1389  const RT t = sumval + xvalue;
1390  comp = ( t - sumval ) - xvalue;
1391  sumval = t;
1392  count++;
1393  if ( xiter ) xiter->next();
1394  if ( yiter ) yiter->next();
1395  }
1396 
1397  delete xiter; delete yiter;
1398  sumvals_[threadidx] = count==0 ? mUdf(RT) : sumval;
1399 
1400  return true;
1401 }
1402 
1403 
1404 template <> inline
1406 { return false; }
1407 
1408 
1409 #define mSetResAndContinue(res) \
1410 { \
1411  if ( outvals ) \
1412  outvals[idx] = res; \
1413  else if ( outstor ) \
1414  outstor->setValue( idx, res );\
1415  else \
1416  outarr_.setND( outiter->getPos(), res ); \
1417  \
1418  if ( xiter ) xiter->next(); \
1419  if ( yiter ) yiter->next(); \
1420  if ( outiter ) outiter->next(); \
1421 }
1422 
1428 template <class OperType,class ArrType>
1431 public:
1433  const ArrayND<ArrType>* yvals, bool noudf,
1434  const ArrayOperExecSetup& setup,
1435  ArrayND<ArrType>& outvals )
1436  : xarr_(xvals)
1437  , yarr_(yvals)
1438  , outarr_(outvals)
1439  , sz_(xvals.info().getTotalSz())
1440  , xfact_(mUdf(double))
1441  , yfact_(mUdf(double))
1442  , shift_(mUdf(double))
1443  , noudf_(noudf)
1444  , setup_(setup)
1445  {}
1446 
1448  uiString uiMessage() const { return tr("Cumulative sum executor");}
1449 
1450  void setYVals( const ArrayND<ArrType>& yvals ) { yarr_ = &yvals; }
1451  void setScaler( double scaler, bool forx=true )
1452  {
1453  if ( forx )
1454  xfact_ = scaler;
1455  else
1456  yfact_ = scaler;
1457  }
1458  void setShift( double shift ) { shift_ = shift; }
1459 
1460 protected:
1461 
1462  od_int64 nrIterations() const { return sz_; }
1463 
1464 private:
1465 
1466  bool doPrepare( int )
1467  {
1468  if ( outarr_.info().getTotalSz() != sz_ )
1469  return false;
1470 
1471  if ( yarr_ && yarr_->info().getTotalSz() != sz_ )
1472  return false;
1473 
1474  return true;
1475  }
1476 
1477  bool doWork(od_int64,od_int64,int);
1478 
1479 private:
1480 
1483  bool noudf_;
1484 
1488  double xfact_;
1489  double yfact_;
1490  double shift_;
1491 };
1492 
1493 
1494 template <class OperType,class ArrType>
1496 {
1497  const ArrType* xvals = xarr_.getData();
1498  const ArrType* yvals = yarr_ ? yarr_->getData() : 0;
1499  ArrType* outvals = outarr_.getData();
1500  const ValueSeries<ArrType>* xstor = xarr_.getStorage();
1501  const ValueSeries<ArrType>* ystor = yarr_ ? yarr_->getStorage() : 0;
1502  ValueSeries<ArrType>* outstor = outarr_.getStorage();
1503  ArrayNDIter* xiter = xvals || xstor ? 0 : new ArrayNDIter( xarr_.info() );
1504  ArrayNDIter* yiter = ( yarr_ && ( yvals || ystor ) ) || !yarr_
1505  ? 0 : new ArrayNDIter( yarr_->info() );
1506  ArrayNDIter* outiter = outvals || outstor
1507  ? 0 : new ArrayNDIter( outarr_.info() );
1508  if ( xiter ) xiter->setGlobalPos( start );
1509  if ( yiter ) yiter->setGlobalPos( start );
1510  if ( outiter ) outiter->setGlobalPos( start );
1511  const bool doscalexvals = !mIsUdf(xfact_);
1512  const bool hasyvals = yarr_;
1513  const bool doscaleyvals = !mIsUdf(yfact_);
1514  const bool doshiftoutvals = !mIsUdf(shift_);
1515  for ( od_int64 idx=start; idx<=stop; idx++ )
1516  {
1517  OperType xvalue = xvals ? xvals[idx]
1518  : xstor ? xstor->value(idx)
1519  : xarr_.getND( xiter->getPos() );
1520  if ( !noudf_ && mIsUdf(xvalue) )
1521  { mSetResAndContinue( mUdf(ArrType) ) continue; }
1522 
1523  if ( doscalexvals ) xvalue *= xfact_;
1524  if ( hasyvals )
1525  {
1526  OperType yvalue = yvals ? yvals[idx]
1527  : ystor ? ystor->value(idx)
1528  : yarr_->getND( yiter->getPos() );
1529  if ( !noudf_ && mIsUdf(yvalue) )
1530  { mSetResAndContinue( mUdf(ArrType) ) continue; }
1531 
1532  if ( doscaleyvals ) yvalue *= yfact_;
1533  if ( setup_.doadd_ )
1534  xvalue += yvalue;
1535  else
1536  xvalue *= yvalue;
1537  }
1538 
1539  if ( doshiftoutvals )
1540  xvalue += shift_;
1541 
1542  mSetResAndContinue( mCast(ArrType,xvalue) )
1543  }
1544 
1545  delete xiter; delete yiter; delete outiter;
1546 
1547  return true;
1548 }
1549 
1550 
1551 
1552 template <class T>
1553 class CumSumExec : public ParallelTask
1555 public:
1556  CumSumExec( const T* vals, od_int64 sz, bool noudf )
1557  : vals_(vals)
1558  , sz_(sz)
1559  , noudf_(noudf)
1560  , cumsum_(mUdf(T))
1561  {}
1562 
1564  uiString uiMessage() const { return tr("Cumulative sum executor");}
1565 
1566  T getSum() const { return cumsum_; }
1567 
1568 protected:
1569 
1570  od_int64 nrIterations() const { return sz_; }
1571 
1572 private:
1573 
1574  bool doPrepare( int nrthreads )
1575  {
1576  return sumvals_.setSize( nrthreads );
1577  }
1578 
1579  bool doWork( od_int64 start, od_int64 stop, int threadidx )
1580  {
1581  T sumval = 0;
1582  od_int64 count = 0;
1583  for ( int idx=mCast(int,start); idx<=stop; idx++ )
1584  {
1585  const T value = vals_[idx];
1586  if ( !noudf_ && mIsUdf(value) )
1587  continue;
1588 
1589  sumval += value;
1590  count++;
1591  }
1592 
1593  sumvals_[threadidx] = count==0 ? mUdf(T) : sumval;
1594 
1595  return true;
1596  }
1597 
1598  bool doFinish( bool success )
1599  {
1600  if ( !success )
1601  return false;
1602 
1603  int count = 0;
1604  cumsum_ = 0;
1605  for ( int idx=0; idx<sumvals_.size(); idx++ )
1606  {
1607  if ( mIsUdf(sumvals_[idx]) )
1608  continue;
1609 
1610  cumsum_ += sumvals_[idx];
1611  count++;
1612  }
1613 
1614  if ( count == 0 )
1615  cumsum_ = mUdf(T);
1616 
1617  return true;
1618  }
1619 
1621  bool noudf_;
1622 
1624  const T* vals_;
1626 };
1627 
1628 
1632 template <class T>
1633 inline T getSum( const ArrayND<T>& in, bool noudf, bool parallel )
1634 {
1635  ArrayOperExecSetup setup;
1636  CumArrOperExec<double,T> sumexec( in, noudf, setup );
1637  if ( !sumexec.executeParallel(parallel) )
1638  return mUdf(T);
1639 
1640  return mCast(T,sumexec.getSum());
1641 }
1642 
1643 
1644 template <>
1645 inline float_complex getSum( const ArrayND<float_complex>& in, bool noudf,
1646  bool parallel )
1647 { return mUdf(float_complex); }
1648 
1649 
1650 
1653 template <class T>
1654 inline T getAverage( const ArrayND<T>& in, bool noudf, bool parallel )
1655 {
1656  ArrayOperExecSetup setup;
1657  setup.donormalizesum_ = true;
1658  CumArrOperExec<double,T> avgexec( in, noudf, setup );
1659  if ( !avgexec.executeParallel(parallel) )
1660  return mUdf(T);
1661 
1662  return mCast(T,avgexec.getSum());
1663 }
1664 
1665 
1667 template <>
1669  bool noudf, bool parallel )
1670 {
1671  const od_uint64 sz = in.info().getTotalSz();
1672  const float_complex sumvals = getSum( in, noudf, parallel );
1673  return mIsUdf(sumvals) ? mUdf(float_complex) : sumvals / mCast(float,sz);
1674 }
1675 
1676 
1677 template <class T>
1679  od_static_tr("ScalingExec","Array scaler executor"),
1680  const T*,arrin,T*,arrout,T,fact,T,shift,bool,noudf)
1681 mDefParallelCalcBody(,const T inpval = arrin_[idx]; \
1682  if ( !noudf_ && ( mIsUdf(inpval) ) ) \
1683  { arrout_[idx] = mUdf(T); continue; } \
1684  arrout_[idx] = fact_ * inpval + shift_; , )
1685 
1688 template <class T>
1689 inline void getScaledArray( const ArrayND<T>& in, ArrayND<T>* out_, double fact,
1690  double shift, bool noudf, bool parallel )
1691 {
1692  ArrayND<T>& out = out_ ? *out_ : const_cast<ArrayND<T>&>( in );
1693  ArrayOperExecSetup setup;
1694  ArrOperExec<double,T> scalinngexec( in, 0, noudf, setup, out );
1695  scalinngexec.setScaler( fact );
1696  scalinngexec.setShift( shift );
1697  scalinngexec.executeParallel( parallel );
1698 }
1699 
1700 
1701 
1702 template <class T>
1704  od_static_tr("SumExec","Array addition executor"),
1705  const T*,arr1,const T*,arr2,T*,out,T,fact1,T,fact2,bool,noudf)
1706 mDefParallelCalcBody(,const T val1 = arr1_[idx]; const T val2 = arr2_[idx]; \
1707  if ( !noudf_ && ( mIsUdf(val1) || mIsUdf(val2) ) ) \
1708  { out_[idx] = mUdf(T); continue; } \
1709  out_[idx] = fact1_ * val1 + fact2_ * val2; , )
1710 
1713 template <class T>
1714 inline void getSumArrays( const ArrayND<T>& in1, const ArrayND<T>& in2,
1715  ArrayND<T>& out, double fact1, double fact2,
1716  bool noudf, bool parallel )
1717 {
1718  ArrayOperExecSetup setup;
1719  ArrOperExec<double,T> sumexec( in1, &in2, noudf, setup, out );
1720  sumexec.setScaler( fact1 );
1721  sumexec.setScaler( fact2, false );
1722  sumexec.executeParallel( parallel );
1723 }
1724 
1725 
1726 
1727 template <class T>
1729  od_static_tr("ProdExec","Array product executor"),
1730  const T*,arr1,const T*,arr2,T*,out,bool,noudf)
1731 mDefParallelCalcBody(,const T val1 = arr1_[idx]; const T val2 = arr2_[idx]; \
1732  if ( !noudf_ && ( mIsUdf(val1) || mIsUdf(val2) ) ) \
1733  { out_[idx] = mUdf(T); continue; } \
1734  out_[idx] = val1*val2; , )
1735 
1736 
1739 template <class T>
1740 inline void getProduct( const ArrayND<T>& in1, const ArrayND<T>& in2,
1741  ArrayND<T>& out, bool noudf, bool parallel )
1742 {
1743  ArrayOperExecSetup setup;
1744  setup.doadd_ = false;
1745  ArrOperExec<double,T> prodexec( in1, &in2, noudf, setup, out );
1746  prodexec.executeParallel( parallel );
1747 }
1748 
1749 
1750 
1753 template <class T>
1754 inline void getSum( const ArrayND<T>& in1, const ArrayND<T>& in2,
1755  ArrayND<T>& out, bool noudf, bool parallel )
1756 {
1757  ArrayOperExecSetup setup;
1758  ArrOperExec<double,T> sumexec( in1, &in2, noudf, setup, out );
1759  sumexec.executeParallel( parallel );
1760 }
1761 
1762 
1765 template <class T>
1766 inline T getSumProduct( const ArrayND<T>& in1, const ArrayND<T>& in2,
1767  bool noudf, bool parallel )
1768 {
1769  ArrayOperExecSetup setup;
1770  setup.doadd_ = false;
1771  CumArrOperExec<double,T> sumprodexec( in1, noudf, setup );
1772  sumprodexec.setYVals( in2 );
1773  if ( !sumprodexec.executeParallel(parallel) )
1774  return mUdf(T);
1775 
1776  return mCast(T,sumprodexec.getSum());
1777 }
1778 
1779 template <class T>
1780 inline double getSumProductD( const ArrayND<T>& in1, const ArrayND<T>& in2,
1781  bool noudf, bool parallel )
1782 {
1783  ArrayOperExecSetup setup;
1784  setup.doadd_ = false;
1785  CumArrOperExec<double,T> sumprodexec( in1, noudf, setup );
1786  sumprodexec.setYVals( in2 );
1787  if ( !sumprodexec.executeParallel(parallel) )
1788  return mUdf(double);
1789 
1790  return sumprodexec.getSum();
1791 }
1792 
1793 
1796 template <class T>
1797 inline T getSumSq( const ArrayND<T>& in, bool noudf, bool parallel )
1798 {
1799  ArrayOperExecSetup setup;
1800  setup.dosqinp_ = true;
1801  CumArrOperExec<double,T> sumsqexec( in, noudf, setup );
1802  if ( !sumsqexec.executeParallel(parallel) )
1803  return mUdf(T);
1804 
1805  return mCast(T,sumsqexec.getSum());
1806 }
1807 
1808 
1811 template <class T>
1812 inline T getNorm2( const ArrayND<T>& in, bool noudf, bool parallel )
1813 {
1814  ArrayOperExecSetup setup;
1815  setup.dosqinp_ = true;
1816  setup.dosqrtsum_ = true;
1817  CumArrOperExec<double,T> norm2exec( in, noudf, setup );
1818  if ( !norm2exec.executeParallel(parallel) )
1819  return mUdf(T);
1820 
1821  return mCast(T,norm2exec.getSum());
1822 }
1823 
1824 template <class T>
1825 inline double getNorm2D( const ArrayND<T>& in, bool noudf, bool parallel )
1826 {
1827  ArrayOperExecSetup setup;
1828  setup.dosqinp_ = true;
1829  setup.dosqrtsum_ = true;
1830  CumArrOperExec<double,T> norm2exec( in, noudf, setup );
1831  if ( !norm2exec.executeParallel(parallel) )
1832  return mUdf(double);
1833 
1834  return norm2exec.getSum();
1835 }
1836 
1837 
1840 template <class T>
1841 inline T getRMS( const ArrayND<T>& in, bool noudf, bool parallel )
1842 {
1843  ArrayOperExecSetup setup;
1844  setup.dosqinp_ = true;
1845  setup.donormalizesum_ = true;
1846  setup.dosqrtsum_ = true;
1847  CumArrOperExec<double,T> rmsexec( in, noudf, setup );
1848  if ( !rmsexec.executeParallel(parallel) )
1849  return mUdf(T);
1850 
1851  return mCast(T,rmsexec.getSum());
1852 }
1853 
1854 
1857 template <class T>
1858 inline T getResidual( const ArrayND<T>& in1, const ArrayND<T>& in2, bool noudf,
1859  bool parallel )
1860 {
1861  ArrayOperExecSetup setup;
1862  setup.doabs_ = true;
1863  setup.donormalizesum_ = true;
1864  CumArrOperExec<double,T> residualexec( in1, noudf, setup );
1865  residualexec.setYVals( in2 );
1866  residualexec.setScaler( -1., false );
1867  if ( !residualexec.executeParallel(parallel) )
1868  return mUdf(T);
1869 
1870  return mCast(T,residualexec.getSum());
1871 }
1872 
1873 
1876 template <class T>
1877 inline T getSumXMY2( const ArrayND<T>& in1, const ArrayND<T>& in2, bool noudf,
1878  bool parallel )
1879 {
1880  ArrayOperExecSetup setup;
1881  setup.dosqout_ = true;
1882  CumArrOperExec<double,T> sumxmy2exec( in1, noudf, setup );
1883  sumxmy2exec.setYVals( in2 );
1884  sumxmy2exec.setScaler( -1., false );
1885  if ( !sumxmy2exec.executeParallel(parallel) )
1886  return mUdf(T);
1887 
1888  return mCast(T,sumxmy2exec.getSum());
1889 }
1890 
1891 
1894 template <class T>
1895 inline T getSumX2PY2( const ArrayND<T>& in1, const ArrayND<T>& in2, bool noudf,
1896  bool parallel )
1897 {
1898  ArrayOperExecSetup setup;
1899  setup.dosqinp_ = true;
1900  CumArrOperExec<double,T> sumx2py2exec( in1, noudf, setup );
1901  sumx2py2exec.setYVals( in2 );
1902  if ( !sumx2py2exec.executeParallel(parallel) )
1903  return mUdf(T);
1904 
1905  return mCast(T,sumx2py2exec.getSum());
1906 }
1907 
1908 
1911 template <class T>
1912 inline T getSumX2MY2( const ArrayND<T>& in1, const ArrayND<T>& in2, bool noudf,
1913  bool parallel )
1914 {
1915  ArrayOperExecSetup setup;
1916  setup.dosqinp_ = true;
1917  CumArrOperExec<double,T> sumx2my2exec( in1, noudf, setup );
1918  sumx2my2exec.setYVals( in2 );
1919  sumx2my2exec.setScaler( -1., false );
1920  if ( !sumx2my2exec.executeParallel(parallel) )
1921  return mUdf(T);
1922 
1923  return mCast(T,sumx2my2exec.getSum());
1924 }
1925 
1926 
1929 template <class T, class fT>
1930 inline bool getInterceptGradient( const ArrayND<T>& iny, const ArrayND<T>* inx_,
1931  T& intercept, T& gradient )
1932 {
1933  const od_uint64 sz = iny.info().getTotalSz();
1934  T avgyvals = getAverage( iny, false, true );
1935  if ( mIsUdf(avgyvals) )
1936  return false;
1937 
1938  const bool hasxvals = inx_;
1939  const ArrayND<T>* inx = hasxvals ? inx_ : 0;
1940  if ( !hasxvals )
1941  {
1942  Array1DImpl<T>* inxtmp = new Array1DImpl<T>( mCast(int,sz) );
1943  if ( !inxtmp->isOK() )
1944  { delete inxtmp; return false; }
1945 
1946  T* inxvals = inxtmp->getData();
1947  if ( inxvals )
1948  {
1949  for ( od_uint64 idx=0; idx<sz; idx++ )
1950  inxvals[idx] = mCast(fT,idx);
1951  }
1952  else
1953  {
1954  ArrayNDIter iter( inxtmp->info() );
1955  od_uint64 idx = 0;
1956  do
1957  {
1958  inxtmp->setND( iter.getPos(), mCast(fT,idx) );
1959  idx++;
1960  } while ( iter.next() );
1961  }
1962 
1963  inx = inxtmp;
1964  }
1965 
1966  T avgxvals = getAverage( *inx, false, true );
1967  if ( mIsUdf(avgxvals) )
1968  { if ( !hasxvals) delete inx; return false; }
1969 
1970  ArrayND<T>& inyed = const_cast<ArrayND<T>&>( iny );
1971  ArrayND<T>& inxed = const_cast<ArrayND<T>&>( *inx );
1972  removeBias<T,fT>( inyed );
1973  removeBias<T,fT>( inxed );
1974 
1975  Array1DImpl<T> crossprodxy( mCast(int,sz) );
1976  if ( !crossprodxy.isOK() )
1977  { if ( !hasxvals ) delete inx; return false; }
1978 
1979  getProduct( *inx, iny, crossprodxy, false, true );
1980 
1981  gradient = getSumProduct( *inx, iny, false, true ) /
1982  getSumSq( *inx, false, true );
1983  intercept = avgyvals - gradient * avgxvals;
1984  getScaledArray( iny, &inyed, 1., avgyvals, false, true );
1985 
1986  if ( !hasxvals )
1987  delete inx;
1988  else
1989  getScaledArray( *inx, &inxed, 1., avgxvals, false, true );
1990 
1991  return true;
1992 }
1993 
1994 }; //namespace ArrayMath
1995 
1996 
1997 
2004 template <class T>
2007 public:
2009  LargeValVec<od_uint64>* undefidxs )
2010  : ParallelTask("Array Udf Replacer")
2011  , inp_(inp)
2012  , replval_(0.f)
2013  , undefidxs_(undefidxs)
2014  , tks_(0)
2015  , trcssampling_(0)
2016  , totalnr_(inp.info().getTotalSz()/inp.info().getSize(1))
2017  {}
2018 
2020  LargeValVec<od_uint64>* undefidxs )
2021  : ParallelTask("Array Udf Replacer")
2022  , inp_(inp)
2023  , replval_(0.f)
2024  , undefidxs_(undefidxs)
2025  , tks_(0)
2026  , trcssampling_(0)
2027  , totalnr_(inp.info().getTotalSz()/inp.info().getSize(2))
2028  {}
2029 
2031  {
2032  return tr("Replacing undefined values");
2033  }
2034 
2036 
2037  void setReplacementValue( T val ) { replval_ = val; }
2038 
2039  void setSampling( const TrcKeySampling& tks,
2040  const PosInfo::CubeData* trcssampling )
2041  {
2042  tks_ = &tks;
2043  trcssampling_ = trcssampling;
2044  }
2045 
2046 protected:
2047 
2048  od_int64 nrIterations() const { return totalnr_; }
2049 
2050 private:
2051 
2052  bool doPrepare( int )
2053  {
2054  if ( undefidxs_ )
2055  undefidxs_->setEmpty();
2056 
2057  return true;
2058  }
2059 
2060  bool doWork( od_int64 start, od_int64 stop, int )
2061  {
2062  const bool isrect = tks_ && trcssampling_
2063  ? trcssampling_->isFullyRectAndReg()
2064  : true;
2065  const ArrayNDInfo& info = inp_.info();
2066  const int nrtrcsp = info.getSize( inp_.get1DDim() );
2067  T* dataptr = inp_.getData();
2068  ValueSeries<T>* datastor = inp_.getStorage();
2069  const bool hasarrayptr = dataptr;
2070  const bool hasstorage = datastor;
2071  const bool neediterator = !hasarrayptr && !hasstorage;
2072  const od_int64 offset = start * nrtrcsp;
2073  dataptr += offset;
2074  od_uint64 validx = offset;
2075  ArrayNDIter* iter = neediterator
2076  ? new ArrayNDIter( info ) : 0;
2077  if ( iter )
2078  iter->setGlobalPos( offset );
2079 
2080  const T replval = replval_;
2081  for ( od_int64 idx=start; idx<=stop; idx++,
2082  quickAddToNrDone(idx))
2083  {
2084  const bool hastrcdata = isrect ? true
2085  : trcssampling_->isValid(idx,*tks_);
2086  if ( hastrcdata )
2087  {
2088  for ( int idz=0; idz<nrtrcsp; idz++ )
2089  {
2090  const int* pos = iter ? iter->getPos() : 0;
2091  const T val = hasarrayptr ? *dataptr
2092  : hasstorage
2093  ? datastor->value( validx )
2094  : inp_.getND( pos );
2095  if ( !mIsUdf(val) )
2096  {
2097  if ( hasarrayptr ) dataptr++;
2098  else if ( hasstorage ) validx++;
2099  else iter->next();
2100 
2101  continue;
2102  }
2103 
2104  if ( undefidxs_ )
2105  {
2106  lck_.lock();
2107  *undefidxs_ += idx*nrtrcsp + idz;
2108  lck_.unLock();
2109  }
2110 
2111  if ( hasarrayptr )
2112  *dataptr++ = replval;
2113  else if ( hasstorage )
2114  datastor->setValue( validx++, replval );
2115  else
2116  {
2117  inp_.setND( pos, replval );
2118  iter->next();
2119  }
2120  }
2121  }
2122  else
2123  {
2124  if ( hasarrayptr )
2125  {
2126  dataptr =
2127  OD::sysMemValueSet( dataptr, replval, nrtrcsp );
2128  }
2129  else if ( hasstorage )
2130  {
2131  for ( int idz=0; idz<nrtrcsp; idz++ )
2132  datastor->setValue( validx++, replval );
2133  }
2134  else
2135  {
2136  for ( int idz=0; idz<nrtrcsp; idz++ )
2137  {
2138  inp_.setND( iter->getPos(), replval );
2139  iter->next();
2140  }
2141  }
2142  }
2143  }
2144 
2145  delete iter;
2146 
2147  return true;
2148  }
2149 
2157 };
2158 
2159 
2163  const TrcKeyZSampling& tkzsout,
2165 
2166 
2169 template <class T>
2172 public:
2173  ArrayUdfValRestorer( const LargeValVec<od_uint64>& undefidxs,
2174  ArrayND<T>& outp )
2175  : ParallelTask("Udf retriever")
2176  , undefidxs_(undefidxs)
2177  , outp_(outp)
2178  , totalnr_(undefidxs.size())
2179  {}
2180 
2181  uiString uiMessage() const { return tr("Replacing undefined values"); }
2182 
2184 
2185 protected:
2186 
2187  od_int64 nrIterations() const { return totalnr_; }
2188 
2189 private:
2190 
2191  bool doWork( od_int64 start, od_int64 stop, int )
2192  {
2193  T* outpptr = outp_.getData();
2194  ValueSeries<T>* outpstor = outp_.getStorage();
2195  mDeclareAndTryAlloc(int*,pos,int[outp_.info().getNDim()])
2196  if ( !pos )
2197  return false;
2198 
2199  const T udfval = mUdf(T);
2200  const ArrayNDInfo& info = outp_.info();
2201  for ( od_int64 idx=start; idx<=stop; idx++,
2202  quickAddToNrDone(idx) )
2203  {
2204  const od_uint64 sidx = undefidxs_[idx];
2205  if ( outpptr )
2206  outpptr[sidx] = udfval;
2207  else if ( outpstor )
2208  outpstor->setValue( sidx, udfval );
2209  else
2210  {
2211  info.getArrayPos( sidx, pos );
2212  outp_.setND( pos, udfval );
2213  }
2214  }
2215 
2216  delete [] pos;
2217 
2218  return true;
2219  }
2220 
2224 };
2225 
2226 
2229 template <class T>
2232 public:
2233  Array3DUdfTrcRestorer( const PosInfo::CubeData& trcssampling,
2234  const TrcKeySampling& tks,
2235  Array3D<T>& outp )
2236  : ParallelTask("Udf traces retriever")
2237  , trcssampling_(trcssampling)
2238  , tks_(tks)
2239  , outp_(outp)
2240  , totalnr_(trcssampling.totalSizeInside(tks) ==
2241  mCast(int,tks.totalNr()) ? 0 :
2242  outp.info().getTotalSz()/outp.info().getSize(2))
2243  {}
2244 
2245  uiString uiMessage() const { return tr("Restoring undefined values"); }
2246 
2248 
2249 protected:
2250 
2251  od_int64 nrIterations() const { return totalnr_; }
2252 
2253 private:
2254 
2255  bool doWork( od_int64 start, od_int64 stop, int )
2256  {
2257  const Array3DInfo& info = outp_.info();
2258  const int nrtrcsp = info.getSize( outp_.get1DDim() );
2259  T* outpptr = outp_.getData();
2260  ValueSeries<T>* outstor = outp_.getStorage();
2261  const bool hasarrayptr = outpptr;
2262  const bool hasstorage = outstor;
2263  const od_int64 offset = start * nrtrcsp;
2264  outpptr += offset;
2265  od_uint64 validx = offset;
2266  const Array2DInfoImpl hinfo( info.getSize(0),
2267  info.getSize(1) );
2268  ArrayNDIter* hiter = !hasarrayptr && !hasstorage
2269  ? new ArrayNDIter( hinfo ) : 0;
2270  if ( hiter )
2271  hiter->setGlobalPos( start );
2272 
2273  for ( od_int64 idx=start; idx<=stop; idx++ )
2274  {
2275  if ( trcssampling_.isValid(idx,tks_) )
2276  {
2277  if ( hasarrayptr ) outpptr+=nrtrcsp;
2278  else if ( hasstorage ) validx+=nrtrcsp;
2279  else hiter->next();
2280 
2281  continue;
2282  }
2283 
2284  if ( hasarrayptr )
2285  {
2286  outpptr =
2287  OD::sysMemValueSet( outpptr, mUdf(T), nrtrcsp );
2288  }
2289  else if ( hasstorage )
2290  {
2291  for ( int idz=0; idz<nrtrcsp; idz++ )
2292  outstor->setValue( validx++, mUdf(T) );
2293  }
2294  else
2295  {
2296  const int inlidx = (*hiter)[0];
2297  const int crlidx = (*hiter)[1];
2298  for ( int idz=0; idz<nrtrcsp; idz++ )
2299  outp_.set( inlidx, crlidx, idz, mUdf(T) );
2300  }
2301  }
2302 
2303  delete hiter;
2304 
2305  return true;
2306  }
2307 
2311 
2313 };
2314 
2315 
2321 template <class T>
2324 public:
2325  MuteArrayExtracter( const ArrayND<T>& data,
2326  ArrayND<int>& topmute,
2327  ArrayND<int>& tailmute )
2328  : ParallelTask("Mute Array Extracter")
2329  , data_(data)
2330  , topmute_(topmute)
2331  , tailmute_(tailmute)
2332  , tks_(0)
2333  , trcssampling_(0)
2334  , totalnr_(data.info().getTotalSz()/
2335  data.info().getSize(data.get1DDim()))
2336  {}
2337 
2339  {
2340  return tr("Extracting mute positions");
2341  }
2342 
2344 
2345  void setSampling( const TrcKeySampling& tks,
2346  const PosInfo::CubeData* trcssampling )
2347  {
2348  tks_ = &tks;
2349  trcssampling_ = trcssampling;
2350  }
2351 
2352 protected:
2353 
2354  od_int64 nrIterations() const { return totalnr_; }
2355 
2356 private:
2357 
2358  bool doPrepare( int )
2359  {
2360  const int data1ddim = data_.get1DDim();
2361  if ( ( data1ddim != 1 && data1ddim != 2 ) ||
2362  topmute_.get1DDim() != data1ddim-1 ||
2363  tailmute_.get1DDim() != data1ddim-1 )
2364  return false;
2365 
2366  topmute_.setAll( 0 );
2367  const int nrz =
2368  mCast(int,data_.info().getTotalSz()/totalnr_);
2369  tailmute_.setAll( nrz-1 );
2370 
2371  return true;
2372  }
2373 
2374  bool doWork( od_int64 start, od_int64 stop, int )
2375  {
2376  const bool isrect = tks_ && trcssampling_
2377  ? trcssampling_->isFullyRectAndReg()
2378  : true;
2379  const T* dataptr = data_.getData();
2380  int* topmuteptr = topmute_.getData();
2381  int* tailmuteptr = tailmute_.getData();
2382  const ValueSeries<T>* datastor = data_.getStorage();
2383  ValueSeries<int>* topmutestor = topmute_.getStorage();
2384  ValueSeries<int>* tailmutestor = tailmute_.getStorage();
2385  const bool hasarrayptr = dataptr && topmuteptr &&
2386  tailmuteptr;
2387  const bool hasstorage = datastor && topmutestor &&
2388  tailmutestor;
2389  const bool neediterator = !hasarrayptr && !hasstorage;
2390  const ArrayNDInfo& info = data_.info();
2391  const int zidx = data_.get1DDim();
2392  const int nrtrcsp = info.getSize( zidx );
2393  const od_int64 offset = start * nrtrcsp;
2394  if ( hasarrayptr )
2395  {
2396  dataptr += offset;
2397  topmuteptr += start;
2398  tailmuteptr += start;
2399  }
2400 
2401  od_uint64 validx = offset;
2402  const int ndim = info.getNDim();
2403  const bool is2d = ndim == 2;
2404  const int nrlines = is2d ? 1 : info.getSize(0);
2405  const int nrtrcs = info.getSize( is2d ? 0 : 1 );
2406  const Array2DInfoImpl hinfo( nrlines, nrtrcs );
2407  ArrayNDIter* hiter = neediterator
2408  ? new ArrayNDIter( hinfo ) : 0;
2409  if ( hiter )
2410  hiter->setGlobalPos( start );
2411 
2412  const T zeroval = mCast(T,0);
2413  mDeclareAndTryAlloc(int*,pos,int[ndim])
2414  if ( !pos )
2415  return false;
2416 
2417  for ( od_int64 idx=start; idx<=stop; idx++,
2418  quickAddToNrDone(idx) )
2419  {
2420  const bool hastrcdata = isrect ? true
2421  : trcssampling_->isValid(idx,*tks_);
2422  if ( !hastrcdata )
2423  {
2424  if ( hasarrayptr )
2425  {
2426  dataptr+=nrtrcsp;
2427  topmuteptr++;
2428  tailmuteptr++;
2429  }
2430  if ( hasstorage ) validx+=nrtrcsp;
2431  else hiter->next();
2432 
2433  continue;
2434  }
2435 
2436  const int* hpos = hiter ? hiter->getPos() : 0;
2437  if ( hiter )
2438  {
2439  for ( int ipos=0; ipos<ndim; ipos++ )
2440  pos[ipos] = hpos[ipos];
2441  hiter->next();
2442  }
2443 
2444  bool allnull = true;
2445  for ( int idz=0; idz<nrtrcsp; idz++ )
2446  {
2447  if ( hiter ) pos[zidx] = idz;
2448  const T val = hasarrayptr
2449  ? *dataptr++
2450  : hasstorage
2451  ? datastor->value( validx++ )
2452  : data_.getND( pos );
2453  if ( val == zeroval )
2454  continue;
2455 
2456  if ( hasarrayptr )
2457  {
2458  *topmuteptr++ = idz;
2459  dataptr += nrtrcsp-idz-2;
2460  }
2461  else if ( hasstorage )
2462  {
2463  topmutestor->setValue( idx, idz );
2464  validx += nrtrcsp-idz-2;
2465  }
2466  else
2467  topmute_.setND( hpos, idz );
2468 
2469  allnull = false;
2470  break;
2471  }
2472 
2473  if ( allnull )
2474  {
2475  if ( hasarrayptr )
2476  {
2477  *topmuteptr++ = nrtrcsp;
2478  *tailmuteptr++ = -1;
2479  }
2480  else if ( hasstorage )
2481  {
2482  topmutestor->setValue( idx, nrtrcsp );
2483  tailmutestor->setValue( idx, -1 );
2484  }
2485  else
2486  {
2487  topmute_.setND( hpos, nrtrcsp );
2488  tailmute_.setND( hpos, -1 );
2489  }
2490 
2491  continue;
2492  }
2493 
2494  for ( int idz=nrtrcsp-1; idz>=0; idz-- )
2495  {
2496  if ( hiter ) pos[zidx] = idz;
2497  const T val = hasarrayptr
2498  ? *dataptr--
2499  : hasstorage
2500  ? datastor->value( validx-- )
2501  : data_.getND( pos );
2502  if ( val == zeroval )
2503  continue;
2504 
2505  if ( hasarrayptr )
2506  {
2507  *tailmuteptr++ = idz;
2508  dataptr += nrtrcsp-idz+1;
2509  }
2510  else if ( hasstorage )
2511  {
2512  tailmutestor->setValue( idx, idz );
2513  validx += nrtrcsp-idz+1;
2514  }
2515  else
2516  tailmute_.setND( hpos, idz );
2517 
2518  break;
2519  }
2520 
2521  }
2522 
2523  delete [] pos;
2524  delete hiter;
2525 
2526  return true;
2527  }
2528 
2534 
2536 };
2537 
ArrayUdfValReplacer::ArrayUdfValReplacer
ArrayUdfValReplacer(Array3D< T > &inp, LargeValVec< od_uint64 > *undefidxs)
Definition: arrayndalgo.h:2019
ValueSeries< fT >
ArrayUdfValRestorer::outp_
ArrayND< T > & outp_
Definition: arrayndalgo.h:2222
ArrayMath::CumSumExec::cumsum_
T cumsum_
Definition: arrayndalgo.h:1625
Array3DUdfTrcRestorer::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:2245
MuteArrayExtracter::setSampling
void setSampling(const TrcKeySampling &tks, const PosInfo::CubeData *trcssampling)
Definition: arrayndalgo.h:2345
convertUndefinedIndexList
void convertUndefinedIndexList(const TrcKeyZSampling &tkzsin, const TrcKeyZSampling &tkzsout, LargeValVec< od_uint64 > &)
od_uint64
#define od_uint64
Definition: plftypes.h:36
ArrayMath::ArrayOperExecSetup::doabs_
bool doabs_
Definition: arrayndalgo.h:1231
PosInfo::CubeData
Position info for an entire 3D cube. The LineData's are not sorted.
Definition: posinfo.h:95
TrcKeySampling
Horizontal sampling (inline and crossline range and steps).
Definition: trckeysampling.h:35
ArrayMath::getAverage< float_complex >
float_complex getAverage< float_complex >(const ArrayND< float_complex > &in, bool noudf, bool parallel)
Specialization for complex numbers.
Definition: arrayndalgo.h:1668
ArrayNDWindow::windowtypename_
BufferString windowtypename_
Definition: arrayndalgo.h:431
Array3DInterpolate
T Array3DInterpolate(const Array3D< T > &array, float p0, float p1, float p2, bool posperiodic=false)
Definition: arrayndalgo.h:439
ArrayMath::CumSumExec
Definition: arrayndalgo.h:1554
ArrayMath::CumArrOperExec::sumvals_
TypeSet< RT > sumvals_
Definition: arrayndalgo.h:1322
Array3DCopier::tkzsout_
const TrcKeyZSampling & tkzsout_
Definition: arrayndalgo.h:1079
ArrayMath::getInterceptGradient
bool getInterceptGradient(const ArrayND< T > &iny, const ArrayND< T > *inx_, T &intercept, T &gradient)
returns the intercept and gradient of two arrays
Definition: arrayndalgo.h:1930
Array2DCopier::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:849
TrcKeyZSampling::hsamp_
TrcKeySampling hsamp_
Definition: trckeyzsampling.h:60
TrcKeySampling::totalNr
int64_t totalNr() const
Pos::IdxPair::crl
IdxType & crl()
Definition: posidxpair.h:47
Array1DImpl::isOK
bool isOK() const
Definition: arrayndimpl.h:66
Array2DCopier
Transfers the common samples from one 2D array to another.
Definition: arrayndalgo.h:819
Array1DImpl::info
const Array1DInfo & info() const
Definition: arrayndimpl.h:75
ArrayMath::ArrOperExec::mODTextTranslationClass
mODTextTranslationClass(ArrOperExec)
PolyTrend::initOrder0
void initOrder0(const TypeSet< double > &)
Array2DCopier::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:839
ArrayND::get1DDim
virtual int get1DDim() const
Definition: arraynd.h:398
ArrayNDPaste
bool ArrayNDPaste(ArrayND< T > &dest, const ArrayND< T > &src, const TypeSet< int > &pastepos, bool destperiodic=false)
Definition: arrayndalgo.h:691
float_complex
std::complex< float > float_complex
Definition: odcomplex.h:17
PolyTrend::mDeclareEnumUtils
mDeclareEnumUtils(Order) static const char *sKeyOrder()
Definition: arrayndalgo.h:1101
ArrayMath::CumArrOperExec::setScaler
void setScaler(double scaler, bool forx)
Definition: arrayndalgo.h:1262
ParallelTask::executeParallel
virtual bool executeParallel(bool parallel)
Threads::Mutex
Is a lock that allows a thread to have exlusive rights to something.
Definition: thread.h:45
PolyTrend::f2_
double f2_
Definition: arrayndalgo.h:1126
ArrayNDInfo
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:25
ArrayMath::val1
const T val1
Definition: arrayndalgo.h:1706
mGlobal
#define mGlobal(module)
Definition: commondefs.h:180
PolyTrend::initOrder1
void initOrder1(const TypeSet< Coord > &, const TypeSet< double > &)
PolyTrend::f11_
double f11_
Definition: arrayndalgo.h:1127
ArrayMath::CumArrOperExec::xfact_
double xfact_
Definition: arrayndalgo.h:1325
Array3DCopier::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:1007
ArrayMath::getNorm2D
double getNorm2D(const ArrayND< T > &in, bool noudf, bool parallel)
Definition: arrayndalgo.h:1825
Array3DUdfTrcRestorer
Definition: arrayndalgo.h:2231
mGetInfo
#define mGetInfo()
Definition: arrayndalgo.h:980
ArrayNDInfo::getTotalSz
virtual uint64_t getTotalSz() const
Array1D::set
virtual void set(int, T)=0
ArrayNDWindow::apply
bool apply(ArrayND< Type > *in, ArrayND< Type > *out_=0) const
Definition: arrayndalgo.h:373
ArrayMath::CumArrOperExec::xarr_
const ArrayND< AT > & xarr_
Definition: arrayndalgo.h:1323
ArrayMath::getProduct
void getProduct(const ArrayND< T > &in1, const ArrayND< T > &in2, ArrayND< T > &out, bool noudf, bool parallel)
computes the product array between two arrays
Definition: arrayndalgo.h:1740
ValueSeries::value
virtual T value(int64_t) const =0
PolyTrend::None
@ None
Definition: arrayndalgo.h:1100
Array1DImpl
Implementation of Array1D.
Definition: arrayndimpl.h:52
PosInfo::CubeData::totalSizeInside
int totalSizeInside(const TrcKeySampling &hrg) const
ArrayUdfValReplacer::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:2030
ArrayMath::CumArrOperExec::sz_
od_uint64 sz_
Definition: arrayndalgo.h:1319
mIsUdf
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
Array3DCopier::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:972
StepInterval::nrSteps
int nrSteps() const
Definition: ranges.h:791
od_int64
#define od_int64
Definition: plftypes.h:35
getMin
T getMin(const ArrayND< T > &in)
returns the Minimum of all defined values in the ArrrayND. Returns UDF if empty or only udfs encounte...
Definition: arrayndalgo.h:224
ArrayUdfValRestorer::mODTextTranslationClass
mODTextTranslationClass(ArrayUdfValRestorer) public
Definition: arrayndalgo.h:2171
ArrayNDWindow::WindowType
WindowType
Definition: arrayndalgo.h:351
ArrayMath::getSumX2MY2
T getSumX2MY2(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
returns the sum of subtracted squarred amplitudes of two arrays
Definition: arrayndalgo.h:1912
ArrayUdfValReplacer::mODTextTranslationClass
mODTextTranslationClass(ArrayUdfValReplacer) public
Definition: arrayndalgo.h:2006
ArrayMath::getRMS
T getRMS(const ArrayND< T > &in, bool noudf, bool parallel)
return the RMS of the array
Definition: arrayndalgo.h:1841
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
ArrayMath::ArrOperExec::outarr_
ArrayND< ArrType > & outarr_
Definition: arrayndalgo.h:1487
StepInterval::atIndex
T atIndex(int) const
Definition: ranges.h:695
Array3DCopier::mODTextTranslationClass
mODTextTranslationClass(Array3DCopier) public
Definition: arrayndalgo.h:957
Array3D::set
virtual void set(int, int, int, T)=0
ArrayMath::ArrOperExec::shift_
double shift_
Definition: arrayndalgo.h:1490
PolyTrend::f1_
double f1_
Definition: arrayndalgo.h:1125
Array3D::info
virtual const Array3DInfo & info() const =0
PolyTrend::Order1
@ Order1
Definition: arrayndalgo.h:1100
mDefParallelCalcBody
#define mDefParallelCalcBody(preop, impl, postop)
Definition: paralleltask.h:278
uiStrings::sInline
static uiString sInline(int num=1)
Definition: uistrings.h:406
TrcKeySampling::start_
BinID start_
Definition: trckeysampling.h:142
ArrayNDCopy
bool ArrayNDCopy(ArrayND< T > &dest, const ArrayND< T > &src, const TypeSet< int > &copypos, bool srcperiodic=false)
Definition: arrayndalgo.h:608
ArrayUdfValRestorer
Definition: arrayndalgo.h:2171
ArrayUdfValReplacer::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:2060
ArrayUdfValReplacer::undefidxs_
LargeValVec< od_uint64 > * undefidxs_
Definition: arrayndalgo.h:2152
MuteArrayExtracter::mODTextTranslationClass
mODTextTranslationClass(MuteArrayExtracter) public
Definition: arrayndalgo.h:2323
ArrayMath
Definition: arrayndalgo.h:1211
OffsetValueSeries::arr
T * arr()
Definition: valseries.h:362
mDynamicCastGet
#define mDynamicCastGet(typ, out, in)
Definition: commondefs.h:148
ArrayMath::ArrOperExec::setScaler
void setScaler(double scaler, bool forx=true)
Definition: arrayndalgo.h:1451
ArrayMath::getScaledArray
void getScaledArray(const ArrayND< T > &in, ArrayND< T > *out_, double fact, double shift, bool noudf, bool parallel)
returns a scaled array
Definition: arrayndalgo.h:1689
ArrayMath::CumSumExec::noudf_
bool noudf_
Definition: arrayndalgo.h:1621
ArrayNDInfo::getSize
virtual int getSize(int dim) const =0
ArrayMath::ArrayOperExecSetup::dosqout_
bool dosqout_
Definition: arrayndalgo.h:1230
Pos::IdxPair::trcNr
IdxType & trcNr()
Definition: posidxpair.h:48
mSetResAndContinue
#define mSetResAndContinue(res)
Definition: arrayndalgo.h:1409
ArrayND::getStorage
const ValueSeries< T > * getStorage() const
Definition: arraynd.h:45
hasUndefs
bool hasUndefs(const Array1D< fT > &in)
Returns whether there are undefs in the Array1D.
Definition: arrayndalgo.h:246
ArrayUdfValReplacer::setReplacementValue
void setReplacementValue(T val)
Definition: arrayndalgo.h:2037
Array3DUdfTrcRestorer::trcssampling_
const PosInfo::CubeData & trcssampling_
Definition: arrayndalgo.h:2308
Array2DCopier::tksin_
const TrcKeySampling & tksin_
Definition: arrayndalgo.h:946
MuteArrayExtracter::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:2374
Array2DPaste
bool Array2DPaste(Array2D< T > &dest, const Array2D< T > &src, int p0, int p1, bool destperiodic=false)
Definition: arrayndalgo.h:733
PolyTrend::set
bool set(const TypeSet< Coord > &, const IDXABLE &valuelistj)
Definition: arrayndalgo.h:1144
ArrayMath::CumSumExec::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:1564
ArrayMath::if
if(!noudf_ &&(mIsUdf(inpval)))
Definition: arrayndalgo.h:1682
Array1D
Array1D ( Subclass of ArrayND ) is a one dimensional array.
Definition: arraynd.h:111
PolyTrend::Order2
@ Order2
Definition: arrayndalgo.h:1100
Math::Abs
unsigned int Abs(unsigned int i)
Definition: math2.h:79
arrayndimpl.h
Array1D::info
virtual const Array1DInfo & info() const =0
periodicvalue.h
Array3DCopier::totalnr_
const od_int64 totalnr_
Definition: arrayndalgo.h:1080
ArrayMath::ArrOperExec::xarr_
const ArrayND< ArrType > & xarr_
Definition: arrayndalgo.h:1485
PolyTrend::operator==
bool operator==(const PolyTrend &) const
ArrayNDWindow::setValue
void setValue(int idx, float val)
Definition: arrayndalgo.h:367
ArrayMath::ArrOperExec::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:1448
ArrayND::setND
virtual void setND(const int *, T)=0
ArrayMath::ArrOperExec::setup_
const ArrayOperExecSetup & setup_
Definition: arrayndalgo.h:1481
ArrayMath::ArrOperExec::setYVals
void setYVals(const ArrayND< ArrType > &yvals)
Definition: arrayndalgo.h:1450
PolyTrend::initOrder2
void initOrder2(const TypeSet< Coord > &, const TypeSet< double > &)
ArrayNDInfoImpl
Implementation of ArrayNDInfo.
Definition: arrayndinfo.h:288
TrcKeyZSampling
Hor+Vert sampling in 3D surveys.
Definition: trckeyzsampling.h:35
ArrayMath::ArrOperExec::yarr_
const ArrayND< ArrType > * yarr_
Definition: arrayndalgo.h:1486
OffsetValueSeries::setOffset
void setOffset(int64_t no)
Definition: valseries.h:377
TrcKeySampling::nrTrcs
int nrTrcs() const
Array3DUdfTrcRestorer::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:2251
ArrayNDIter::reset
void reset()
ArrayMath::CumArrOperExec::setYVals
void setYVals(const ArrayND< AT > &yvals)
Definition: arrayndalgo.h:1261
ArrayMath::ArrOperExec
Parallel task for computing the element wise operations of one array and optionally a second input ar...
Definition: arrayndalgo.h:1430
ArrayMath::ArrOperExec::yfact_
double yfact_
Definition: arrayndalgo.h:1489
ArrayUdfValReplacer::lck_
Threads::Mutex lck_
Definition: arrayndalgo.h:2156
BendPointBasedMathFunction
MathFunction based on bend points.
Definition: mathfunc.h:151
ArrayMath::CumArrOperExec::CumArrOperExec
CumArrOperExec(const ArrayND< AT > &xvals, bool noudf, const ArrayOperExecSetup &setup)
Definition: arrayndalgo.h:1246
OffsetValueSeries
ValueSeries of offsets.
Definition: valseries.h:70
Array3D
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:162
BinID
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:31
StepInterval< float >
TrcKeySampling::atIndex
BinID atIndex(int i0, int i1) const
Coord
A cartesian coordinate in 2D space.
Definition: coord.h:25
Array3DUdfTrcRestorer::mODTextTranslationClass
mODTextTranslationClass(Array3DUdfTrcRestorer) public
Definition: arrayndalgo.h:2231
Pos::IdxPair::lineNr
IdxType & lineNr()
Definition: posidxpair.h:43
ArrayMath::CumSumExec::CumSumExec
CumSumExec(const T *vals, od_int64 sz, bool noudf)
Definition: arrayndalgo.h:1556
ParallelTask::tr
static uiString tr(const char *text, const char *disambiguation=nullptr, int pluralnr=-1)
Definition: paralleltask.h:66
PolyTrend::PolyTrend
PolyTrend()
MuteArrayExtracter::totalnr_
const od_int64 totalnr_
Definition: arrayndalgo.h:2535
ArrayMath::getSumSq
T getSumSq(const ArrayND< T > &in, bool noudf, bool parallel)
returns the sum of squarred amplitudes of the array
Definition: arrayndalgo.h:1797
ArrayMath::getAverage
T getAverage(const ArrayND< T > &in, bool noudf, bool parallel)
returns the average amplitude of the array
Definition: arrayndalgo.h:1654
Array2DCopier::mODTextTranslationClass
mODTextTranslationClass(Array2DCopier)
ArrayND::info
virtual const ArrayNDInfo & info() const =0
PolyTrend::f22_
double f22_
Definition: arrayndalgo.h:1129
MuteArrayExtracter::tks_
const TrcKeySampling * tks_
Definition: arrayndalgo.h:2530
Angle::Type
Type
Definition: angles.h:26
BendPointBasedMathFunction::InterpolType
InterpolType
Definition: mathfunc.h:154
ArrayMath::getSumX2PY2
T getSumX2PY2(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
returns the sum of summed squarred amplitudes of two arrays
Definition: arrayndalgo.h:1895
Array2DCopier::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:845
ArrayMath::ArrOperExec::xfact_
double xfact_
Definition: arrayndalgo.h:1488
ArrayNDIter::setGlobalPos
bool setGlobalPos(int64_t)
Definition: arraynd.h:293
mDeclareAndTryAlloc
#define mDeclareAndTryAlloc(tp, var, stmt)
Creates variable, try to alloc and catch bad_alloc.
Definition: commondefs.h:253
Strat::RT
const RefTree & RT()
ArrayUdfValRestorer::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:2187
MuteArrayExtracter::topmute_
ArrayND< int > & topmute_
Definition: arrayndalgo.h:2532
ArrayNDWindow
Tapers the N-dimentional ArrayND with a windowFunction.
Definition: arrayndalgo.h:349
PolyTrend::getOrder
static bool getOrder(int nrpoints, Order &, uiString *=0)
ArrayMath::ArrOperExec::doWork
bool doWork(od_int64, od_int64, int)
Definition: arrayndalgo.h:1495
ArrayUdfValReplacer::trcssampling_
const PosInfo::CubeData * trcssampling_
Definition: arrayndalgo.h:2154
mComputeTrendAandB
#define mComputeTrendAandB(sz)
Definition: arrayndalgo.h:27
ArrayMath::ArrayOperExecSetup
Definition: arrayndalgo.h:1214
ArrayMath::CumArrOperExec::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:1274
ArrayMath::ArrOperExec::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:1462
trckeyzsampling.h
Geom::Point2D::isDefined
bool isDefined() const
Definition: geometry.h:364
posinfo.h
ArrayMath::CumSumExec::doPrepare
bool doPrepare(int nrthreads)
Definition: arrayndalgo.h:1574
TrcKeySampling::lineRange
StepInterval< int > lineRange() const
TrcKeySampling::getInterSection
bool getInterSection(const TrcKeySampling &, TrcKeySampling &) const
Returns false if intersection is empty.
Array3DUdfTrcRestorer::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:2247
mClass
#define mClass(module)
Definition: commondefs.h:181
ArrayMath::CumArrOperExec::doWork
bool doWork(od_int64, od_int64, int)
Definition: arrayndalgo.h:1332
ArrayMath::CumArrOperExec::yfact_
double yfact_
Definition: arrayndalgo.h:1326
Array3DPaste
bool Array3DPaste(Array3D< T > &dest, const Array3D< T > &src, int p0, int p1, int p2, bool destperiodic=false)
Definition: arrayndalgo.h:771
PolyTrend::mODTextTranslationClass
mODTextTranslationClass(PolyTrend)
uistrings.h
Array3DCopier
Transfers the common samples from one 3D array to another.
Definition: arrayndalgo.h:957
ArrayNDIter::getPos
const int * getPos() const
Definition: arraynd.h:220
ArrayMath::CumSumExec::doWork
bool doWork(od_int64 start, od_int64 stop, int threadidx)
Definition: arrayndalgo.h:1579
arrayndslice.h
uiStrings::phrJoinStrings
static uiString phrJoinStrings(const uiString &a, const uiString &b)
"
ArrayMath::CumSumExec::getSum
T getSum() const
Definition: arrayndalgo.h:1566
TrcKeySampling::lineIdx
int lineIdx(Pos::LineID) const
Definition: trckeysampling.h:231
ArrayNDIter
Iterates through all samples in an ArrayND.
Definition: arraynd.h:209
ArrayUdfValReplacer::replval_
T replval_
Definition: arrayndalgo.h:2151
removeBias
bool removeBias(ArrayND< T > &inout)
Removes the bias from an ArrayND.
Definition: arrayndalgo.h:142
Array2DCopier::Array2DCopier
Array2DCopier(const Array2D< T > &in, const TrcKeySampling &tksin, const TrcKeySampling &tksout, Array2D< T > &out)
Definition: arrayndalgo.h:821
ArrayNDWindow::buildWindow
bool buildWindow(const char *winnm, float pval)
ArrayNDWindow::CosTaper5
@ CosTaper5
Definition: arrayndalgo.h:352
MuteArrayExtracter::data_
const ArrayND< T > & data_
Definition: arrayndalgo.h:2529
Array1D::setND
void setND(const int *pos, T v)
Definition: arraynd.h:116
ArrayMath::CumSumExec::doFinish
bool doFinish(bool success)
Definition: arrayndalgo.h:1598
Array2DCopier::out_
Array2D< T > & out_
Definition: arrayndalgo.h:949
ArrayNDIter::next
bool next()
getAverage
T getAverage(const ArrayND< T > &in)
returns the average of all defined values in the Arrray1D. Returns UDF if empty or only udfs encounte...
Definition: arrayndalgo.h:176
ArrayNDWindow::getValues
float * getValues() const
Definition: arrayndalgo.h:365
ArrayNDWindow::isOK
bool isOK() const
Definition: arrayndalgo.h:362
ArrayND::totalSize
uint64_t totalSize() const
Definition: arraynd.h:87
od_static_tr
uiString od_static_tr(const char *function_name, const char *text, const char *disambiguation=nullptr, int pluralnr=-1)
Array2DCopier::commontks_
TrcKeySampling commontks_
Definition: arrayndalgo.h:948
ArrayUdfValReplacer::inp_
ArrayND< T > & inp_
Definition: arrayndalgo.h:2150
MuteArrayExtracter::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:2343
MuteArrayExtracter::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:2354
Array3DCopier::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:970
ParallelTask::sTrcFinished
static uiString sTrcFinished()
Definition: paralleltask.h:89
Array3D::get
virtual T get(int p0, int p1, int p2) const =0
ArrayMath::CumSumExec::sz_
od_int64 sz_
Definition: arrayndalgo.h:1620
MuteArrayExtracter::doPrepare
bool doPrepare(int)
Definition: arrayndalgo.h:2358
ArrayMath::getSumProduct
T getSumProduct(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
returns the sum of product amplitudes between two vectors
Definition: arrayndalgo.h:1766
ArrayMath::CumArrOperExec::noudf_
bool noudf_
Definition: arrayndalgo.h:1320
ArrayMath::CumSumExec::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:1563
ArrayUdfValReplacer
Definition: arrayndalgo.h:2006
ArrayNDWindow::window_
float * window_
Definition: arrayndalgo.h:427
PolyTrend::f12_
double f12_
Definition: arrayndalgo.h:1128
uiStrings::sDone
static uiString sDone()
Definition: uistrings.h:348
ArrayMath::ArrayOperExecSetup::ArrayOperExecSetup
ArrayOperExecSetup(bool doadd=true, bool dosqinp=false, bool dosqout=false, bool doabs=false, bool donormalizesum=false, bool dosqrtsum=false)
Definition: arrayndalgo.h:1216
ArrayMath::ArrayOperExecSetup::dosqinp_
bool dosqinp_
Definition: arrayndalgo.h:1229
ArrayMath::mDefParallelCalc4Pars
mDefParallelCalc4Pars(ProdExec, od_static_tr("ProdExec","Array product executor"), const T *, arr1, const T *, arr2, T *, out, bool, noudf) mDefParallelCalcBody(
Array3DUdfTrcRestorer::outp_
Array3D< T > & outp_
Definition: arrayndalgo.h:2310
Array3DUdfTrcRestorer::totalnr_
const od_int64 totalnr_
Definition: arrayndalgo.h:2312
Conv::set
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:27
Array3DInfo
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:147
ArrayMath::ArrOperExec::doPrepare
bool doPrepare(int)
Definition: arrayndalgo.h:1466
removeTrend
bool removeTrend(ArrayND< T > &inout)
Removes a linear trend from an ArrayND.
Definition: arrayndalgo.h:158
mathfunc.h
Array2D::info
virtual const Array2DInfo & info() const =0
ArrayUdfValReplacer::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:2035
ArrayUdfValReplacer::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:2048
OD::sysMemValueSet
T * sysMemValueSet(T *, T, int64_t nrsamp)
Definition: odmemory.h:465
OD::sysMemCopy
void sysMemCopy(void *, const void *, int64_t)
ArrayND::getND
virtual T getND(const int *) const =0
ParallelTask
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
Array3DCopy
bool Array3DCopy(Array3D< T > &dest, const Array3D< T > &src, int p0, int p1, int p2, bool srcperiodic=false)
Definition: arrayndalgo.h:647
ArrayMath::ArrayOperExecSetup::donormalizesum_
bool donormalizesum_
Definition: arrayndalgo.h:1232
ArrayUdfValReplacer::doPrepare
bool doPrepare(int)
Definition: arrayndalgo.h:2052
ArrayNDWindow::size_
ArrayNDInfoImpl size_
Definition: arrayndalgo.h:428
ArrayMath::CumArrOperExec::getSum
RT getSum() const
Definition: arrayndalgo.h:1270
PolyTrend::setOrder
void setOrder(PolyTrend::Order t)
Definition: arrayndalgo.h:1106
mCast
#define mCast(tp, v)
Definition: commondefs.h:137
TrcKeySampling::trcIdx
int trcIdx(Pos::TraceID) const
Definition: trckeysampling.h:239
ArrayNDInfo::getArrayPos
virtual bool getArrayPos(uint64_t, int *) const
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
ArrayMath::getSumProductD
double getSumProductD(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
Definition: arrayndalgo.h:1780
ArrayMath::CumArrOperExec::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:1258
Network::None
@ None
Definition: networkcommon.h:33
Array3DCopier::tkzsin_
const TrcKeyZSampling & tkzsin_
Definition: arrayndalgo.h:1078
MuteArrayExtracter::tailmute_
ArrayND< int > & tailmute_
Definition: arrayndalgo.h:2533
ArrayNDWindow::ArrayNDWindow
ArrayNDWindow(const ArrayNDInfo &, bool rectangular, const char *winnm, float paramval=mUdf(float))
Array3DCopier::in_
const Array3D< T > & in_
Definition: arrayndalgo.h:1082
ArrayUdfValRestorer::totalnr_
const od_int64 totalnr_
Definition: arrayndalgo.h:2223
BendPointBasedMathFunction::add
void add(xT x, yT y)
Definition: mathfunc.h:405
Array2DImpl
Implementation of Array2D.
Definition: arrayndimpl.h:102
Array2DInfoImpl
Implementation of Array2DInfo.
Definition: arrayndinfo.h:212
ArrayUdfValRestorer::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:2191
ArrayUdfValRestorer::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:2183
PolyTrend::order_
Order order_
Definition: arrayndalgo.h:1123
MuteArrayExtracter::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:2338
ArrayNDWindow::setType
bool setType(const char *, float paramval=mUdf(float))
MuteArrayExtracter
Definition: arrayndalgo.h:2323
uiString
String that is able to hold international (UTF-8) strings for the user interface.
Definition: uistring.h:121
ArrayMath::ArrayOperExecSetup::dosqrtsum_
bool dosqrtsum_
Definition: arrayndalgo.h:1233
ArrayMath::mDefParallelCalc5Pars
mDefParallelCalc5Pars(ScalingExec, od_static_tr("ScalingExec","Array scaler executor"), const T *, arrin, T *, arrout, T, fact, T, shift, bool, noudf) mDefParallelCalcBody(
ArrayMath::CumArrOperExec::setup_
const ArrayOperExecSetup & setup_
Definition: arrayndalgo.h:1318
removeLinPart
bool removeLinPart(const ArrayND< T > &in_, ArrayND< T > *out, bool trend)
[do not use, helper function]
Definition: arrayndalgo.h:37
ArrayNDWindow::ArrayNDWindow
ArrayNDWindow(const ArrayNDInfo &, bool rectangular, WindowType=Hamming)
ArrayMath::getSumXMY2
T getSumXMY2(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
returns the sum of squarred differences of two arrays
Definition: arrayndalgo.h:1877
ArrayMath::CumArrOperExec::doPrepare
bool doPrepare(int nrthreads)
Definition: arrayndalgo.h:1278
enums.h
dePeriodize
T dePeriodize(T val, T period)
Definition: periodicvalue.h:25
Geom::Point2D::y
T y
Definition: geometry.h:68
PolyTrend::Order0
@ Order0
Definition: arrayndalgo.h:1100
ArrayMath::getNorm2
T getNorm2(const ArrayND< T > &in, bool noudf, bool parallel)
return the Norm-2 of the array
Definition: arrayndalgo.h:1812
PolyTrend::Order
Order
Definition: arrayndalgo.h:1100
PolyTrend::posc_
Coord posc_
Definition: arrayndalgo.h:1130
Array3DCopier::out_
Array3D< T > & out_
Definition: arrayndalgo.h:1083
ArrayND
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
ArrayMath::CumArrOperExec::doFinish
bool doFinish(bool success)
Definition: arrayndalgo.h:1288
ArrayUdfValRestorer::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:2181
PolyTrend::initCenter
void initCenter(const TypeSet< Coord > &)
ArrayNDWindow::setType
bool setType(WindowType)
ArrayMath::CumSumExec::vals_
const T * vals_
Definition: arrayndalgo.h:1624
ArrayMath::getSum
T getSum(const ArrayND< T > &in, bool noudf, bool parallel)
returns the sum of all defined values in the Array. Returns UDF if empty or only udfs encountered.
Definition: arrayndalgo.h:1633
MuteArrayExtracter::trcssampling_
const PosInfo::CubeData * trcssampling_
Definition: arrayndalgo.h:2531
ArrayMath::inpval
const T inpval
Definition: arrayndalgo.h:1681
ArrayMath::ArrayOperExecSetup::doadd_
bool doadd_
Definition: arrayndalgo.h:1228
ArrayNDInfo::total_size_type
offset_type total_size_type
Definition: arrayndinfo.h:33
ArrayMath::getResidual
T getResidual(const ArrayND< T > &in1, const ArrayND< T > &in2, bool noudf, bool parallel)
returns the residual differences of two arrays
Definition: arrayndalgo.h:1858
ValueSeries::setValue
virtual void setValue(int64_t, T)
Definition: valseries.h:45
mPlural
#define mPlural
Definition: uistrings.h:18
ArrayNDWindow::paramval_
float paramval_
Definition: arrayndalgo.h:432
Geom::Point2D::x
T x
Definition: geometry.h:67
ArrayMath::CumSumExec::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:1570
mUdf
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
ArrayNDInfo::getNDim
virtual int getNDim() const =0
ArrayNDWindow::~ArrayNDWindow
~ArrayNDWindow()
OD::ValVec::size
size_type size() const
Definition: typeset.h:321
Array2D::set
virtual void set(int, int, T)=0
Array3DCopier::nrIterations
od_int64 nrIterations() const
Definition: arrayndalgo.h:976
ArrayUdfValReplacer::totalnr_
const od_int64 totalnr_
Definition: arrayndalgo.h:2155
ArrayUdfValReplacer::setSampling
void setSampling(const TrcKeySampling &tks, const PosInfo::CubeData *trcssampling)
Definition: arrayndalgo.h:2039
ArrayMath::CumSumExec::sumvals_
TypeSet< T > sumvals_
Definition: arrayndalgo.h:1623
BendPointBasedMathFunction::getValue
yT getValue(xT x) const
Definition: mathfunc.h:167
Array3DCopier::doPrepare
bool doPrepare(int)
Definition: arrayndalgo.h:986
ArrayMath::CumArrOperExec::uiMessage
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndalgo.h:1259
ArrayMath::val2
const T val2
Definition: arrayndalgo.h:1706
Array3DUdfTrcRestorer::tks_
const TrcKeySampling & tks_
Definition: arrayndalgo.h:2309
ArrayNDWindow::rectangular_
bool rectangular_
Definition: arrayndalgo.h:429
ParallelTask::sPosFinished
static uiString sPosFinished()
Definition: paralleltask.h:88
ArrayMath::getSumArrays
void getSumArrays(const ArrayND< T > &in1, const ArrayND< T > &in2, ArrayND< T > &out, double fact1, double fact2, bool noudf, bool parallel)
computes the sum array between two arrays with scaling
Definition: arrayndalgo.h:1714
ArrayMath::mDefParallelCalc6Pars
mDefParallelCalc6Pars(SumExec, od_static_tr("SumExec","Array addition executor"), const T *, arr1, const T *, arr2, T *, out, T, fact1, T, fact2, bool, noudf) mDefParallelCalcBody(
Array2DCopier::doPrepare
bool doPrepare(int)
Definition: arrayndalgo.h:862
ArrayMath::ArrOperExec::setShift
void setShift(double shift)
Definition: arrayndalgo.h:1458
Array2DCopier::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:894
Math::Sqrt
float Sqrt(float)
Array3DUdfTrcRestorer::doWork
bool doWork(od_int64 start, od_int64 stop, int)
Definition: arrayndalgo.h:2255
getMax
T getMax(const ArrayND< T > &in)
returns the Maximum of all defined values in the ArrrayND. Returns UDF if empty or only udfs encounte...
Definition: arrayndalgo.h:201
ArrayMath::CumSumExec::mODTextTranslationClass
mODTextTranslationClass(CumSumExec)
PolyTrend::apply
void apply(const Coord &pos, bool dir, T &) const
Definition: arrayndalgo.h:1178
Array2DCopier::in_
const Array2D< T > & in_
Definition: arrayndalgo.h:945
ArrayMath::CumArrOperExec::cumsum_
RT cumsum_
Definition: arrayndalgo.h:1327
Array2DCopier::canCopyAll
bool canCopyAll() const
Definition: arrayndalgo.h:856
PolyTrend::f0_
double f0_
Definition: arrayndalgo.h:1124
TrcKeySampling::includes
bool includes(const TrcKeySampling &, bool ignoresteps=false) const
mNINT32
#define mNINT32(x)
Definition: commondefs.h:58
ArrayMath::ArrOperExec::sz_
od_uint64 sz_
Definition: arrayndalgo.h:1482
ArrayMath::arrout_
arrout_[idx]
Definition: arrayndalgo.h:1684
ArrayNDWindow::mDeclareEnumUtils
mDeclareEnumUtils(WindowType)
Array1D::get
virtual T get(int) const =0
ArrayMath::CumArrOperExec
Parallel task for computing the sum of element wise operations of one array and optionally a second i...
Definition: arrayndalgo.h:1244
ArrayMath::ArrOperExec::uiNrDoneText
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndalgo.h:1447
ArrayMath::CumArrOperExec::mODTextTranslationClass
mODTextTranslationClass(CumArrOperExec)
ArrayMath::CumArrOperExec::yarr_
const ArrayND< AT > * yarr_
Definition: arrayndalgo.h:1324
LargeValVec< od_uint64 >
ArrayUdfValReplacer::tks_
const TrcKeySampling * tks_
Definition: arrayndalgo.h:2153
ArrayMath::ArrOperExec::noudf_
bool noudf_
Definition: arrayndalgo.h:1483
Array2D
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:140
ArrayND::getData
const T * getData() const
Definition: arraynd.h:54
Array2DCopier::tksout_
const TrcKeySampling & tksout_
Definition: arrayndalgo.h:947
ArrayMath::ArrOperExec::ArrOperExec
ArrOperExec(const ArrayND< ArrType > &xvals, const ArrayND< ArrType > *yvals, bool noudf, const ArrayOperExecSetup &setup, ArrayND< ArrType > &outvals)
Definition: arrayndalgo.h:1432
ArrayNDWindow::getParamVal
float getParamVal() const
Definition: arrayndalgo.h:364
PolyTrend
Polynomial trend with order 0 (mean), 1 (linear) or 2 (parabolic) The trend is derived from a set of ...
Definition: arrayndalgo.h:1094
ArrayMath::out_
out_[idx]
Definition: arrayndalgo.h:1709
TypeSet< int >
ArrayNDWindow::resize
bool resize(const ArrayNDInfo &)
ArrayUdfValRestorer::undefidxs_
const LargeValVec< od_uint64 > & undefidxs_
Definition: arrayndalgo.h:2221
interpUdf
bool interpUdf(Array1D< fT > &in, typename BendPointBasedMathFunction< fT, fT >::InterpolType ipoltyp=BendPointBasedMathFunction< fT, fT >::Poly)
Definition: arrayndalgo.h:311
coord.h
PolyTrend::getOrder
Order getOrder() const
Definition: arrayndalgo.h:1113

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