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

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