diff --git a/src/interfaces/swig/Library.i b/src/interfaces/swig/Library.i index 0825fc69750..b54be35060f 100644 --- a/src/interfaces/swig/Library.i +++ b/src/interfaces/swig/Library.i @@ -32,10 +32,6 @@ %rename(IndexBlockTree) CIndexBlockTree; %rename(Data) CData; -%rename(IndependentComputationEngine) CIndependentComputationEngine; -%rename(SerialComputationEngine) CSerialComputationEngine; - - %ignore RADIX_STACK_SIZE; %ignore NUMTRAPPEDSIGS; %ignore TRIE_TERMINAL_CHARACTER; @@ -446,94 +442,3 @@ namespace shogun %include %include %include - -/* Computation framework */ - -/* Computation Engine */ -%rename (IndependentComputationEngine) CIndependentComputationEngine; -%rename (SerialComputationEngine) CSerialComputationEngine; - -%include -%include - -/* Independent compution-job */ -%include - -/* Independent computation-job results */ -%rename (JobResult) CJobResult; -%include -%include -namespace shogun -{ -#ifdef USE_CHAR - %template(ScalarCharResult) CScalarResult; -#endif -#ifdef USE_BOOL - %template(ScalarBoolResult) CScalarResult; -#endif -#ifdef USE_UINT8 - %template(ScalarByteResult) CScalarResult; -#endif -#ifdef USE_INT16 - %template(ScalarShortResult) CScalarResult; -#endif -#ifdef USE_UINT16 - %template(ScalarWordResult) CScalarResult; -#endif -#ifdef USE_INT32 - %template(ScalarIntResult) CScalarResult; -#endif -#ifdef USE_UINT32 - %template(ScalarUIntResult) CScalarResult; -#endif -#ifdef USE_INT64 - %template(ScalarLongResult) CScalarResult; -#endif -#ifdef USE_UINT64 - %template(ScalarULongResult) CScalarResult; -#endif -#ifdef USE_FLOAT32 - %template(ScalarShortRealResult) CScalarResult; -#endif -#ifdef USE_FLOAT64 - %template(ScalarRealResult) CScalarResult; -#endif -} - -%include -namespace shogun -{ -#ifdef USE_CHAR - %template(VectorCharResult) CVectorResult; -#endif -#ifdef USE_BOOL - %template(VectorBoolResult) CVectorResult; -#endif -#ifdef USE_UINT8 - %template(VectorByteResult) CVectorResult; -#endif -#ifdef USE_INT16 - %template(VectorShortResult) CVectorResult; -#endif -#ifdef USE_UINT16 - %template(VectorWordResult) CVectorResult; -#endif -#ifdef USE_INT32 - %template(VectorIntResult) CVectorResult; -#endif -#ifdef USE_UINT32 - %template(VectorUIntResult) CVectorResult; -#endif -#ifdef USE_INT64 - %template(VectorLongResult) CVectorResult; -#endif -#ifdef USE_UINT64 - %template(VectorULongResult) CVectorResult; -#endif -#ifdef USE_FLOAT32 - %template(VectorShortRealResult) CVectorResult; -#endif -#ifdef USE_FLOAT64 - %template(VectorRealResult) CVectorResult; -#endif -} diff --git a/src/interfaces/swig/Library_includes.i b/src/interfaces/swig/Library_includes.i index 7a8fbdcedf8..7304e586384 100644 --- a/src/interfaces/swig/Library_includes.i +++ b/src/interfaces/swig/Library_includes.i @@ -29,10 +29,4 @@ #include #include #include -#include -#include -#include -#include -#include -#include %} diff --git a/src/shogun/lib/computation/aggregator/JobResultAggregator.h b/src/shogun/lib/computation/aggregator/JobResultAggregator.h deleted file mode 100644 index f31bc630f87..00000000000 --- a/src/shogun/lib/computation/aggregator/JobResultAggregator.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Björn Esser - */ - -#ifndef JOB_RESULT_AGGREGATOR_H_ -#define JOB_RESULT_AGGREGATOR_H_ - -#include -#include -#include -#include - -namespace shogun -{ - -/** @brief Abstract base class that provides an interface for computing an - * aggeregation of the job results of independent computation jobs as - * they are submitted and also for finalizing the aggregation. - */ -class CJobResultAggregator : public CSGObject -{ -public: - /** default constructor */ - CJobResultAggregator() - : CSGObject() - { - init(); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - - /** destructor */ - virtual ~CJobResultAggregator() - { - SG_UNREF(m_result); - - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) - } - - /** - * abstract method that submits the result of an independent job, and - * computes the aggregation with the previously submitted result - * - * @param result the result of an independent job - */ - virtual void submit_result(CJobResult* result) = 0; - - /** - * abstract method that finalizes the aggregation and computes the result, - * its necessary to call finalize before getting the final result - */ - virtual void finalize() = 0; - - /** @return the final result */ - CJobResult* get_final_result() const - { - return m_result; - } - - /** @return object name */ - virtual const char* get_name() const - { - return "JobResultAggregator"; - } -protected: - /** the final job result */ - CJobResult* m_result; - -private: - /** initialize with default values and register params */ - void init() - { - m_result=NULL; - - SG_ADD((CSGObject**)&m_result, "final_result", - "Aggregation of computation job results", MS_NOT_AVAILABLE); - } -}; - -} - -#endif // JOB_RESULT_AGGREGATOR_H_ diff --git a/src/shogun/lib/computation/aggregator/StoreScalarAggregator.cpp b/src/shogun/lib/computation/aggregator/StoreScalarAggregator.cpp deleted file mode 100644 index 8818ba2ad13..00000000000 --- a/src/shogun/lib/computation/aggregator/StoreScalarAggregator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Björn Esser - */ - -#include -#include - -namespace shogun -{ -template -CStoreScalarAggregator::CStoreScalarAggregator() - : CJobResultAggregator() - { - init(); - } - -template -void CStoreScalarAggregator::init() - { - m_aggregate=static_cast(0); - - set_generic(); - - SG_ADD(&m_aggregate, "current_aggregate", - "Aggregation of computation job results", MS_NOT_AVAILABLE); - } - -template -CStoreScalarAggregator::~CStoreScalarAggregator() - { - } - -template -void CStoreScalarAggregator::submit_result(CJobResult* result) - { - SG_GCDEBUG("Entering\n") - - // check for proper typecast - CScalarResult* new_result=dynamic_cast*>(result); - if (!new_result) - SG_ERROR("result is not of CScalarResult type!\n"); - // aggregate it with previous - m_aggregate+=new_result->get_result(); - - SG_GCDEBUG("Leaving\n") - } - -template<> -void CStoreScalarAggregator::submit_result(CJobResult* result) - { - SG_NOTIMPLEMENTED - } - -template<> -void CStoreScalarAggregator::submit_result(CJobResult* result) - { - SG_NOTIMPLEMENTED - } - -template -void CStoreScalarAggregator::finalize() - { - m_result=(CJobResult*)(new CScalarResult(m_aggregate)); - SG_REF(m_result); - } - -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -template class CStoreScalarAggregator; -} diff --git a/src/shogun/lib/computation/aggregator/StoreScalarAggregator.h b/src/shogun/lib/computation/aggregator/StoreScalarAggregator.h deleted file mode 100644 index 1576f20e3fc..00000000000 --- a/src/shogun/lib/computation/aggregator/StoreScalarAggregator.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Yuyu Zhang, Björn Esser - */ - -#ifndef STORE_SCALAR_AGGREGATOR_H_ -#define STORE_SCALAR_AGGREGATOR_H_ - -#include - -#include - -namespace shogun -{ -class CJobResult; - -/** @brief Template class that aggregates scalar job results in each - * submit_result call, finalize then transforms current aggregation into - * a CScalarResult. - */ -template class CStoreScalarAggregator : public CJobResultAggregator -{ -/** this class supports complex */ -typedef bool supports_complex128_t; - -public: - /** default constructor */ - CStoreScalarAggregator(); - - /** destructor */ - virtual ~CStoreScalarAggregator(); - - /** - * method that submits the result (scalar) of an independent job, and - * computes the aggregation with the previously submitted result - * - * @param result the result of an independent job - */ - virtual void submit_result(CJobResult* result); - - /** - * method that finalizes the aggregation and computes the result (scalar), - * its necessary to call finalize before getting the final result - */ - virtual void finalize(); - - /** @return object name */ - virtual const char* get_name() const - { - return "StoreScalarAggregator"; - } -private: - /** the aggregation */ - T m_aggregate; - - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // STORE_SCALAR_AGGREGATOR_H_ diff --git a/src/shogun/lib/computation/aggregator/StoreVectorAggregator.cpp b/src/shogun/lib/computation/aggregator/StoreVectorAggregator.cpp deleted file mode 100644 index 7469b61919b..00000000000 --- a/src/shogun/lib/computation/aggregator/StoreVectorAggregator.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Björn Esser - */ - -#include -#include -#include -#include - -namespace shogun -{ -template -CStoreVectorAggregator::CStoreVectorAggregator() - : CJobResultAggregator() - { - init(); - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - -template -CStoreVectorAggregator::CStoreVectorAggregator(index_t dimension) - : CJobResultAggregator() - { - init(); - - m_aggregate=SGVector(dimension); - m_aggregate.set_const(static_cast(0)); - } - -template -void CStoreVectorAggregator::init() - { - SG_ADD(&m_aggregate, "current_aggregate", - "Aggregation of computation job results", MS_NOT_AVAILABLE); - } - -template -CStoreVectorAggregator::~CStoreVectorAggregator() - { - } - -template -void CStoreVectorAggregator::submit_result(CJobResult* result) - { - SG_GCDEBUG("Entering\n") - - // check for proper typecast - CVectorResult* new_result=dynamic_cast*>(result); - if (!new_result) - SG_ERROR("result is not of CVectorResult type!\n"); - // aggregate it with previous - m_aggregate+=new_result->get_result(); - - SG_GCDEBUG("Leaving\n") - } - -template<> -void CStoreVectorAggregator::submit_result(CJobResult* result) - { - SG_NOTIMPLEMENTED - } - -template<> -void CStoreVectorAggregator::submit_result(CJobResult* result) - { - SG_NOTIMPLEMENTED - } - -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -template class CStoreVectorAggregator; -} diff --git a/src/shogun/lib/computation/aggregator/StoreVectorAggregator.h b/src/shogun/lib/computation/aggregator/StoreVectorAggregator.h deleted file mode 100644 index 5f7f9d6e8cd..00000000000 --- a/src/shogun/lib/computation/aggregator/StoreVectorAggregator.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Thoralf Klein, Soumyajit De, Yuyu Zhang, Björn Esser - */ - -#ifndef STORE_VECTOR_AGGREGATOR_H_ -#define STORE_VECTOR_AGGREGATOR_H_ - -#include - -#include -#include -#include - -namespace shogun -{ -class CJobResult; -template class CVectorResult; - -/** @brief Abstract template class that aggregates vector job results in each - * submit_result call, finalize is abstract - */ -template class CStoreVectorAggregator : public CJobResultAggregator -{ -public: - /** default constructor */ - CStoreVectorAggregator(); - - /** - * constructor - * - * @param dimension the dimension of vectors in vector result - */ - CStoreVectorAggregator(index_t dimension); - - /** destructor */ - virtual ~CStoreVectorAggregator(); - - /** - * method that submits the result (vector) of an independent job, and - * computes the aggregation with the previously submitted result - * - * @param result the result of an independent job - */ - virtual void submit_result(CJobResult* result); - - /** - * abstract method that finalizes the aggregation and computes the result - * (scalar), its necessary to call finalize before getting the final result - */ - virtual void finalize() = 0; - - /** @return object name */ - virtual const char* get_name() const - { - return "StoreVectorAggregator"; - } -protected: - /** the aggregation */ - SGVector m_aggregate; - -private: - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // STORE_VECTOR_AGGREGATOR_H_ diff --git a/src/shogun/lib/computation/engine/IndependentComputationEngine.h b/src/shogun/lib/computation/engine/IndependentComputationEngine.h deleted file mode 100644 index 2edfb5ee978..00000000000 --- a/src/shogun/lib/computation/engine/IndependentComputationEngine.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Björn Esser - */ - -#ifndef INDEPENDENT_COMPUTATION_ENGINE_H_ -#define INDEPENDENT_COMPUTATION_ENGINE_H_ - -#include -#include - -namespace shogun -{ -class CIndependentJob; - -/** @brief Abstract base class for solving multiple independent instances of - * CIndependentJob. It has one method, submit_job, which may add the job to an - * internal queue and might block if there is yet not space in the queue. - * After jobs are submitted, it might not yet be ready. wait_for_all waits - * until all jobs are completed, which *must be* called to guarantee that all - * jobs are finished. - */ -class CIndependentComputationEngine : public CSGObject -{ -public: - /** default constructor */ - CIndependentComputationEngine() - : CSGObject() - { - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - - /** destructor */ - virtual ~CIndependentComputationEngine() - { - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) - } - - /** - * abstract method that submits the jobs to the engine - * - * @param job the job to be computed - */ - virtual void submit_job(CIndependentJob* job) = 0; - - /** abstract method that blocks until all the jobs are completed */ - virtual void wait_for_all() = 0; - - /** @return object name */ - virtual const char* get_name() const - { - return "IndependentComputationEngine"; - } -}; - -} - -#endif // INDEPENDENT_COMPUTATION_ENGINE_H_ diff --git a/src/shogun/lib/computation/engine/SerialComputationEngine.cpp b/src/shogun/lib/computation/engine/SerialComputationEngine.cpp deleted file mode 100644 index 1e69b9826f8..00000000000 --- a/src/shogun/lib/computation/engine/SerialComputationEngine.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Björn Esser - */ - -#include -#include -#include -#include -#include - -namespace shogun -{ - -CSerialComputationEngine::CSerialComputationEngine() - : CIndependentComputationEngine() -{ - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -CSerialComputationEngine::~CSerialComputationEngine() -{ - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) -} - -void CSerialComputationEngine::submit_job(CIndependentJob* job) -{ - SG_DEBUG("Entering. The job is being computed!\n"); - - REQUIRE(job, "Job to be computed is NULL\n"); - job->compute(); - - SG_DEBUG("The job is computed. Leaving!\n"); -} - -void CSerialComputationEngine::wait_for_all() -{ - SG_DEBUG("All jobs are computed!\n"); -} - -} diff --git a/src/shogun/lib/computation/engine/SerialComputationEngine.h b/src/shogun/lib/computation/engine/SerialComputationEngine.h deleted file mode 100644 index d9e5659bccf..00000000000 --- a/src/shogun/lib/computation/engine/SerialComputationEngine.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Yuyu Zhang, Björn Esser - */ - -#ifndef SERIAL_COMPUTATION_ENGINE_H_ -#define SERIAL_COMPUTATION_ENGINE_H_ - -#include - -#include - -namespace shogun -{ -class CIndependentJob; - -/** @brief Class that computes multiple independent instances of - * computation jobs sequentially - */ -class CSerialComputationEngine : public CIndependentComputationEngine -{ -public: - /** default constructor */ - CSerialComputationEngine(); - - /** destructor */ - virtual ~CSerialComputationEngine(); - - /** - * method that calls the job's compute method in each call, therefore - * blocks until the its computation is done - * - * @param job the job to be computed - */ - virtual void submit_job(CIndependentJob* job); - - /** - * method that returns when all the jobs computed, in this case it does - * nothing - */ - virtual void wait_for_all(); - - /** @return object name */ - virtual const char* get_name() const - { - return "SerialComputationEngine"; - } -}; - -} - -#endif // SERIAL_COMPUTATION_ENGINE_H_ diff --git a/src/shogun/lib/computation/job/IndependentJob.h b/src/shogun/lib/computation/job/IndependentJob.h deleted file mode 100644 index fbcb216c498..00000000000 --- a/src/shogun/lib/computation/job/IndependentJob.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Heiko Strathmann, Björn Esser - */ - -#ifndef INDEPENDENT_JOB_H_ -#define INDEPENDENT_JOB_H_ - -#include -#include -#include -#include - -namespace shogun -{ - -/** @brief Abstract base for general computation jobs to be registered - * in CIndependentComputationEngine. compute method produces a job result - * and submits it to the internal JobResultAggregator. Each set of jobs - * that form a result will share the same job result aggregator. - */ -class CIndependentJob : public CSGObject -{ -public: - /** default constructor*/ - CIndependentJob() - : CSGObject() - { - init(); - } - - /** - * constructor - * - * @param aggregator the job result aggregator for the current job - */ - CIndependentJob(CJobResultAggregator* aggregator) - : CSGObject(), m_aggregator(aggregator) - { - init(); - - m_aggregator=aggregator; - SG_REF(m_aggregator); - } - - /** destructor */ - virtual ~CIndependentJob() - { - SG_UNREF(m_aggregator); - } - - /** - * abstract compute method that computes the job, creates a CJobResult, - * submits the result to the job result aggregator - */ - virtual void compute() = 0; - - /** @return object name */ - virtual const char* get_name() const - { - return "IndependentJob"; - } -protected: - /** the job result aggregator for the current job */ - CJobResultAggregator* m_aggregator; - -private: - /** initialize with default values and register params */ - void init() - { - m_aggregator=NULL; - - SG_ADD((CSGObject**)&m_aggregator, "job_result_aggregator", - "Job result aggregator for current job", MS_NOT_AVAILABLE); - } -}; - -} - -#endif // INDEPENDENT_JOB_H_ diff --git a/src/shogun/lib/computation/jobresult/JobResult.h b/src/shogun/lib/computation/jobresult/JobResult.h deleted file mode 100644 index 85bb71176b9..00000000000 --- a/src/shogun/lib/computation/jobresult/JobResult.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Thoralf Klein, Soumyajit De, Björn Esser - */ - -#ifndef JOB_RESULT_H_ -#define JOB_RESULT_H_ - -#include -#include -#include - -namespace shogun -{ - -/** @brief Base class that stores the result of an independent job */ -class CJobResult : public CSGObject -{ -public: - /** default constructor */ - CJobResult() - : CSGObject() - { - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - - /** destructor */ - virtual ~CJobResult() - { - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) - } - - /** @return object name */ - virtual const char* get_name() const - { - return "JobResult"; - } -}; - -} - -#endif // JOB_RESULT_H_ diff --git a/src/shogun/lib/computation/jobresult/ScalarResult.cpp b/src/shogun/lib/computation/jobresult/ScalarResult.cpp deleted file mode 100644 index 4cb92d39c14..00000000000 --- a/src/shogun/lib/computation/jobresult/ScalarResult.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Björn Esser - */ - -#include - -namespace shogun -{ -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -template class CScalarResult; -} diff --git a/src/shogun/lib/computation/jobresult/ScalarResult.h b/src/shogun/lib/computation/jobresult/ScalarResult.h deleted file mode 100644 index d04c1a5ff9e..00000000000 --- a/src/shogun/lib/computation/jobresult/ScalarResult.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Thoralf Klein, Soeren Sonnenburg, Yuyu Zhang, - * Björn Esser - */ - -#ifndef SCALAR_RESULT_H_ -#define SCALAR_RESULT_H_ - -#include - -#include -#include - -namespace shogun -{ - -/** @brief Base class that stores the result of an independent job - * when the result is a scalar. - */ -template class CScalarResult : public CJobResult -{ -/** this class supports complex */ -typedef bool supports_complex128_t; - -public: - /** default constructor */ - CScalarResult() - : CJobResult() - { - init(); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - - /** - * constructor - * - * @param scalar_result the scalar result - */ - CScalarResult(const T& scalar_result) - : CJobResult() - { - init(); - - m_result=scalar_result; - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) - } - - /** destructor */ - virtual ~CScalarResult() - { - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) - } - - /** @return object name */ - virtual const char* get_name() const - { - return "ScalarResult"; - } - - /** @return the job result */ - const T get_result() const - { - return m_result; - } - -protected: - /** the scalar result */ - T m_result; - -private: - /** initialize with default values and register params */ - void init() - { - m_result=static_cast(0); - - set_generic(); - - SG_ADD(&m_result, "scalar_result", "Scalar result of a computation job", - MS_NOT_AVAILABLE); - } -}; -} - -#endif // SCALAR_RESULT_H_ diff --git a/src/shogun/lib/computation/jobresult/VectorResult.cpp b/src/shogun/lib/computation/jobresult/VectorResult.cpp deleted file mode 100644 index 78afb545736..00000000000 --- a/src/shogun/lib/computation/jobresult/VectorResult.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Björn Esser - */ - -#include - -namespace shogun -{ -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -template class CVectorResult; -} diff --git a/src/shogun/lib/computation/jobresult/VectorResult.h b/src/shogun/lib/computation/jobresult/VectorResult.h deleted file mode 100644 index 96317d4c941..00000000000 --- a/src/shogun/lib/computation/jobresult/VectorResult.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Viktor Gal, Thoralf Klein, Yuyu Zhang, Björn Esser - */ - -#ifndef VECTOR_RESULT_H_ -#define VECTOR_RESULT_H_ - -#include - -#include -#include -#include - -namespace shogun -{ -/** @brief Base class that stores the result of an independent job - * when the result is a vector. - */ -template class CVectorResult : public CJobResult -{ -/** this class supports complex */ -typedef bool supports_complex128_t; - -public: - /** default constructor */ - CVectorResult() - : CJobResult() - { - init(); - } - - /** constructor - * @param vector_result the vector result - */ - CVectorResult(SGVector vector_result) - : CJobResult() - { - init(); - - m_result = vector_result; - } - - /** destructor */ - virtual ~CVectorResult() - { - } - - /** @return object name */ - virtual const char* get_name() const - { - return "VectorResult"; - } - - /** @return the job result */ - SGVector get_result() const - { - return m_result; - } - -protected: - /** the vector result */ - SGVector m_result; - -private: - /** initialize with default values and register params */ - void init() - { - set_generic(); - - SG_ADD(&m_result, "vector_result", - "The result vector", MS_NOT_AVAILABLE); - } -}; -} - -#endif // VECTOR_RESULT_H_ diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.cpp b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.cpp deleted file mode 100644 index 2b698bdd56c..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#include - -#include -#include -#include -#include -#include -#include - -using namespace Eigen; - -namespace shogun -{ -CIndividualJobResultAggregator::CIndividualJobResultAggregator() - : CStoreVectorAggregator(), - m_const_multiplier(0.0) -{ - init(); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -CIndividualJobResultAggregator::CIndividualJobResultAggregator( - CLinearOperator* linear_operator, - SGVector vector, - const float64_t& const_multiplier) - : CStoreVectorAggregator(vector.vlen), - m_const_multiplier(const_multiplier) -{ - init(); - - m_vector=vector; - - m_linear_operator=linear_operator; - SG_REF(m_linear_operator); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -void CIndividualJobResultAggregator::init() -{ - m_linear_operator=NULL; - - SG_ADD(&m_vector, "sample_vector", - "The sample vector to perform final dot product", MS_NOT_AVAILABLE); - - SG_ADD((CSGObject**)&m_linear_operator, "linear_operator", - "The linear operator to apply on the aggregation", MS_NOT_AVAILABLE); -} - -CIndividualJobResultAggregator::~CIndividualJobResultAggregator() -{ - SG_UNREF(m_linear_operator); - - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) -} - -void CIndividualJobResultAggregator::finalize() -{ - // take out the imaginary part of the aggegation before - // applying linear operator - SGVector imag_agg=m_aggregate.get_imag(); - SGVector agg=m_linear_operator->apply(imag_agg); - - // perform dot product - Map map_agg(agg.vector, agg.vlen); - Map map_vector(m_vector.vector, m_vector.vlen); - float64_t result=map_vector.dot(map_agg); - - result*=m_const_multiplier; - - // form the final result into a scalar result - m_result=new CScalarResult(result); - SG_REF(m_result); -} - -} diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.h b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.h deleted file mode 100644 index 049e3054034..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/aggregator/IndividualJobResultAggregator.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#ifndef INDIVIDUAL_JOB_RESULT_AGGREGATOR_H_ -#define INDIVIDUAL_JOB_RESULT_AGGREGATOR_H_ - -#include -#include - - -namespace shogun -{ -class CJobResult; -template class SGVector; -template class CLinearOperator; - -/** @brief Class that aggregates vector job results in each submit_result call - * of jobs generated from rational approximation of linear operator function - * times a vector. finalize extracts the imaginary part of that aggregation, - * applies the linear operator to the aggregation, performs a dot product with - * the sample vector, multiplies with the constant multiplier (see - * CRationalApproximation) and stores the result as CScalarResult - */ -class CIndividualJobResultAggregator : public CStoreVectorAggregator -{ -public: - /** default constructor */ - CIndividualJobResultAggregator(); - - /** - * constructor - * - * @param linear_operator linear operator to apply on the imaginary part - * of the aggregation before performing the dot product - * @param vector the sample vector with which the final dot product - * has to be performed - * @param const_multiplier the constant multiplier to be multiplied with - * the final vector-vector product to give final result - */ - CIndividualJobResultAggregator(CLinearOperator* - linear_operator, SGVector vector, - const float64_t& const_multiplier); - - /** destructor */ - virtual ~CIndividualJobResultAggregator(); - - /** - * method that finalizes the aggregation and computes the result (scalar), - * its necessary to call finalize before getting the final result - */ - virtual void finalize(); - - /** @return object name */ - virtual const char* get_name() const - { - return "IndividualJobResultAggregator"; - } -private: - /** the linear operator */ - CLinearOperator* m_linear_operator; - - /** the sample vector */ - SGVector m_vector; - - /** the constant multiplier */ - const float64_t m_const_multiplier; - - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // INDIVIDUAL_JOB_RESULT_AGGREGATOR_H_ diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.cpp b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.cpp deleted file mode 100644 index 63715ba77f4..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Heiko Strathmann, Soumyajit De, Björn Esser - */ - -#include - -#include -#include -#include -#include -#include -#include - -using namespace Eigen; - -namespace shogun -{ - -CDenseExactLogJob::CDenseExactLogJob() - : CIndependentJob() -{ - init(); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -CDenseExactLogJob::CDenseExactLogJob(CJobResultAggregator* aggregator, - CDenseMatrixOperator* log_operator, - SGVector vector) - : CIndependentJob(aggregator) -{ - init(); - - m_log_operator=log_operator; - SG_REF(m_log_operator); - - m_vector=vector; - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -void CDenseExactLogJob::init() -{ - m_log_operator=NULL; - - SG_ADD((CSGObject**)&m_log_operator, "log_operator", - "Log of linear operator", MS_NOT_AVAILABLE); - - SG_ADD(&m_vector, "trace_sample", - "Sample vector to apply linear operator on", MS_NOT_AVAILABLE); -} - -CDenseExactLogJob::~CDenseExactLogJob() -{ - SG_UNREF(m_log_operator); - - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) -} - -void CDenseExactLogJob::compute() -{ - SG_DEBUG("Entering...\n") - - REQUIRE(m_log_operator, "Log operator function is NULL\n"); - REQUIRE(m_aggregator, "Job result aggregator is NULL\n"); - - // apply the log to m_vector - SGVector vec=m_log_operator->apply(m_vector); - - // compute the vector-vector dot product using Eigen3 - Map v(vec.vector, vec.vlen); - Map s(m_vector.vector, m_vector.vlen); - - CScalarResult* result=new CScalarResult(s.dot(v)); - SG_REF(result); - - m_aggregator->submit_result(result); - SG_UNREF(result); - - SG_DEBUG("Leaving...\n") -} - -SGVector CDenseExactLogJob::get_vector() const -{ - return m_vector; -} - -CDenseMatrixOperator* CDenseExactLogJob::get_operator() const -{ - return m_log_operator; -} - -} diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.h b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.h deleted file mode 100644 index af19ec5be23..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/DenseExactLogJob.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Heiko Strathmann, Soumyajit De, Björn Esser - */ - -#ifndef DENSE_EXACT_LOG_JOB_H_ -#define DENSE_EXACT_LOG_JOB_H_ - -#include - -#include - -namespace shogun -{ -template class SGVector; -template class CDenseMatrixOperator; - -/** @brief Class that represents the job of applying the log of - * a CDenseMatrixOperator on a real vector - */ -class CDenseExactLogJob : public CIndependentJob -{ -public: - /** default constructor */ - CDenseExactLogJob(); - - /** - * constructor - * - * @param aggregator the job result aggregator for this job - * @param log_operator the dense matrix operator to be applied to the vector - * @param vector the sample vector to which operator is to be applied - */ - CDenseExactLogJob(CJobResultAggregator* aggregator, - CDenseMatrixOperator* log_operator, - SGVector vector); - - /** destructor */ - virtual ~CDenseExactLogJob(); - - /** implementation of compute method for the job */ - virtual void compute(); - - /** @return the vector */ - SGVector get_vector() const; - - /** @return the linear operator */ - CDenseMatrixOperator* get_operator() const; - - /** @return object name */ - virtual const char* get_name() const - { - return "DenseExactLogJob"; - } - -private: - /** the log of a CDenseMatrixOperator */ - CDenseMatrixOperator* m_log_operator; - - /** the trace-sample */ - SGVector m_vector; - - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // DENSE_EXACT_LOG_JOB_H_ diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.cpp b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.cpp deleted file mode 100644 index 17b959be2e0..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace Eigen; - -namespace shogun -{ - -CRationalApproximationCGMJob::CRationalApproximationCGMJob() - : CIndependentJob() -{ - init(); -} - -CRationalApproximationCGMJob::CRationalApproximationCGMJob( - CStoreScalarAggregator* aggregator, - CCGMShiftedFamilySolver* linear_solver, - CLinearOperator* linear_operator, - SGVector vector, - SGVector shifts, - SGVector weights, - float64_t const_multiplier) - : CIndependentJob((CJobResultAggregator*)aggregator) -{ - init(); - - m_linear_solver=linear_solver; - SG_REF(m_linear_solver); - - m_operator=linear_operator; - SG_REF(m_operator); - - m_vector=vector; - - m_shifts=shifts; - m_weights=weights; - m_const_multiplier=const_multiplier; -} - -void CRationalApproximationCGMJob::init() -{ - m_linear_solver=NULL; - m_operator=NULL; - m_const_multiplier=0.0; - - SG_ADD((CSGObject**)&m_linear_solver, "linear_solver", - "Linear solver for complex-shifted system", MS_NOT_AVAILABLE); - - SG_ADD((CSGObject**)&m_operator, "linear_operator", - "Linear operator", MS_NOT_AVAILABLE); - - SG_ADD(&m_vector, "trace_sample", - "Sample vector to apply linear operator on", MS_NOT_AVAILABLE); - - SG_ADD(&m_weights, "complex_shifts", - "Shifts in the linear systems to be solved", MS_NOT_AVAILABLE); - - SG_ADD(&m_weights, "complex_weights", - "Weights to be multiplied to the solution vector", MS_NOT_AVAILABLE); - - SG_ADD(&m_const_multiplier, "constant_multiplier", - "Constant multiplier to be multiplied with the final solution", MS_NOT_AVAILABLE); -} - -CRationalApproximationCGMJob::~CRationalApproximationCGMJob() -{ - SG_UNREF(m_linear_solver); - SG_UNREF(m_operator); -} - -void CRationalApproximationCGMJob::compute() -{ - SG_DEBUG("Entering\n"); - - REQUIRE(m_aggregator, "Job result aggregator is not set!\n"); - REQUIRE(m_operator, "Operator is not set!\n"); - REQUIRE(m_vector.vector, "Vector is not set!\n"); - REQUIRE(m_shifts.vector, "Shifts are not set!\n"); - REQUIRE(m_weights.vector, "Weights are not set!\n"); - REQUIRE(m_operator->get_dimension()==m_vector.vlen, - "Dimension mismatch! %d vs %d\n", m_operator->get_dimension(), m_vector.vlen); - REQUIRE(m_shifts.vlen==m_weights.vlen, - "Number of shifts and weights are not equal!\n"); - - // solve the linear system with the sample vector - SGVector vec=m_linear_solver->solve_shifted_weighted( - m_operator, m_vector, m_shifts, m_weights); - - // Take negative (see CRationalApproximation for the formula) - Map v(vec.vector, vec.vlen); - v=-v; - - // take out the imaginary part of the result before - // applying linear operator - SGVector agg=m_operator->apply(vec.get_imag()); - - // perform dot product - Map map_agg(agg.vector, agg.vlen); - Map map_vector(m_vector.vector, m_vector.vlen); - float64_t result=map_vector.dot(map_agg); - - result*=m_const_multiplier; - - // form the final result into a scalar result and submit to the aggregator - CScalarResult* final_result=new CScalarResult(result); - SG_REF(final_result); - - m_aggregator->submit_result(final_result); - - SG_UNREF(final_result); - - SG_DEBUG("Leaving\n"); -} - -} diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.h b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.h deleted file mode 100644 index dd54e15a1c7..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationCGMJob.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#ifndef RATIONAL_APPROXIMATION_CGM_JOB_H_ -#define RATIONAL_APPROXIMATION_CGM_JOB_H_ - -#include - -#include - -namespace shogun -{ -template class SGVector; -template class CLinearOperator; -template class CStoreScalarAggregator; -class CCGMShiftedFamilySolver; - -/** @brief Implementation of independent jobs that solves one whole family - * of shifted systems in rational approximation of linear operator function - * times a vector using CG-M linear solver. compute calls submit_results of - * the aggregator with CScalarResult (see CRationalApproximation) - */ -class CRationalApproximationCGMJob : public CIndependentJob -{ -public: - /** default constructor */ - CRationalApproximationCGMJob(); - - /** - * constructor - * - * @param aggregator the scalar job result aggregator for this job - * @param linear_solver solver for the shifted-system of this job - * @param linear_operator the linear operator of the system - * @param vector the sample vector of the system - * @param shifts the complex shifts vector in the system - * @param weights the complex weights vector in the system - * @param const_multiplier the constant multiplier - */ - CRationalApproximationCGMJob(CStoreScalarAggregator* aggregator, - CCGMShiftedFamilySolver* linear_solver, - CLinearOperator* linear_operator, - SGVector vector, SGVector shifts, - SGVector weights, float64_t const_multiplier); - - /** destructor */ - virtual ~CRationalApproximationCGMJob(); - - /** implementation of compute method for the job */ - virtual void compute(); - - /** @return object name */ - virtual const char* get_name() const - { - return "RationalApproximationCGMJob"; - } - -private: - /** the real valued linear operator of linear system to be solved */ - CLinearOperator* m_operator; - - /** the vector of the system to be solved */ - SGVector m_vector; - - /** the complex-shifted linear family solver */ - CCGMShiftedFamilySolver* m_linear_solver; - - /** the shifts in the systems to be solved */ - SGVector m_shifts; - - /** the weights to be multiplied with each solution per shift */ - SGVector m_weights; - - /** the constant multiplier */ - float64_t m_const_multiplier; - - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // RATIONAL_APPROXIMATION_CGM_JOB_H_ diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.cpp b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.cpp deleted file mode 100644 index 2d7fabc1590..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Eigen; - -namespace shogun -{ - -CRationalApproximationIndividualJob::CRationalApproximationIndividualJob() - : CIndependentJob() -{ - init(); - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -CRationalApproximationIndividualJob::CRationalApproximationIndividualJob( - CJobResultAggregator* aggregator, - CLinearSolver* linear_solver, - CLinearOperator* linear_operator, - SGVector vector, - complex128_t weight) - : CIndependentJob(aggregator) -{ - init(); - - m_linear_solver=linear_solver; - SG_REF(m_linear_solver); - - m_operator=linear_operator; - SG_REF(m_operator); - - m_vector=vector; - - m_weight=weight; - - SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) -} - -void CRationalApproximationIndividualJob::init() -{ - m_linear_solver=NULL; - m_operator=NULL; - m_weight=complex128_t(0.0); - - SG_ADD((CSGObject**)&m_linear_solver, "linear_solver", - "Linear solver for complex system", MS_NOT_AVAILABLE); - - SG_ADD((CSGObject**)&m_operator, "shifted_operator", - "Shifted linear operator", MS_NOT_AVAILABLE); - - SG_ADD(&m_vector, "trace_sample", - "Sample vector to apply linear operator on", MS_NOT_AVAILABLE); - - SG_ADD(&m_weight, "complex_weight", - "Weight to be multiplied to the solution vector", MS_NOT_AVAILABLE); -} - -CRationalApproximationIndividualJob::~CRationalApproximationIndividualJob() -{ - SG_UNREF(m_linear_solver); - SG_UNREF(m_operator); - - SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) -} - -void CRationalApproximationIndividualJob::compute() -{ - REQUIRE(m_aggregator, "Job result aggregator is not set!\n"); - REQUIRE(m_operator, "Operator is not set!\n"); - REQUIRE(m_vector.vector, "Vector is not set!\n"); - - // solve the linear system with the sample vector - SGVector vec=m_linear_solver->solve(m_operator, m_vector); - - // multiply with the weight using Eigen3 and take negative - // (see CRationalApproximation for the formula) - Map v(vec.vector, vec.vlen); - v*=m_weight; - v=-v; - - // set as a vector result and submit to the aggregator - CVectorResult* result=new CVectorResult(vec); - SG_REF(result); - - m_aggregator->submit_result(result); - - SG_UNREF(result); -} - -} diff --git a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.h b/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.h deleted file mode 100644 index 878d3052712..00000000000 --- a/src/shogun/mathematics/linalg/ratapprox/logdet/computation/job/RationalApproximationIndividualJob.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Authors: Soumyajit De, Sunil Mahendrakar, Heiko Strathmann, Björn Esser - */ - -#ifndef RATIONAL_APPROXIMATION_INDIVIDUAL_JOB_H_ -#define RATIONAL_APPROXIMATION_INDIVIDUAL_JOB_H_ - -#include - -#include - -namespace shogun -{ -template class SGVector; -template class CLinearOperator; -template class CLinearSolver; - -/** @brief Implementation of independent job that solves one of the family - * of shifted systems in rational approximation of linear operator function - * times a vector using a direct linear solver. The shift is moved inside the - * operator. compute calls submit_results of the aggregator with CVectorResult - * which is the solution vector for that shift multiplied by complex weight - * (See CRationalApproximation) - */ -class CRationalApproximationIndividualJob : public CIndependentJob -{ -public: - /** default constructor */ - CRationalApproximationIndividualJob(); - - /** - * constructor - * - * @param aggregator the job result aggregator for this job - * @param linear_solver solver for the complex system of this job - * @param linear_operator the shifted operator of the system - * @param vector the sample vector of the system - * @param weight the complex weight to be multiplied with the solution - * vector after solving the linear-system - */ - CRationalApproximationIndividualJob(CJobResultAggregator* aggregator, - CLinearSolver* linear_solver, - CLinearOperator* linear_operator, - SGVector vector, complex128_t weight); - - /** destructor */ - virtual ~CRationalApproximationIndividualJob(); - - /** implementation of compute method for the job */ - virtual void compute(); - - /** @return object name */ - virtual const char* get_name() const - { - return "RationalApproximationIndividualJob"; - } - -private: - /** the shifted operator for linear system to be solved */ - CLinearOperator* m_operator; - - /** the vector of the system to be solved */ - SGVector m_vector; - - /** the complex linear solver for solving systems */ - CLinearSolver* m_linear_solver; - - /** the weight to be multiplied with the solution vector */ - complex128_t m_weight; - - /** initialize with default values and register params */ - void init(); -}; - -} - -#endif // RATIONAL_APPROXIMATION_INDIVIDUAL_JOB_H_ diff --git a/tests/unit/lib/computation/SerialComputationEngine_unittest.cc b/tests/unit/lib/computation/SerialComputationEngine_unittest.cc deleted file mode 100644 index 243a2cc7b19..00000000000 --- a/tests/unit/lib/computation/SerialComputationEngine_unittest.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Eigen; -using namespace shogun; - -TEST(SerialComputationEngine, dense_log_det) -{ - CSerialComputationEngine e; - const index_t size=2; - - // create the matrix whose log-det has to be found - SGMatrix mat(size, size); - SGMatrix log_mat(size, size); - mat(0,0)=2.0; - mat(0,1)=1.0; - mat(1,0)=1.0; - mat(1,1)=3.0; - Map m(mat.matrix, mat.num_rows, mat.num_cols); - Map log_m(log_mat.matrix, log_mat.num_rows, log_mat.num_cols); -#if EIGEN_WITH_LOG_BUG_1229 - MatrixXd tmp = m; - log_m=tmp.log(); -#else - log_m=m.log(); -#endif - - // create linear operator and aggregator - CDenseMatrixOperator* log_op=new CDenseMatrixOperator(log_mat); - SG_REF(log_op); - CStoreScalarAggregator* agg=new CStoreScalarAggregator; - SG_REF(agg); - - // create jobs with unit-vectors to extract the trace of log(mat) - for (index_t i=0; i s(size); - s.set_const(0.0); - s[i]=1.0; - CDenseExactLogJob *job=new CDenseExactLogJob((CJobResultAggregator*)agg, - log_op, s); - SG_REF(job); - // submit the job to the computation engine - e.submit_job(job); - SG_UNREF(job); - } - - // wait for all the jobs to be computed in the computation engine - e.wait_for_all(); - // its really important we call finalize before getting the final result - agg->finalize(); - - CScalarResult* r=dynamic_cast*> - (agg->get_final_result()); - - EXPECT_NEAR(r->get_result(), CStatistics::log_det(mat), 1E-15); - - SG_UNREF(log_op); - SG_UNREF(agg); -} - diff --git a/tests/unit/lib/computation/StoreScalarAggregator_unittest.cc b/tests/unit/lib/computation/StoreScalarAggregator_unittest.cc deleted file mode 100644 index c077cc84ae7..00000000000 --- a/tests/unit/lib/computation/StoreScalarAggregator_unittest.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ - -#include -#include -#include -#include - -using namespace shogun; - -TEST(StoreScalarAggregator, submit_result) -{ - CStoreScalarAggregator* agg=new CStoreScalarAggregator; - SG_REF(agg); - const index_t num_results=10; - - for (index_t i=0; i* result - =new CScalarResult((float64_t)i); - SG_REF(result); - agg->submit_result((CJobResult*)result); - SG_UNREF(result); - } - agg->finalize(); - float64_t result=dynamic_cast*> - (agg->get_final_result())->get_result(); - - EXPECT_NEAR(result, 45.0, 1E-16); - SG_UNREF(agg); -} - diff --git a/tests/unit/mathematics/linalg/DenseExactLogJob_unittest.cc b/tests/unit/mathematics/linalg/DenseExactLogJob_unittest.cc deleted file mode 100644 index 4a2aee1fb3f..00000000000 --- a/tests/unit/mathematics/linalg/DenseExactLogJob_unittest.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Eigen; -using namespace shogun; - -TEST(DenseExactLogJob, log_det) -{ - const index_t size=2; - - // create the matrix whose log-det has to be found - SGMatrix mat(size, size); - SGMatrix log_mat(size, size); - mat(0,0)=2.0; - mat(0,1)=1.0; - mat(1,0)=1.0; - mat(1,1)=3.0; - Map m(mat.matrix, mat.num_rows, mat.num_cols); - Map log_m(log_mat.matrix, log_mat.num_rows, log_mat.num_cols); -#if EIGEN_WITH_LOG_BUG_1229 - MatrixXd tmp = m; - log_m=tmp.log(); -#else - log_m=m.log(); -#endif - - // create linear operator and aggregator - CDenseMatrixOperator* log_op=new CDenseMatrixOperator(log_mat); - SG_REF(log_op); - CStoreScalarAggregator* agg=new CStoreScalarAggregator; - SG_REF(agg); - - // create jobs with unit-vectors to extract the trace of log(mat) - for (index_t i=0; i s(size); - s.set_const(0.0); - s[i]=1.0; - CDenseExactLogJob *job=new CDenseExactLogJob((CJobResultAggregator*)agg, - log_op, s); - SG_REF(job); - job->compute(); - SG_UNREF(job); - } - // its really important we call finalize before getting the final result - agg->finalize(); - - CScalarResult* r=dynamic_cast*> - (agg->get_final_result()); - - EXPECT_NEAR(r->get_result(), CStatistics::log_det(mat), 1E-15); - - SG_UNREF(log_op); - SG_UNREF(agg); -} diff --git a/tests/unit/mathematics/linalg/IndividualJobResultAggregator_unittest.cc b/tests/unit/mathematics/linalg/IndividualJobResultAggregator_unittest.cc deleted file mode 100644 index 9b88959fd08..00000000000 --- a/tests/unit/mathematics/linalg/IndividualJobResultAggregator_unittest.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace shogun; - -TEST(IndividualJobResultAggregator, finalize) -{ - const index_t size=2; - SGVector result_vector(size); - result_vector.set_const(complex128_t(0.0, 1.0)); - - SGMatrix m(size, size); - m(0,0)=1.0; - m(0,1)=0.0; - m(1,0)=0.0; - m(1,1)=1.0; - CDenseMatrixOperator* op=new CDenseMatrixOperator(m); - SG_REF(op); - - CVectorResult *job_result - =new CVectorResult(result_vector); - SG_REF(job_result); - - SGVector sample(size); - sample.set_const(1.0); - - const float64_t const_multiplier=1.0; - - CIndividualJobResultAggregator* agg - =new CIndividualJobResultAggregator(op, sample, const_multiplier); - SG_REF(agg); - - agg->submit_result(job_result); - agg->finalize(); - - CScalarResult* final_result - =dynamic_cast*>(agg->get_final_result()); - float64_t result=final_result->get_result(); - - EXPECT_NEAR(result, 2.0, 1E-15); - - SG_UNREF(job_result); - SG_UNREF(agg); - SG_UNREF(op); -} diff --git a/tests/unit/mathematics/linalg/RationalApproximationCGMJob_unittest.cc b/tests/unit/mathematics/linalg/RationalApproximationCGMJob_unittest.cc deleted file mode 100644 index 01d8b617aed..00000000000 --- a/tests/unit/mathematics/linalg/RationalApproximationCGMJob_unittest.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace shogun; -using namespace Eigen; - -TEST(RationalApproximationCGMJob, compute) -{ - const int32_t size=4; - SGMatrix m(size, size); - m.set_const(0.0); - - // diagonal Hermintian matrix - for (index_t i=0; i* linear_operator - =new CDenseMatrixOperator(m); - SG_REF(linear_operator); - - SGVector sample(size); - sample.set_const(0.5); - - SGVector shifts(1); - shifts[0]=complex128_t(0.0, 0.01); - - SGVector weights(1); - weights[0]=1.0; - - float const_multiplier=1.0; - - CCGMShiftedFamilySolver* linear_solver=new CCGMShiftedFamilySolver(); - SG_REF(linear_solver); - linear_solver->set_iteration_limit(100); - CStoreScalarAggregator* aggregator - =new CStoreScalarAggregator(); - SG_REF(aggregator); - - CRationalApproximationCGMJob* job=new CRationalApproximationCGMJob( - aggregator, linear_solver, linear_operator, sample, shifts, weights, - const_multiplier); - SG_REF(job); - - job->compute(); - aggregator->finalize(); - CScalarResult* final_result - =dynamic_cast*>(aggregator->get_final_result()); - float64_t result=final_result->get_result(); - - EXPECT_NEAR(result, 0.00520803894373009658, 1E-10); - - SG_UNREF(job); - SG_UNREF(aggregator); - SG_UNREF(linear_operator); - SG_UNREF(linear_solver); -} diff --git a/tests/unit/mathematics/linalg/RationalApproximationIndividualJob_unittest.cc b/tests/unit/mathematics/linalg/RationalApproximationIndividualJob_unittest.cc deleted file mode 100644 index a0fe48d69a6..00000000000 --- a/tests/unit/mathematics/linalg/RationalApproximationIndividualJob_unittest.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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. - * - * Written (W) 2013 Soumyajit De - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace shogun; - -TEST(RationalApproximationIndividualJob, compute_direct) -{ - const index_t size=2; - SGMatrix m(size, size); - m(0,0)=complex128_t(2.0, 1.0); - m(0,1)=complex128_t(1.0); - m(1,0)=complex128_t(1.0); - m(1,1)=complex128_t(3.0, 1.0); - - SGMatrix mi(size, size); - mi(0,0)=1.0; - mi(0,1)=0.0; - mi(1,0)=0.0; - mi(1,1)=1.0; - CDenseMatrixOperator* identity=new CDenseMatrixOperator(mi); - SG_REF(identity); - - CDenseMatrixOperator* op=new CDenseMatrixOperator(m); - SG_REF(op); - - const float64_t const_multiplier=2.0; - const complex128_t weight=complex128_t(1.0, 1.0); - SGVector s(size); - s.set_const(1.0); - // creating aggregator - CIndividualJobResultAggregator* agg=new CIndividualJobResultAggregator( - identity, s, const_multiplier); - SG_REF(agg); - - // creating complex linear solver - CDirectLinearSolverComplex* solver=new CDirectLinearSolverComplex(); - SG_REF(solver); - - CRationalApproximationIndividualJob* job - =new CRationalApproximationIndividualJob(agg, - (CLinearSolver*)solver, op, s, weight); - SG_REF(job); - job->compute(); - SG_UNREF(job); - agg->finalize(); - CScalarResult* r=dynamic_cast*> - (agg->get_final_result()); - float64_t result=r->get_result(); - SG_UNREF(agg); - SG_UNREF(op); - SG_UNREF(identity); - SG_UNREF(solver); - - EXPECT_NEAR(result, -0.73170731707317049, 1E-15); -} - -TEST(RationalApproximationIndividualJob, compute_cocg) -{ - const index_t size=2; - SGMatrix m(size, size); - m(0,0)=complex128_t(2.0, 1.0); - m(0,1)=complex128_t(1.0); - m(1,0)=complex128_t(1.0); - m(1,1)=complex128_t(3.0, 1.0); - - SGMatrix mi(size, size); - mi(0,0)=1.0; - mi(0,1)=0.0; - mi(1,0)=0.0; - mi(1,1)=1.0; - CDenseMatrixOperator* identity=new CDenseMatrixOperator(mi); - SG_REF(identity); - - CDenseMatrixOperator* op=new CDenseMatrixOperator(m); - SG_REF(op); - - const float64_t const_multiplier=2.0; - const complex128_t weight=complex128_t(1.0, 1.0); - SGVector s(size); - s.set_const(1.0); - // creating aggregator - CIndividualJobResultAggregator* agg=new CIndividualJobResultAggregator( - identity, s, const_multiplier); - SG_REF(agg); - - // creating complex linear solver - CConjugateOrthogonalCGSolver* solver=new CConjugateOrthogonalCGSolver(); - SG_REF(solver); - - CRationalApproximationIndividualJob* job - =new CRationalApproximationIndividualJob(agg, - (CLinearSolver*)solver, op, s, weight); - SG_REF(job); - job->compute(); - SG_UNREF(job); - agg->finalize(); - CScalarResult* r=dynamic_cast*> - (agg->get_final_result()); - float64_t result=r->get_result(); - SG_UNREF(agg); - SG_UNREF(op); - SG_UNREF(identity); - SG_UNREF(solver); - - EXPECT_NEAR(result, -0.73170731707317049, 1E-15); -}