diff --git a/src/shogun/statistical_testing/MMD.cpp b/src/shogun/statistical_testing/MMD.cpp index d0b99b2400c..030b0f0a062 100644 --- a/src/shogun/statistical_testing/MMD.cpp +++ b/src/shogun/statistical_testing/MMD.cpp @@ -1,19 +1,31 @@ /* - * Restructuring Shogun's statistical hypothesis testing framework. - * Copyright (C) 2016 Soumyajit De + * Copyright (c) The Shogun Machine Learning Toolbox + * Written (w) 2016 Soumyajit De + * All rights reserved. * - * 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. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * 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. + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the Shogun Development Team. */ #include @@ -68,6 +80,8 @@ struct CMMD::Self std::function)> statistic_job; std::function)> permutation_job; std::function)> variance_job; + + KernelManager kernel_selection_mgr; }; CMMD::Self::Self(CMMD& cmmd) : owner(cmmd), @@ -309,6 +323,11 @@ CMMD::~CMMD() { } +void CMMD::add_kernel(CKernel* kernel) +{ + self->kernel_selection_mgr.push_back(kernel); +} + float64_t CMMD::compute_statistic() { return self->compute_statistic_variance().first; diff --git a/src/shogun/statistical_testing/MMD.h b/src/shogun/statistical_testing/MMD.h index 8f4d4ea480b..9d62df93ee3 100644 --- a/src/shogun/statistical_testing/MMD.h +++ b/src/shogun/statistical_testing/MMD.h @@ -1,19 +1,31 @@ /* - * Restructuring Shogun's statistical hypothesis testing framework. - * Copyright (C) 2016 Soumyajit De + * Copyright (c) The Shogun Machine Learning Toolbox + * Written (w) 2016 Soumyajit De + * All rights reserved. * - * 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. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * 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. + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those + * of the authors and should not be interpreted as representing official policies, + * either expressed or implied, of the Shogun Development Team. */ #ifndef MMD_H_ @@ -64,8 +76,9 @@ class CMMD : public CTwoSampleTest public: CMMD(); virtual ~CMMD(); -/* + void add_kernel(CKernel *kernel); +/* void select_kernel(EKernelSelectionMethod kmethod); CKernel* get_kernel() const; */ diff --git a/src/shogun/statistical_testing/internals/KernelManager.cpp b/src/shogun/statistical_testing/internals/KernelManager.cpp index c6fde0d7794..e45c1d2eb37 100644 --- a/src/shogun/statistical_testing/internals/KernelManager.cpp +++ b/src/shogun/statistical_testing/internals/KernelManager.cpp @@ -38,6 +38,11 @@ using namespace shogun; using namespace internal; +KernelManager::KernelManager() +{ + SG_SDEBUG("Kernel manager instance initialized!\n"); +} + KernelManager::KernelManager(index_t num_kernels) { SG_SDEBUG("Kernel manager instance initialized with %d kernels!\n", num_kernels); @@ -77,6 +82,14 @@ CKernel* KernelManager::kernel_at(size_t i) const return m_precomputed_kernels[i].get(); } +void KernelManager::push_back(CKernel* kernel) +{ + SG_SDEBUG("Entering!\n"); + SG_REF(kernel); + m_kernels.push_back(std::shared_ptr(kernel, [](CKernel* ptr) { SG_UNREF(ptr); })); + SG_SDEBUG("Leaving!\n"); +} + void KernelManager::precompute_kernel_at(size_t i) { SG_SDEBUG("Entering!\n"); diff --git a/src/shogun/statistical_testing/internals/KernelManager.h b/src/shogun/statistical_testing/internals/KernelManager.h index 16d2725f5d1..52118d817b9 100644 --- a/src/shogun/statistical_testing/internals/KernelManager.h +++ b/src/shogun/statistical_testing/internals/KernelManager.h @@ -48,12 +48,15 @@ namespace internal class KernelManager { public: - KernelManager(index_t num_kernels); + KernelManager(); + explicit KernelManager(index_t num_kernels); ~KernelManager(); InitPerKernel kernel_at(size_t i); CKernel* kernel_at(size_t i) const; + void push_back(CKernel* kernel); + void precompute_kernel_at(size_t i); void restore_kernel_at(size_t i); private: