Skip to content

Commit

Permalink
use varargs for require macro and add kernel example
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Jul 4, 2012
1 parent 2c53078 commit 0408912
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/shogun/io/SGIO.h
Expand Up @@ -100,7 +100,7 @@ __FILE__ ":" func ": Unstable method! Please report if it seems to " \
#define SG_SDEPRECATED sg_io->deprecated(__FILE__, __LINE__)

#define ASSERT(x) { if (!(x)) SG_SERROR("assertion %s failed in file %s line %d\n",#x, __FILE__, __LINE__);}
#define REQUIRE(x, msg) { if (!(x)) SG_SERROR(msg); }
#define REQUIRE(x, ...) { if (!(x)) SG_SERROR(__VA_ARGS__); }


/** @brief Class SGIO, used to do input output operations throughout shogun.
Expand Down
12 changes: 5 additions & 7 deletions src/shogun/kernel/Kernel.h
Expand Up @@ -17,6 +17,7 @@

#include <shogun/lib/common.h>
#include <shogun/lib/Signal.h>
#include <shogun/io/SGIO.h>
#include <shogun/io/File.h>
#include <shogun/mathematics/Math.h>
#include <shogun/features/FeatureTypes.h>
Expand Down Expand Up @@ -221,11 +222,9 @@ class CKernel : public CSGObject
*/
inline float64_t kernel(int32_t idx_a, int32_t idx_b)
{
if (idx_a<0 || idx_b<0 || idx_a>=num_lhs || idx_b>=num_rhs)
{
SG_ERROR("Index out of Range: idx_a=%d/%d idx_b=%d/%d\n",
idx_a,num_lhs, idx_b,num_rhs);
}
REQUIRE(idx_a>=0 && idx_b>=0 && idx_a<num_lhs && idx_b<num_rhs,
"Index out of Range: idx_a=%d/%d idx_b=%d/%d\n",
idx_a,num_lhs, idx_b,num_rhs);

return normalizer->normalize(compute(idx_a, idx_b), idx_a, idx_b);
}
Expand Down Expand Up @@ -280,8 +279,7 @@ class CKernel : public CSGObject
{
T* result = NULL;

if (!has_features())
SG_ERROR( "no features assigned to kernel\n");
REQUIRE(has_features(), "no features assigned to kernel\n");

int32_t m=get_num_vec_lhs();
int32_t n=get_num_vec_rhs();
Expand Down

0 comments on commit 0408912

Please sign in to comment.