SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
IndexBlock.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Copyright (C) 2012 Sergey Lisitsyn
8  */
9 
10 #include <shogun/lib/IndexBlock.h>
11 #include <shogun/lib/List.h>
12 
13 using namespace shogun;
14 
16  m_min_index(0), m_max_index(0),
17  m_weight(1.0), m_sub_blocks(NULL)
18 {
19  m_sub_blocks = new CList(true);
20  SG_REF(m_sub_blocks);
21 }
22 
24  float64_t weight, const char* name) :
25  CSGObject(), m_min_index(min_index), m_max_index(max_index),
26  m_weight(weight), m_sub_blocks(NULL)
27 {
28  m_sub_blocks = new CList(true);
29  SG_REF(m_sub_blocks);
30 }
31 
33 {
34  SG_UNREF(m_sub_blocks);
35 }
36 
38 {
39  ASSERT(sub_block->get_min_index()>=m_min_index)
40  ASSERT(sub_block->get_max_index()<=m_max_index)
41  m_sub_blocks->append_element(sub_block);
42 }
43 
45 {
46  SG_REF(m_sub_blocks);
47  return m_sub_blocks;
48 }
49 
51 {
52  return m_sub_blocks->get_num_elements();
53 }
int32_t index_t
Definition: common.h:62
#define SG_REF(x)
Definition: SGObject.h:54
int32_t get_num_sub_blocks()
Definition: IndexBlock.cpp:50
#define ASSERT(x)
Definition: SGIO.h:201
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
double float64_t
Definition: common.h:50
class IndexBlock used to represent contiguous indices of one group (e.g. block of related features) ...
Definition: IndexBlock.h:25
int32_t get_num_elements()
Definition: List.h:145
CList * get_sub_blocks()
Definition: IndexBlock.cpp:44
index_t get_min_index() const
Definition: IndexBlock.h:45
void add_sub_block(CIndexBlock *sub_block)
Definition: IndexBlock.cpp:37
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
bool append_element(CSGObject *data)
Definition: List.h:331
index_t get_max_index() const
Definition: IndexBlock.h:49
Class List implements a doubly connected list for low-level-objects.
Definition: List.h:84

SHOGUN Machine Learning Toolbox - Documentation