Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove/computation #4090

Closed
wants to merge 10 commits into from
Closed
8 changes: 2 additions & 6 deletions examples/undocumented/python/mathematics_logdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def mathematics_logdet (matrix=mtx,max_iter_eig=1000,max_iter_lin=1000,num_sampl
from shogun.Mathematics import ProbingSampler
from shogun.Mathematics import LogDetEstimator
from shogun.Mathematics import Statistics
from shogun.Library import SerialComputationEngine

# creating the linear operator, eigen-solver
op=RealSparseMatrixOperator(A.tocsc())
Expand All @@ -50,16 +49,13 @@ def mathematics_logdet (matrix=mtx,max_iter_eig=1000,max_iter_lin=1000,num_sampl
lin_solver=CGMShiftedFamilySolver()
lin_solver.set_iteration_limit(max_iter_lin)

# computation engine
engine=SerialComputationEngine()

# set the desired accuracy tighter to obtain better results
# this determines the number of contour points in conformal mapping of
# the rational approximation of the Cauchy's integral of f(A)*s, f=log
desired_accuracy=1E-5

# creating the log-linear-operator function
op_func=LogRationalApproximationCGM(op, engine, eig_solver, lin_solver,\
op_func=LogRationalApproximationCGM(op, eig_solver, lin_solver,\
desired_accuracy)

# set the trace sampler to be probing sampler, in which samples are obtained
Expand All @@ -68,7 +64,7 @@ def mathematics_logdet (matrix=mtx,max_iter_eig=1000,max_iter_lin=1000,num_sampl
trace_sampler=ProbingSampler(op)

# estimating log-det
log_det_estimator=LogDetEstimator(trace_sampler, op_func, engine)
log_det_estimator=LogDetEstimator(trace_sampler, op_func)

# set the number of samples as required
estimates=log_det_estimator.sample(num_samples)
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/octave/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FIND_PACKAGE(Octave 3.6 REQUIRED)
SET(OCTAVE_APIVERSION ${OCTAVE_API_VERSION})
SET(OCTAVE_APIVERSION ${OCTAVE_MAJOR_VERSION})
UNSET(TARGET_SWIGFLAGS)

include(ShogunInterfaces)
include_directories(${OCTAVE_INCLUDE_DIRS})

GENERATE_INTERFACE_TARGET(octave ${CMAKE_CURRENT_SOURCE_DIR} ${OCTAVE_LIBRARY})
GENERATE_INTERFACE_TARGET(octave ${CMAKE_CURRENT_SOURCE_DIR} "${OCTAVE_LIBRARIES}")
set_target_properties(interface_octave PROPERTIES PREFIX "")
set_target_properties(interface_octave PROPERTIES SUFFIX ".oct")
target_compile_definitions(interface_octave PRIVATE "OCTAVE_APIVERSION=${OCTAVE_API_VERSION}")

SET(INTERFACE_OCTAVE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
install (TARGETS interface_octave
DESTINATION ${OCTAVE_OCT_LOCAL_API_FILE_DIR}/shogun
DESTINATION ${OCTAVE_OCT_SITE_DIR}/shogun
COMPONENT octave)
26 changes: 25 additions & 1 deletion src/interfaces/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,31 @@ IF (NOT MSVC)
SET(SWIG_CXX_COMPILER_FLAGS "${SWIG_CXX_COMPILER_FLAGS} -Wno-c++11-narrowing")
ENDIF()

GENERATE_INTERFACE_TARGET(python ${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_LIBRARIES})
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_config_var('LDSHARED'))"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
OUTPUT_VARIABLE PYTHON_LDSHARED
OUTPUT_STRIP_TRAILING_WHITESPACE)

IF ("${PYTHON_LDSHARED}" MATCHES "dynamic_lookup")
MESSAGE("Using static linking for Python")
SET(PYTHON_LINK_LIBRARIES "NO")
ELSE()
SET(PYTHON_LINK_LIBRARIES "${PYTHON_LIBRARIES}")
ENDIF()

GENERATE_INTERFACE_TARGET(python "${CMAKE_CURRENT_SOURCE_DIR}" "${PYTHON_LINK_LIBRARIES}")

IF (NOT PYTHON_LINK_LIBRARIES)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_TARGET_PROPERTIES(${SWIG_MODULE_interface_python_REAL_NAME} PROPERTIES
LINK_FLAGS "-Wl,-flat_namespace,-undefined,dynamic_lookup")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_TARGET_PROPERTIES(${SWIG_MODULE_interface_python_REAL_NAME} PROPERTIES
LINK_FLAGS "-undefined dynamic_lookup")
ELSE()
MESSAGE(FATAL_ERROR "No libraries to link with the interface are provided but don't know how to handle dynamic lookup")
ENDIF()
ENDIF()

# pacakges directory
if(CMAKE_HOST_UNIX)
Expand Down
95 changes: 0 additions & 95 deletions src/interfaces/swig/Library.i
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
%rename(IndexBlockTree) CIndexBlockTree;
%rename(Data) CData;

%rename(IndependentComputationEngine) CIndependentComputationEngine;
%rename(SerialComputationEngine) CSerialComputationEngine;


%ignore RADIX_STACK_SIZE;
%ignore NUMTRAPPEDSIGS;
%ignore TRIE_TERMINAL_CHARACTER;
Expand Down Expand Up @@ -405,94 +401,3 @@ namespace shogun
%include <shogun/lib/IndexBlockGroup.h>
%include <shogun/lib/IndexBlockTree.h>
%include <shogun/lib/Data.h>

/* Computation framework */

/* Computation Engine */
%rename (IndependentComputationEngine) CIndependentComputationEngine;
%rename (SerialComputationEngine) CSerialComputationEngine;

%include <shogun/lib/computation/engine/IndependentComputationEngine.h>
%include <shogun/lib/computation/engine/SerialComputationEngine.h>

/* Independent compution-job */
%include <shogun/lib/computation/job/IndependentJob.h>

/* Independent computation-job results */
%rename (JobResult) CJobResult;
%include <shogun/lib/computation/jobresult/JobResult.h>
%include <shogun/lib/computation/jobresult/ScalarResult.h>
namespace shogun
{
#ifdef USE_CHAR
%template(ScalarCharResult) CScalarResult<char>;
#endif
#ifdef USE_BOOL
%template(ScalarBoolResult) CScalarResult<bool>;
#endif
#ifdef USE_UINT8
%template(ScalarByteResult) CScalarResult<uint8_t>;
#endif
#ifdef USE_INT16
%template(ScalarShortResult) CScalarResult<int16_t>;
#endif
#ifdef USE_UINT16
%template(ScalarWordResult) CScalarResult<uint16_t>;
#endif
#ifdef USE_INT32
%template(ScalarIntResult) CScalarResult<int32_t>;
#endif
#ifdef USE_UINT32
%template(ScalarUIntResult) CScalarResult<uint32_t>;
#endif
#ifdef USE_INT64
%template(ScalarLongResult) CScalarResult<int64_t>;
#endif
#ifdef USE_UINT64
%template(ScalarULongResult) CScalarResult<uint64_t>;
#endif
#ifdef USE_FLOAT32
%template(ScalarShortRealResult) CScalarResult<float32_t>;
#endif
#ifdef USE_FLOAT64
%template(ScalarRealResult) CScalarResult<float64_t>;
#endif
}

%include <shogun/lib/computation/jobresult/VectorResult.h>
namespace shogun
{
#ifdef USE_CHAR
%template(VectorCharResult) CVectorResult<char>;
#endif
#ifdef USE_BOOL
%template(VectorBoolResult) CVectorResult<bool>;
#endif
#ifdef USE_UINT8
%template(VectorByteResult) CVectorResult<uint8_t>;
#endif
#ifdef USE_INT16
%template(VectorShortResult) CVectorResult<int16_t>;
#endif
#ifdef USE_UINT16
%template(VectorWordResult) CVectorResult<uint16_t>;
#endif
#ifdef USE_INT32
%template(VectorIntResult) CVectorResult<int32_t>;
#endif
#ifdef USE_UINT32
%template(VectorUIntResult) CVectorResult<uint32_t>;
#endif
#ifdef USE_INT64
%template(VectorLongResult) CVectorResult<int64_t>;
#endif
#ifdef USE_UINT64
%template(VectorULongResult) CVectorResult<uint64_t>;
#endif
#ifdef USE_FLOAT32
%template(VectorShortRealResult) CVectorResult<float32_t>;
#endif
#ifdef USE_FLOAT64
%template(VectorRealResult) CVectorResult<float64_t>;
#endif
}
6 changes: 0 additions & 6 deletions src/interfaces/swig/Library_includes.i
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,4 @@
#include <shogun/lib/Tokenizer.h>
#include <shogun/lib/DelimiterTokenizer.h>
#include <shogun/lib/NGramTokenizer.h>
#include <shogun/lib/computation/engine/IndependentComputationEngine.h>
#include <shogun/lib/computation/engine/SerialComputationEngine.h>
#include <shogun/lib/computation/job/IndependentJob.h>
#include <shogun/lib/computation/jobresult/JobResult.h>
#include <shogun/lib/computation/jobresult/ScalarResult.h>
#include <shogun/lib/computation/jobresult/VectorResult.h>
%}
13 changes: 13 additions & 0 deletions src/shogun/base/AnyParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ namespace shogun
return m_properties;
}

/** Equality operator which compares value but not properties.
* @return true if value of other parameter equals own */
inline bool operator==(const AnyParameter& other) const
{
return m_value == other.get_value();
}

/** @see operator==() */
inline bool operator!=(const AnyParameter& other) const
{
return !(*this == other);
}

private:
Any m_value;
AnyParameterProperties m_properties;
Expand Down