Skip to content

Commit

Permalink
Updated set_weights method
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Mar 20, 2012
1 parent 9fbbb9c commit df1b927
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/shogun/kernel/WeightedCommWordStringKernel.cpp
Expand Up @@ -82,14 +82,14 @@ bool CWeightedCommWordStringKernel::set_wd_weights()
return weights!=NULL;
}

bool CWeightedCommWordStringKernel::set_weights(float64_t* w, int32_t d)
bool CWeightedCommWordStringKernel::set_weights(SGVector<float64_t> w)
{
ASSERT(d==degree);
ASSERT(w.vlen==degree);

SG_FREE(weights);
weights=SG_MALLOC(float64_t, degree);
weights = w.vector;
for (int32_t i=0; i<degree; i++)
weights[i]=CMath::sqrt(w[i]);
weights[i]=CMath::sqrt(weights[i]);
return true;
}

Expand Down
7 changes: 3 additions & 4 deletions src/shogun/kernel/WeightedCommWordStringKernel.h
Expand Up @@ -109,11 +109,10 @@ class CWeightedCommWordStringKernel: public CCommWordStringKernel

/** set custom weights (swig compatible)
*
* @param w weights
* @param d degree (must match number of weights)
* @return if setting was successful
* @param weights weights
* @return true if setting was successful
*/
bool set_weights(float64_t* w, int32_t d);
bool set_weights(SGVector<float64_t> weights);

/** return what type of kernel we are
*
Expand Down

0 comments on commit df1b927

Please sign in to comment.