File: filter_nan.cpp

package info (click to toggle)
odin 2.0.5-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,196 kB
  • sloc: cpp: 62,638; sh: 4,541; makefile: 779
file content (29 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// C++ Implementation: filter_nan
//
// Description: 
//
//
// Author:  <Enrico Reimer>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "filter_nan.h"

void FilterNaN::init(){
  replace=0;
  replace.set_description("Replacement value");
  append_arg(replace,"replace");
}

bool FilterNaN::process(Data<float,4>& data, Protocol& prot)const{
  //replace all elements by replace where element does NOT equal itself (which is only true for NaN)
  TinyVector<int,4> indexvec;
  for(unsigned int i=0; i<data.numElements(); i++) {
    indexvec=data.create_index(i);
    float val=data(indexvec);
    if(!(val == val)) data(indexvec)=replace;
  }
  return true;
}