-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
NextSamples.cpp
75 lines (65 loc) · 2.02 KB
/
NextSamples.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Restructuring Shogun's statistical hypothesis testing framework.
* Copyright (C) 2016 Soumyajit De
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http:/www.gnu.org/licenses/>.
*/
#include <shogun/features/Features.h>
#include <shogun/statistical_testing/internals/NextSamples.h>
using namespace shogun;
using namespace internal;
NextSamples::NextSamples(index_t num_distributions) : m_num_blocks(0)
{
next_samples.resize(num_distributions);
}
NextSamples& NextSamples::operator=(const NextSamples& other)
{
clear();
m_num_blocks=other.m_num_blocks;
next_samples=other.next_samples;
return *this;
}
NextSamples::~NextSamples()
{
clear();
}
std::vector<Block>& NextSamples::operator[](size_t i)
{
REQUIRE(i>=0 && i<next_samples.size(),
"index (%d) must be between [0,%d]!\n",
i, next_samples.size()-1);
return next_samples[i];
}
const std::vector<Block>& NextSamples::operator[](size_t i) const
{
REQUIRE(i>=0 && i<next_samples.size(),
"index (%d) must be between [0,%d]!\n",
i, next_samples.size()-1);
return next_samples[i];
}
const index_t NextSamples::num_blocks() const
{
return m_num_blocks;
}
const bool NextSamples::empty() const
{
using type=const std::vector<Block>;
return std::any_of(next_samples.cbegin(), next_samples.cend(), [](type& f) { return f.size()==0; });
}
void NextSamples::clear()
{
using type=std::vector<Block>;
std::for_each(next_samples.begin(), next_samples.end(), [](type& f) { f.clear(); });
next_samples.clear();
}