void test_func_all(TIndex& index) {
    const osmium::unsigned_object_id_type id1 = 12;
    const osmium::unsigned_object_id_type id2 = 3;
    const osmium::Location loc1{1.2, 4.5};
    const osmium::Location loc2{3.5, -7.2};

    REQUIRE_THROWS_AS(index.get(id1), const osmium::not_found&);

    index.set(id1, loc1);
    index.set(id2, loc2);

    index.sort();

    REQUIRE_THROWS_AS(index.get(0), const osmium::not_found&);
    REQUIRE_THROWS_AS(index.get(1), const osmium::not_found&);
    REQUIRE_THROWS_AS(index.get(5), const osmium::not_found&);
    REQUIRE_THROWS_AS(index.get(100), const osmium::not_found&);
    REQUIRE_THROWS_WITH(index.get(0), "id 0 not found");
    REQUIRE_THROWS_WITH(index.get(1), "id 1 not found");

    REQUIRE(index.get_noexcept(0) == osmium::Location{});
    REQUIRE(index.get_noexcept(1) == osmium::Location{});
    REQUIRE(index.get_noexcept(5) == osmium::Location{});
    REQUIRE(index.get_noexcept(100) == osmium::Location{});
}
示例#2
0
inline unsigned long long runTimePerIndexAF(CharString const dir, CharString const indexFolder, TText const & text, StringSet<TText> const & reads)
{
    clock_t t, runningTimes[ITERATIONS];
    unsigned long long sumTmp = 0;

    typedef TSchnatt TIndex;

    // prepare query sequences:
    static unsigned char pattern[READCOUNT][READLENGTH + 1];
    for (unsigned r = 0; r < READCOUNT; ++r)
    {
        CharString read(reads[r]);
        strcpy(pattern[r], toCString(read));
    }

    TIndex::searchstate s;

    // Load index
    CharString tmp;
    tmp = dir;
    tmp += indexFolder;
    tmp += "index";
    TIndex index;
    std::ifstream in(toCString(tmp));
    index.load(in);
    in.close();

    for (unsigned i = 0; i < ITERATIONS; ++i)
    {
        t = clock();
        for (int r = 0; r < READCOUNT; ++r)
        {
            index.init_search_state(s);

            for (unsigned l = READLENGTH/2+1; l < READLENGTH; ++l)
            {
                index.backward_search(index.char2comp[pattern[r][l]], s);
            }
            for (signed l = READLENGTH/2; l >= 0; --l)
            {
                index.forward_search(index.char2comp[pattern[r][l]], s);
            }
            sumTmp += s.occ_begin;

#if _MY_DEBUG == 1
            if (s.occ_end - s.occ_begin < 1)
                std::cout << "AHHHHHHHHHHHHHHHHHHH6! " << (s.occ_end - s.occ_begin) << " " << reads[0] << std::endl;
#endif
        }
        runningTimes[i] = clock() - t;
    }
    std::cout << sumTmp << std::endl;

    // Output: min, median, max
    std::sort(runningTimes, runningTimes + ITERATIONS);

    return runningTimes[(ITERATIONS-1)/2]; // return median
}
void test_func_all(TIndex& index) {
    osmium::object_id_type id1 = 12;
    osmium::object_id_type id2 = 3;
    osmium::Location loc1(1.2, 4.5);
    osmium::Location loc2(3.5, -7.2);

    BOOST_CHECK_THROW(index.get(id1), osmium::not_found);

    index.set(id1, loc1);
    index.set(id2, loc2);

    index.sort();

    BOOST_CHECK_THROW(index.get(5), osmium::not_found);
    BOOST_CHECK_THROW(index.get(100), osmium::not_found);
}
示例#4
0
CDatedData::CDatedData(const CDatedData &right, const TIndex &selectedDim) : 
date(right.date)
{
	if ( selectedDim.Size() <= 0 )
		data.CopyContent(right.data); 
	else 
	{
		TIndex validDim; 
                for (int i=0; i<selectedDim.Size(); i++)
                {
                        if (selectedDim[i] >=0 && selectedDim[i] < right.DataDimension())
                                validDim += selectedDim[i];
                }
                data = right.data.SubVector(validDim);
	}
}
示例#5
0
CDatedDataSeries::CDatedDataSeries(const TDenseMatrix &date_data_matrix, const TIndex &selectedTime, const TIndex &selectedDim)
{
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<date_data_matrix.rows; i++)
			this->push_back(CDatedData(date_data_matrix.RowVector(i),selectedDim)); 
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >= 0 && selectedTime[i] < date_data_matrix.rows)
				this->push_back(CDatedData(date_data_matrix.RowVector(selectedTime[i]), selectedDim)); 
		}
	}	
}
示例#6
0
CDatedDataSeries::CDatedDataSeries(const CDatedDataSeries &right, const TIndex &selectedTime, const TIndex &selectedDim)
{
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<right.ObservationLength(); i++)
			this->push_back(CDatedData(right[i],selectedDim));
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >=0 && selectedTime[i] < (int)(right.size()) )
				this->push_back(CDatedData(right[selectedTime[i]],selectedDim)); 
		}
	}
}
示例#7
0
CDatedData::CDatedData(const CDate &_date, const TDenseVector &_data, const TIndex &selectedDim) : 
date(_date)
{
	if (selectedDim.Size() <= 0)
		data.CopyContent(_data); 
	else 
	{
		TIndex validDim; 
		for (int i=0; i<selectedDim.Size(); i++)
		{
			if (selectedDim[i] >=0 && selectedDim[i] < _data.Dimension())
				validDim += selectedDim[i]; 
		}
		data = _data.SubVector(validDim); 
	}
}
示例#8
0
CDatedDataSeries::CDatedDataSeries(const std::vector<CDate> &date_series, const TDenseMatrix &data_matrix, const TIndex &selectedTime, const TIndex &selectedDim)
{
	int N = (int)date_series.size() <= data_matrix.rows ? (int)date_series.size() : data_matrix.rows; 
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<N; i++)
			this->push_back(CDatedData(date_series[i],data_matrix.RowVector(i,selectedDim))); 
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >= 0 && selectedTime[i] < N)
				this->push_back(CDatedData(date_series[selectedTime[i]],data_matrix.RowVector(selectedTime[i],selectedDim) )); 	
		}
	}
}
示例#9
0
CDatedDataSeries::CDatedDataSeries(const std::vector<CDate> &date_series, const std::vector<TDenseVector> &data_series, const TIndex &selectedTime, const TIndex &selectedDim)
{
	int N = (int)(date_series.size() <= data_series.size() ? date_series.size() : data_series.size()); 
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<N; i++)
			this->push_back(CDatedData(date_series[i],data_series[i],selectedDim)); 
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >= 0 && selectedTime[i] < N)
				this->push_back(CDatedData(date_series[selectedTime[i]], data_series[selectedTime[i]], selectedDim)); 
		}
	}
}
示例#10
0
std::vector<CDate> CDatedDataSeries::GetDateSeries(const TIndex &selectedTime) const
{
	std::vector<CDate> date_series; 
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<ObservationLength(); i++)
			date_series.push_back(this->operator[](i).GetDate()); 
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >= 0 || selectedTime[i] < ObservationLength())
				date_series.push_back(this->operator[](selectedTime[i]).GetDate()); 
		}
	}
	return date_series; 
}
示例#11
0
std::vector<TDenseVector> CDatedDataSeries::GetDataSeries_Vector(const TIndex &selectedTime, const TIndex &selectedDim) const
{
	std::vector<TDenseVector> data_series;
	if (selectedTime.Size() <= 0)
	{
		for (int i=0; i<ObservationLength(); i++)
			data_series.push_back(this->operator[](i).GetData(selectedDim)); 
	}
	else 
	{
		for (int i=0; i<selectedTime.Size(); i++)
		{
			if (selectedTime[i] >= 0 &&  selectedTime[i] < ObservationLength())
				data_series.push_back(this->operator[](selectedTime[i]).GetData(selectedDim)); 
		}
	}
	return data_series; 
}
示例#12
0
CDatedData::CDatedData(const TDenseVector &date_data, const TIndex &selectedDim) :
date(date_data)
{
	if (date_data.Dimension() > 3) // there are data besides date	
	{
		if (selectedDim.Size() <= 0)
			data = date_data.SubVector(3,date_data.Dimension()-1); 
		else 
		{
			TIndex validDim; 
			for (int i=0; i<selectedDim.Size(); i++)
			{
				if (selectedDim[i] >= 3 && selectedDim[i] < date_data.Dimension())
					validDim += selectedDim[i]; 
			}
			data = date_data.SubVector(validDim); 
		}
	}
}