00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Heiko Strathmann 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #include <shogun/features/Subset.h> 00012 #include <shogun/io/SGIO.h> 00013 #include <shogun/base/Parameter.h> 00014 00015 using namespace shogun; 00016 00017 CSubset::CSubset() : m_subset_idx(SGVector<index_t>()) 00018 { 00019 init(); 00020 } 00021 00022 CSubset::CSubset(SGVector<index_t> subset_idx) : m_subset_idx(subset_idx) 00023 { 00024 init(); 00025 } 00026 00027 CSubset::~CSubset() { 00028 SG_FREE(m_subset_idx.vector); 00029 } 00030 00031 CSubset* CSubset::duplicate() { 00032 SGVector<index_t> idx_copy(m_subset_idx.vlen); 00033 00034 memcpy(idx_copy.vector, m_subset_idx.vector, 00035 sizeof(index_t)*m_subset_idx.vlen); 00036 00037 CSubset* copy_subset=new CSubset(idx_copy); 00038 00039 return copy_subset; 00040 } 00041 00042 void CSubset::init() { 00043 m_parameters->add((CSGObject**)&m_subset_idx, "subset", 00044 "Vector of subset indices"); 00045 }