Exemplo n.º 1
0
int main(int argc, char *argv[]) {
  g_conf.number_of_feature = 3;
  g_conf.max_depth = 4;
  if (argc > 1) {
    g_conf.max_depth = boost::lexical_cast<int>(argv[1]);
  }

  DataVector d;
  bool r = LoadDataFromFile("../../data/train.dat", &d);
  assert(r);

  RegressionTree tree;

  tree.Fit(&d);
  std::ofstream model_output("../../data/model");
  model_output << tree.Save();

  RegressionTree tree2;
  tree2.Load(tree.Save());

  DataVector::iterator iter = d.begin();
  PredictVector predict;
  for ( ; iter != d.end(); ++iter) {
    std::cout << (*iter)->ToString() << std::endl;
    ValueType p = tree2.Predict(**iter);
    predict.push_back(p);
    std::cout << p << "," << tree.Predict(**iter) << std::endl;
  }

  std::cout << "rmse: " << RMSE(d, predict) << std::endl;

  CleanDataVector(&d);
  return 0;
}
Exemplo n.º 2
0
/**
 * Test DataFilters
 */
void test_datafilters()
{

    std::vector<std::string> datas;
    datas.push_back("1");
    datas.push_back("2");
    datas.push_back("3");
    
    DataVector datav;
    datav.push_back(DataPoint(1,true));
    datav.push_back(DataPoint(2,true));
    datav.push_back(DataPoint(3,true));

    DataFilters filters;
    ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on string vector with no filter");
    ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with no filter");

    filters.addNumericFilter(0,1,1,true);
    ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with numeric accepting filter on 0");
    
    filters.addNumericFilter(1,4,4,false);
    ASSERT(filters.isFiltered(datav), "DataFilters::isFiltered failed on data vector with numeric rejection filter on 1");

    filters.addStringFilter(0,"1",true,true,true);
    ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on data vector with string accepting filter on 0");
    
    filters.addStringFilter(1,"4",true,true,false);
    ASSERT(filters.isFiltered(datas), "DataFilters::isFiltered failed on data vector with string rejection filter on 1");

}
Exemplo n.º 3
0
    /** Expands the cluster order while adding new neighbor points to the order.
     * @param db All data points that are to be considered by the algorithm. Changes their values.
     * @param p The point to be examined.
     * @param eps The epsilon representing the radius of the epsilon-neighborhood.
     * @param min_pts The minimum number of points to be found within an epsilon-neigborhood.
     * @param[out] o_ordered_vector The ordered vector of data points. Elements will be added to this vector.
     */
    void expand_cluster_order( DataVector& db, DataPoint* p, const real eps, const unsigned int min_pts, DataVector& o_ordered_vector) {
        assert( eps >= 0 && "eps must not be negative");
        assert( min_pts > 0 && "min_pts must be greater than 0");
        
        DataVector N_eps = get_neighbors( p, eps, db);
        p->reachability_distance( OPTICS::UNDEFINED);
        const real core_dist_p = squared_core_distance( p, min_pts, N_eps);
        p->processed( true);
        o_ordered_vector.push_back( p);
    
        if( core_dist_p == OPTICS::UNDEFINED)
            return;

        DataSet seeds;
        update_seeds( N_eps, p, core_dist_p, seeds);
        
        while( !seeds.empty()) {
            DataPoint* q = *seeds.begin();
            seeds.erase( seeds.begin()); // remove first element from seeds

            DataVector N_q = get_neighbors( q, eps, db);
            const real core_dist_q = squared_core_distance( q, min_pts, N_q);
            q->processed( true);
            o_ordered_vector.push_back( q);
            if( core_dist_q != OPTICS::UNDEFINED) {
                // *** q is a core-object ***
                update_seeds( N_q, q, core_dist_q, seeds);
            }
        }
    }
Exemplo n.º 4
0
    void FancyMeshSystem::handleDataLoading( Ra::Engine::Entity* entity, const std::string& rootFolder, 
                                             const std::map<std::string, Ra::Core::Any>& data )
    {
        LOG(logDEBUG) << "FancyMeshSystem : loading " << data.size() << " data items...";

        // Find mesh
        std::string filename;
        auto meshData = data.find("mesh");
        if ( meshData != data.end() )
        {
            filename = rootFolder + "/" + meshData->second.as<std::string>();
        }

        DataVector componentsData = FancyMeshLoader::loadFile( filename );

        if (componentsData.empty())
        {
            // Something wrong happened while trying to load the file
            return;
        }

        if (componentsData.size() > 1)
        {
            LOG(logWARNING) << "Too much objects have been loaded, some data will be ignored.";
        }

        FancyComponentData componentData = componentsData[0];

        FancyMeshComponent* component = static_cast<FancyMeshComponent*>(addComponentToEntity(entity));
        component->handleMeshLoading(componentData);
    }
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
  struct shm_remove
  {
     shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
     ~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
  } remover;
  boost::interprocess::managed_shared_memory segment(boost::interprocess::create_only, "MySharedMemory", 65536);
  const ShmemAllocator alloc_inst (segment.get_segment_manager());
  DataVector *myvector = segment.construct<DataVector>("MyVector")(alloc_inst);
  for(int i = 0; i < 6; ++i) { //Insert data in the vector
    printf("%d ", i);
     myvector->push_back(i*3);
  }
  while(1)
  {
      for(int i = 0; i < 6; ++i) { //Insert data in the vector
        printf("%d ", i);
         myvector->at(i) = rand()*rand();
         printf("%f ", myvector->at(i));
      }
      printf("\n");
  }
return 0;
};
Exemplo n.º 6
0
    /** Updates the seeds priority queue with new neighbors or neighbors that now have a better 
     * reachability distance than before.
     * @param N_eps All points in the the epsilon-neighborhood of the center_object, including p itself.
     * @param center_object The point on which to start the update process.
     * @param c_dist The core distance of the given center_object.
     * @param[out] o_seeds The seeds priority queue (aka set with special comparator function) that will be modified.
     */
    void update_seeds( const DataVector& N_eps, const DataPoint* center_object, const real c_dist, DataSet& o_seeds) {
        assert( c_dist != OPTICS::UNDEFINED && "the core distance must be set <> UNDEFINED when entering update_seeds");
        
        for( DataVector::const_iterator it=N_eps.begin(); it!=N_eps.end(); ++it) {
            DataPoint* o = *it;

            if( o->is_processed())
                continue;

            const real new_r_dist = std::max( c_dist, squared_distance( center_object, o));
            // *** new_r_dist != UNDEFINED ***
        
            if( o->reachability_distance() == OPTICS::UNDEFINED) {
                // *** o not in seeds ***
                o->reachability_distance( new_r_dist);
                o_seeds.insert( o);

            } else if( new_r_dist < o->reachability_distance()) {
                // *** o already in seeds & can be improved ***
                o_seeds.erase( o);
                o->reachability_distance( new_r_dist);
                o_seeds.insert( o);
            }
        }
    }
Exemplo n.º 7
0
//notes: after using buffer, this function deletes buffer.
DataVector convertBufferIntoVector(char* buffer){
  DataVector ColumnData;
  char*p = nextNoneSpacePointer(buffer);
  while ('\0' != *p){
    std::vector< double > lineData;
    lineData.reserve(200);
    while ('\n' != *p && '\0' != *p){
      std::size_t dataOffset = 0;
      char *dataBeginning = p;
      while (' ' != *p && '\n' != *p && '\0' != *p) {
        ++dataOffset;
        ++p;
      }
      char *dataBuf = new char[dataOffset + 1];
      memcpy(dataBuf, dataBeginning, dataOffset);
      dataBuf[dataOffset] = '\0';
      double dataValue = atof(dataBuf);
      delete[] dataBuf;
      lineData.push_back(dataValue);
      p = nextNoneSpacePointer(p);
    }
    if (lineData.size() > 0) ColumnData.push_back(lineData);
    if ('\0' != *p) ++p;
  }
  delete[] buffer;
  return ColumnData;
}
  /**
   * Performs a transposed mass evaluation
   *
   * @param storage GridStorage object that contains the grid's points information
   * @param basis a reference to a class that implements a specific basis
   * @param source the coefficients of the grid points
   * @param x the d-dimensional vector with data points (row-wise)
   * @param result the result vector of the matrix vector multiplication
   */
  void mult_transpose(GridStorage* storage, BASIS& basis, DataVector& source,
                      DataMatrix& x, DataVector& result) {
    result.setAll(0.0);
    size_t source_size = source.getSize();

    #pragma omp parallel
    {
      DataVector privateResult(result.getSize());
      privateResult.setAll(0.0);

      DataVector line(x.getNcols());
      AlgorithmEvaluationTransposed<BASIS> AlgoEvalTrans(storage);

      privateResult.setAll(0.0);


      #pragma omp for schedule(static)

      for (size_t i = 0; i < source_size; i++) {
        x.getRow(i, line);

        AlgoEvalTrans(basis, line, source[i], privateResult);
      }

      #pragma omp critical
      {
        result.add(privateResult);
      }
    }
  }
Exemplo n.º 9
0
util::Clustering::Clustering(const DataVector& _data, unsigned _max) : m_maxClusters(_max) {
	m_data.insert(m_data.begin(), _data.begin(), _data.end());
	
	ClusterMap clusterQualityScores;
	
	for (unsigned clusterCount = 1; clusterCount <= m_maxClusters; clusterCount++) {
		clusterQualityScores[clusterCount] = _kmeans(clusterCount);
	}
		
	std::vector< CountClusterPair > sortedScores;
	std::copy(clusterQualityScores.begin(), clusterQualityScores.end(), std::back_inserter(sortedScores));
	ScoreComparator comparator;
	std::sort(sortedScores.begin(), sortedScores.end(), comparator);

	report("Scores:");
	for (int i = 0; i < sortedScores.size(); i++) {
		report(sortedScores[i].first << " clusters: " << sortedScores[i].second.getScore());
	}
	
	report("Clustering with highest score: ");
	report(util::Indents(2) << "cluster count: " << sortedScores[0].first);
	report(util::Indents(2) << "aggregate score: " << sortedScores[0].second.getScore());
	report(util::Indents(2) << "detected clusters:");
	for (auto it = sortedScores[0].second.getClusters().begin(); it != sortedScores[0].second.getClusters().end(); ++it) {
		const Cluster& cluster = *it;
		report(util::Indents(4) << "position = " << cluster.position << ", elements = " << cluster.data.size());
	}
	
	result = sortedScores[0].second;
}
Exemplo n.º 10
0
void test_mean()
{
    DataVector d;
    for (int i=1; i<=9; ++i)
        d.push_back(i);

    unit_assert(d.mean() == 5.0);
}
void SolveEvolutionMatrix(
	DataMatrix<double> & matM,
	DataMatrix<double> & matB,
	DataVector<double> & vecAlphaR,
	DataVector<double> & vecAlphaI,
	DataVector<double> & vecBeta,
	DataMatrix<double> & matVR
) {
	int iInfo = 0;

	char jobvl = 'N';
	char jobvr = 'V';

	int n = matM.GetRows();
	int lda = matM.GetRows();
	int ldb = matM.GetRows();
	int ldvl = 1;
	int ldvr = matVR.GetRows();

	DataVector<double> vecWork;
	vecWork.Initialize(8 * n);
	int lwork = vecWork.GetRows();

	dggev_(
		&jobvl,
		&jobvr,
		&n,
		&(matM[0][0]),
		&lda,
		&(matB[0][0]),
		&ldb,
		&(vecAlphaR[0]),
		&(vecAlphaI[0]),
		&(vecBeta[0]),
		NULL,
		&ldvl,
		&(matVR[0][0]),
		&ldvr,
		&(vecWork[0]),
		&lwork,
		&iInfo);

	int nCount = 0;
	for (int i = 0; i < n; i++) {
		if (vecBeta[i] != 0.0) {
			//printf("%i %1.5e %1.5e\n", i, vecAlphaR[i] / vecBeta[i], vecAlphaI[i] / vecBeta[i]);
			nCount++;
		}
	}
/*
	for (int i = 0; i < 40; i++) {
		printf("%1.5e %1.5e\n", matVR[11][4*i+2], matVR[12][4*i+2]);
	}
*/
	Announce("%i total eigenvalues found", nCount);
}
Exemplo n.º 12
0
int main(int argc, char *argv[])
{
      boost::interprocess::managed_shared_memory segment(boost::interprocess::open_only, "MySharedMemory");
      DataVector *myvector = segment.find<DataVector>("MyVector").first;
      for(int i = 0; i < 100; ++i)  //Insert data in the vector
      {
        printf("%f ", (float)myvector->at(i));
      }
   return 0;
};
Exemplo n.º 13
0
void convertGrayToRGB( DataVector& dataVec, size_t width, size_t height, int pixelSize )
{
	size_t size = width * height;
	switch( pixelSize )
	{
		case 1 :
		{
			char* ptrS = (char*) &dataVec.front();
			char* ptrD = (char*) &dataVec.front();
			// go to end of image
			ptrS += size - 1;
			ptrD += (3 * size) - 1;
			// process from back to begin
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrD--; // red
				*ptrD = *ptrS; ptrD--; // green
				*ptrD = *ptrS; ptrD--; ptrS--; // blue
			}
			break;
		}
		case 2:
		{
			short* ptrS = (short*) &dataVec.front();
			short* ptrD = (short*) &dataVec.front();
			// go to end of image
			ptrS += size - 1;
			ptrD += (3 * size) - 1;
			// process from back to begin
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrD--; // red
				*ptrD = *ptrS; ptrD--; // green
				*ptrD = *ptrS; ptrD--; ptrS--; // blue
			}
			break;
		}
		case 4 :
		{
			float* ptrS = (float*) &dataVec.front();
			float* ptrD = (float*) &dataVec.front();
			// go to end of image
			ptrS += size - 1;
			ptrD += (3 * size) - 1;
			// process from back to begin
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrD--; // red
				*ptrD = *ptrS; ptrD--; // green
				*ptrD = *ptrS; ptrD--; ptrS--; // blue
			}
			break;
		}
	}
}
uint8 RadialMenuManager::findNextId            (const DataVector & dv)
{
	uint8 id = 1;
	for (DataVector::const_iterator it = dv.begin (); it != dv.end (); ++it)
	{
		const ObjectMenuRequestData & data = *it;
		id = std::max (id, static_cast<uint8>(data.m_id + 1));
	}
	
	return id;
}
Exemplo n.º 15
0
double RMSE(const DataVector &data, const PredictVector &predict, size_t len) {
  assert(data.size() >= len);
  assert(predict.size() >= len);
  double s = 0;
  double c = 0;

  for (size_t i = 0; i < data.size(); ++i) {
    s += Squared(predict[i] - data[i]->label) * data[i]->weight;
    c += data[i]->weight;
  }

  return std::sqrt(s / c);
}
Exemplo n.º 16
0
    /** Finds the squared core distance of one given point.
     * @param p The point to be examined.
     * @param min_pts The minimum number of points to be found within an epsilon-neigborhood.
     * @param N_eps All points in the the epsilon-neighborhood of p, including p itself.
     * @return The squared core distance of p.
     */
    real squared_core_distance( const DataPoint* p, const unsigned int min_pts, DataVector& N_eps) {    
        assert( min_pts > 0 && "min_pts must be greater than 0");
        real ret( OPTICS::UNDEFINED);
    
        if( N_eps.size() > min_pts) {
            std::nth_element( N_eps.begin(), 
                              N_eps.begin()+min_pts, 
                              N_eps.end(), 
                              [p]( const DataPoint* a, const DataPoint* b){ return squared_distance( p, a) < squared_distance( p, b); } );

            ret = squared_distance( p, N_eps[min_pts]);
        }
        return ret;
    }
Exemplo n.º 17
0
    /** Retrieves all points in the epsilon-surrounding of the given data point, including the point itself.
     * @param p The datapoint which represents the center of the epsilon surrounding.
     * @param eps The epsilon value that represents the radius for the neigborhood search.
     * @param db The database consisting of all datapoints that are checked for neighborhood.
     * @param A vector of pointers to datapoints that lie within the epsilon-neighborhood 
     *        of the given point p, including p itself.
     */
    DataVector get_neighbors( const DataPoint* p, const real eps, DataVector& db) {
        assert( eps >= 0 && "eps must not be negative");
        DataVector ret;

        const real eps_sq = eps*eps;

        for( auto q_it=db.begin(); q_it!=db.end(); ++q_it) {
            DataPoint* q = *q_it;
            if( squared_distance( p, q) <= eps_sq) {
                ret.push_back( q);
            }
        }
        return ret;
    }
Exemplo n.º 18
0
    /** Performs the classic OPTICS algorithm.
     * @param db All data points that are to be considered by the algorithm. Changes their values.
     * @param eps The epsilon representing the radius of the epsilon-neighborhood.
     * @param min_pts The minimum number of points to be found within an epsilon-neigborhood.
     * @return Return the OPTICS ordered list of Data points with reachability-distances set.
     */
    DataVector optics( DataVector& db, const real eps, const unsigned int min_pts) {
        assert( eps >= 0 && "eps must not be negative");
        assert( min_pts > 0 && "min_pts must be greater than 0");
        DataVector ret;

        for( auto p_it = db.begin(); p_it != db.end(); ++p_it) {
            DataPoint* p = *p_it;
            
            if( p->is_processed())
                continue;
            
            expand_cluster_order( db, p, eps, min_pts, ret);
        }
        return ret;
    }
Exemplo n.º 19
0
// -----------------------------------------------------------------------------
// Validation of a constraint violation data file.
// The validation is done using the specified norm type and tolerance. The
// function returns true if the norms of all columns, excluding the first one,
// are below the given tolerance and false otherwise.
// It is assumed that the input file is TAB-delimited.
// -----------------------------------------------------------------------------
bool Validate(const std::string& sim_filename,
              ChNormType         norm_type,
              double             tolerance,
              DataVector&        norms)
{
  ChValidation validator;

  if (!validator.Process(sim_filename))
    return false;

  size_t num_cols = validator.GetNumColumns() - 1;
  norms.resize(num_cols);

  switch (norm_type) {
  case L2_NORM:  norms = validator.GetL2norms(); break;
  case RMS_NORM: norms = validator.GetRMSnorms(); break;
  case INF_NORM: norms = validator.GetINFnorms(); break;
  }

  for (size_t col = 0; col < num_cols; col++) {
    if (norms[col] > tolerance)
      return false;
  }

  return true;
}
Exemplo n.º 20
0
std::auto_ptr<FitResult> Fitter::fit(const DataVector &data, IFMLFunction &f) const
{
  std::auto_ptr<IFMLDataIterator> it = data.createIterator();

  if(!it.get()) return std::auto_ptr<FitResult>();

  return fit(*it.get(),f);
}
SGPP::float_t parabolaBoundary(DataVector& input) {
  SGPP::float_t result = 1.;

  for (size_t i = 0; i < input.getSize(); i++) {
    result *= 0.25 * (input[i] - 0.7) * (input[i] - 0.7) + 2;
  }

  return result;
}
SGPP::float_t parabola(DataVector& input) {
  SGPP::float_t result = 1.;

  for (size_t i = 0; i < input.getSize(); i++) {
    result *= input[i] * (1. - input[i]) * 4.;
  }

  return result;
}
Exemplo n.º 23
0
    void FancyMeshSystem::handleFileLoading( const std::string& filename )
    {
        DataVector componentsData = FancyMeshLoader::loadFile( filename );

        for ( uint i = 0; i < componentsData.size(); ++i )
        {
            FancyComponentData data = componentsData[i];

            // Retrieve entity if exist, create it otherwise
            Ra::Engine::Entity* e = m_engine->getEntityManager()->getOrCreateEntity( data.name );
            e->setTransform( data.transform );

            FancyMeshComponent* component =
                static_cast<FancyMeshComponent*>( addComponentToEntity( e ) );

            component->handleMeshLoading( data );
        }
    }
Exemplo n.º 24
0
void convertRGBAToRGB( DataVector& dataVec, size_t width, size_t height, int pixelSize )
{
	size_t size = width * height;

	switch( pixelSize )
	{
		case 4 :
		{
			char* ptrS = (char*) &dataVec.front();
			char* ptrD = ptrS;
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrS++; ptrD++; // red
				*ptrD = *ptrS; ptrS++; ptrD++; // green
				*ptrD = *ptrS; ptrS+=2;/*skip alpha*/ ptrD++; // blue
			}
			break;
		}
		case 8:
		{
			short* ptrS = (short*) &dataVec.front();
			short* ptrD = ptrS;
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrS++; ptrD++; // red
				*ptrD = *ptrS; ptrS++; ptrD++; // green
				*ptrD = *ptrS; ptrS+=2;/*skip alpha*/ ptrD++; // blue
			}
			break;
		}
		case 16 :
		{
			float* ptrS = (float*) &dataVec.front();
			float* ptrD = ptrS;
			for(size_t i = 0; i< size; i++)
			{
				*ptrD = *ptrS; ptrS++; ptrD++; // red
				*ptrD = *ptrS; ptrS++; ptrD++; // green
				*ptrD = *ptrS; ptrS+=2;/*skip alpha*/ ptrD++; // blue
			}
		}
	}
}
Exemplo n.º 25
0
 DataVector<T> IntAutoTimeGiven( DataVector<T>& autocorr){
   DataVector<T> tau(L);
   T temp;
   for(int i=0; i<L; i++){
     temp=autocorr.PartialSumVector(i);
     tau[i]+=temp;
   }
   //    tau/=autocorr[0];
   tau=tau+Scalar(0.5);
   return tau;    
 }
  /**
   * Performs a mass evaluation
   *
   * @param storage GridStorage object that contains the grid's points information
   * @param basis a reference to a class that implements a specific basis
   * @param source the coefficients of the grid points
   * @param x the d-dimensional vector with data points (row-wise)
   * @param result the result vector of the matrix vector multiplication
   */
  void mult(GridStorage* storage, BASIS& basis, DataVector& source, DataMatrix& x,
            DataVector& result) {
    result.setAll(0.0);
    size_t result_size = result.getSize();


    #pragma omp parallel
    {
      DataVector line(x.getNcols());
      AlgorithmEvaluation<BASIS> AlgoEval(storage);

      #pragma omp for schedule(static)

      for (size_t i = 0; i < result_size; i++) {
        x.getRow(i, line);

        result[i] = AlgoEval(basis, line, source);
      }
    }
  }
Exemplo n.º 27
0
ValueType Average(const DataVector & data, size_t len) {
  assert(len <= data.size());
  if (len == 0)
    return 0;
  double s = 0;
  double c = 0;
  for (size_t i = 0; i < len; ++i) {
    s += data[i]->target * data[i]->weight;
    c += data[i]->weight;
  }
  return static_cast<ValueType>(s / c);
}
Exemplo n.º 28
0
bool Same(const DataVector &data, size_t len) {
  assert(len <= data.size());
  if (len <= 1)
    return true;

  ValueType t = data[0]->target;
  for (size_t i = 1; i < len; ++i) {
    if (!AlmostEqual(t, data[i]->target))
      return false;
  }
  return true;
}
void
WindowingThread::OnProcess( const GenericSignal& Input, GenericSignal& Output )
{
  for( size_t ch = 0; ch < Channels().size(); ++ch )
  {
    // Fill the rightmost part of the buffer with new input:
    size_t i = max<ptrdiff_t>( 0, mBuffers[ch].size() - mInputElements ),
           j = 0;
    while( i < mBuffers[ch].size() )
      mBuffers[ch][i++] = Input( Channels()[ch], j++ );

    DataVector* pDetrendedData = NULL;
    switch( mDetrend )
    {
      case None:
        pDetrendedData = &mBuffers[ch];
        break;

      case Mean:
        Detrend::MeanDetrend( mBuffers[ch], mDetrendBuffer );
        pDetrendedData = &mDetrendBuffer;
        break;

      case Linear:
        Detrend::LinearDetrend( mBuffers[ch], mDetrendBuffer );
        pDetrendedData = &mDetrendBuffer;
        break;

      default:
        throw std_logic_error( "Unknown detrend option" );
    }

    if( mWindowFunction == Rectangular )
      for( size_t i = 0; i < pDetrendedData->size(); ++i )
        Output( Channels()[ch], i ) = ( *pDetrendedData )[i];
    else
      for( size_t i = 0; i < pDetrendedData->size(); ++i )
        Output( Channels()[ch], i ) = mWindow[i] * ( *pDetrendedData )[i];
  }
}
float_t OperationNaiveEvalGradientWavelet::evalGradient(
  const DataVector& alpha, const DataVector& point, DataVector& gradient) {
  const size_t n = storage->size();
  const size_t d = storage->dim();
  float_t result = 0.0;

  gradient.resize(storage->dim());
  gradient.setAll(0.0);

  DataVector curGradient(d);

  for (size_t i = 0; i < n; i++) {
    const GridIndex& gp = *(*storage)[i];
    float_t curValue = 1.0;
    curGradient.setAll(alpha[i]);

    for (size_t t = 0; t < d; t++) {
      const float_t val1d = base.eval(gp.getLevel(t), gp.getIndex(t), point[t]);
      const float_t dx1d = base.evalDx(gp.getLevel(t), gp.getIndex(t),
                                       point[t]);

      curValue *= val1d;

      for (size_t t2 = 0; t2 < d; t2++) {
        if (t2 == t) {
          curGradient[t2] *= dx1d;
        } else {
          curGradient[t2] *= val1d;
        }
      }
    }

    result += alpha[i] * curValue;
    gradient.add(curGradient);
  }

  return result;
}