-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
shogun.i
179 lines (156 loc) · 5 KB
/
shogun.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
* 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) 2011 Soeren Sonnenburg
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/
/* This is needed with SWIG >= 3.0.5 on MacOSX because of
conflicting macros in AssertMacros.h of Carbon-framework.
Won't cause harm on other distros. */
%{
#if defined(__APPLE__)
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#endif // defined(__APPLE__)
%}
%include "swig_config.h"
%define DOCSTR
"The `shogun` module gathers all modules available in the SHOGUN toolkit."
%enddef
#if defined(USE_SWIG_DIRECTORS) && defined(SWIGPYTHON)
%module(directors="1", docstring=DOCSTR) shogun
#else
%module(docstring=DOCSTR) shogun
#endif
#undef DOCSTR
/* Documentation */
%feature("autodoc","0");
#ifdef SWIGPYTHON
#include <object.h>
%{
static int print_sgobject(PyObject *pyobj, FILE *f, int flags);
%}
%feature("python:slot", "tp_str", functype="reprfunc") shogun::CSGObject::__str__;
%feature("python:slot", "tp_repr", functype="reprfunc") shogun::CSGObject::__repr__;
/*%feature("python:slot", "tp_hash", functype="hashfunc") shogun::CSGObject::myHashFunc;*/
%feature("python:tp_print") shogun::CSGObject "print_sgobject";
/*%feature("python:slot", "tp_as_buffer", functype="PyBufferProcs*") shogun::SGObject::tp_as_buffer;
%feature("python:slot", "bf_getbuffer", functype="getbufferproc") shogun::SGObject::getbuffer;*/
#endif
#ifdef HAVE_DOXYGEN
#ifndef SWIGRUBY
%include "shogun_doxygen.i"
#endif
#endif
%include "shogun_ignores.i"
%include "Classifier_includes.i"
%include "Clustering_includes.i"
%include "Distance_includes.i"
%include "Distribution_includes.i"
%include "Evaluation_includes.i"
%include "Features_includes.i"
%include "IO_includes.i"
%include "Kernel_includes.i"
%include "Library_includes.i"
%include "Mathematics_includes.i"
%include "Converter_includes.i"
%include "Preprocessor_includes.i"
%include "Regression_includes.i"
%include "Structure_includes.i"
%include "Multiclass_includes.i"
%include "Transfer_includes.i"
%include "Loss_includes.i"
%include "Statistics_includes.i"
%include "Latent_includes.i"
%include "Metric_includes.i"
%include "Minimizer_includes.i"
%include "GaussianProcess_includes.i"
%include "ModelSelection_includes.i"
%include "Ensemble_includes.i"
%include "NeuralNets_includes.i"
%include "bagging_includes.i"
%include "Boost_includes.i"
%include "SGBase.i"
%include "Machine.i"
%include "IO.i"
%include "Library.i"
%include "Mathematics.i"
%include "Features.i"
%include "Converter.i"
%include "Preprocessor.i"
%include "Evaluation.i"
%include "Distance.i"
%include "Kernel.i"
%include "Distribution.i"
%include "Classifier.i"
%include "Regression.i"
%include "Clustering.i"
%include "Structure.i"
%include "Multiclass.i"
%include "Transfer.i"
%include "Loss.i"
%include "Statistics.i"
%include "Latent.i"
%include "Metric.i"
%include "Minimizer.i"
%include "ModelSelection.i"
%include "GaussianProcess.i"
%include "Ensemble.i"
%include "NeuralNets.i"
%include "bagging.i"
%include "Boost.i"
%include "ParameterObserver.i"
#if defined(SWIGPERL)
%include "abstract_types_extension.i"
#endif
namespace shogun
{
%extend CSGObject
{
template <typename T, typename U= typename std::enable_if_t<std::is_arithmetic<T>::value>>
void put_scalar_dispatcher(const std::string& name, T value)
{
Tag<T> tag_t(name);
Tag<int32_t> tag_int32(name);
Tag<int64_t> tag_int64(name);
Tag<float64_t> tag_float64(name);
if ($self->has(tag_t))
$self->put(tag_t, value);
else if ($self->has(tag_int32))
$self->put(tag_int32, (int32_t)value);
else if ($self->has(tag_int64))
$self->put(tag_int64, (int64_t)value);
else if ($self->has(tag_float64))
$self->put(tag_float64, (float64_t)value);
else
$self->put(tag_t, value);
}
#ifdef SWIGJAVA
template <typename T, typename T2 = typename std::enable_if<std::is_same<SGMatrix<float64_t>, T>::value, T>::type>
void put_vector_or_matrix_dispatcher(const std::string& name, T value)
{
Tag<SGVector<float64_t>> tag_vec(name);
Tag<SGMatrix<float64_t>> tag_mat(name);
if ($self->has(tag_mat))
$self->put(tag_mat, value);
else if ((value.num_rows==1 || value.num_cols==1) && $self->has(tag_vec))
$self->put(tag_vec, SGVector<float64_t>(value.data()));
else
$self->put(tag_mat, value);
}
#endif // SWIGJAVA
}
%template(put) CSGObject::put_scalar_dispatcher<int32_t, int32_t>;
#ifndef SWIGJAVA
%template(put) CSGObject::put_scalar_dispatcher<int64_t, int64_t>;
#endif // SWIGJAVA
%template(put) CSGObject::put_scalar_dispatcher<float64_t, float64_t>;
#ifndef SWIGJAVA
%template(put) CSGObject::put<SGVector<float64_t>, SGVector<float64_t>>;
%template(put) CSGObject::put<SGMatrix<float64_t>, SGMatrix<float64_t>>;
#else // SWIGJAVA
%template(put) CSGObject::put_vector_or_matrix_dispatcher<SGMatrix<float64_t>, SGMatrix<float64_t>>;
#endif // SWIGJAVA
} // namespace shogun