Skip to content

Commit

Permalink
remove SGVector& -> use SGVector instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed May 3, 2012
1 parent 1c8b9b0 commit 2d8d9bc
Show file tree
Hide file tree
Showing 88 changed files with 140 additions and 139 deletions.
2 changes: 0 additions & 2 deletions examples/undocumented/libshogun/classifier_libsvm.cpp
Expand Up @@ -67,7 +67,6 @@ int main()

// create train labels
CLabels* labels=new CLabels(SGVector<float64_t>(lab, NUM));
SG_REF(labels);

// create train features
CSimpleFeatures<float64_t>* features = new CSimpleFeatures<float64_t>(feature_cache);
Expand All @@ -93,7 +92,6 @@ int main()
for (int32_t i=0; i<NUM; i++)
printf("out[%d]=%f\n", i, out_labels->get_label(i));

SG_UNREF(labels);
SG_UNREF(out_labels);
SG_UNREF(kernel);
SG_UNREF(features);
Expand Down
8 changes: 4 additions & 4 deletions src/shogun/clustering/GMM.cpp
Expand Up @@ -44,7 +44,7 @@ CGMM::CGMM(int32_t n, ECovType cov_type) : CDistribution(), m_components(), m_co
register_params();
}

CGMM::CGMM(const SGVector<CGaussian*>& components, const SGVector<float64_t>& coefficients, bool copy) : CDistribution()
CGMM::CGMM(SGVector<CGaussian*> components, SGVector<float64_t> coefficients, bool copy) : CDistribution()
{
ASSERT(components.vlen==coefficients.vlen);

Expand Down Expand Up @@ -675,7 +675,7 @@ SGVector<float64_t> CGMM::get_nth_mean(int32_t num)
return m_components.vector[num]->get_mean();
}

void CGMM::set_nth_mean(const SGVector<float64_t>& mean, int32_t num)
void CGMM::set_nth_mean(SGVector<float64_t> mean, int32_t num)
{
ASSERT(num<m_components.vlen);
m_components.vector[num]->set_mean(mean);
Expand Down Expand Up @@ -708,7 +708,7 @@ SGVector<CGaussian*> CGMM::get_comp()
return m_components;
}

void CGMM::set_comp(const SGVector<CGaussian*>& components)
void CGMM::set_comp(SGVector<CGaussian*> components)
{
for (int32_t i=0; i<m_components.vlen; i++)
{
Expand Down Expand Up @@ -762,7 +762,7 @@ SGVector<float64_t> CGMM::sample()
return m_components.vector[m_coefficients.vlen-1]->sample();
}

SGVector<float64_t> CGMM::cluster(const SGVector<float64_t>& point)
SGVector<float64_t> CGMM::cluster(SGVector<float64_t> point)
{
SGVector<float64_t> answer(m_components.vlen+1);
answer.vector[m_components.vlen]=0;
Expand Down
8 changes: 4 additions & 4 deletions src/shogun/clustering/GMM.h
Expand Up @@ -50,7 +50,7 @@ class CGMM : public CDistribution
* @param coefficients mixing coefficients
* @param copy true if should be copied
*/
CGMM(const SGVector<CGaussian*>& components, const SGVector<float64_t>& coefficients,
CGMM(SGVector<CGaussian*> components, SGVector<float64_t> coefficients,
bool copy=false);
virtual ~CGMM();

Expand Down Expand Up @@ -150,7 +150,7 @@ class CGMM : public CDistribution
* @param mean new mean
* @param num index mean to set
*/
virtual void set_nth_mean(const SGVector<float64_t>& mean, int32_t num);
virtual void set_nth_mean(SGVector<float64_t> mean, int32_t num);

/** get nth covariance
*
Expand Down Expand Up @@ -189,7 +189,7 @@ class CGMM : public CDistribution
*
* @param components Gaussian components
*/
virtual void set_comp(const SGVector<CGaussian*>& components);
virtual void set_comp(SGVector<CGaussian*> components);

/** sample from model
*
Expand All @@ -202,7 +202,7 @@ class CGMM : public CDistribution
* @return log likelihood of belonging to clusters and the log likelihood of being generated by this GMM
* The length of the returned vector is number of components + 1
*/
SGVector<float64_t> cluster(const SGVector<float64_t>& point);
SGVector<float64_t> cluster(SGVector<float64_t> point);

/** @return object name */
inline virtual const char* get_name() const { return "GMM"; }
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/distributions/Gaussian.cpp
Expand Up @@ -22,7 +22,7 @@ CGaussian::CGaussian() : CDistribution(), m_constant(0), m_d(), m_u(), m_mean(),
register_params();
}

CGaussian::CGaussian(const SGVector<float64_t>& mean, SGMatrix<float64_t> cov,
CGaussian::CGaussian(const SGVector<float64_t> mean, SGMatrix<float64_t> cov,
ECovType cov_type) : CDistribution(), m_d(), m_u(), m_cov_type(cov_type)
{
ASSERT(mean.vlen==cov.num_rows);
Expand Down Expand Up @@ -118,7 +118,7 @@ float64_t CGaussian::get_log_likelihood_example(int32_t num_example)
return answer;
}

float64_t CGaussian::compute_log_PDF(const SGVector<float64_t>& point)
float64_t CGaussian::compute_log_PDF(SGVector<float64_t> point)
{
ASSERT(m_mean.vector && m_d.vector);
ASSERT(point.vlen == m_mean.vlen);
Expand Down Expand Up @@ -162,7 +162,7 @@ SGVector<float64_t> CGaussian::get_mean()
return m_mean;
}

void CGaussian::set_mean(const SGVector<float64_t> mean)
void CGaussian::set_mean(SGVector<float64_t> mean)
{
if (mean.vlen==1)
m_cov_type=SPHERICAL;
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/distributions/Gaussian.h
Expand Up @@ -54,7 +54,7 @@ class CGaussian : public CDistribution
* @param cov covariance of the Gaussian
* @param cov_type covariance type (full, diagonal or shperical)
*/
CGaussian(const SGVector<float64_t>& mean, SGMatrix<float64_t> cov, ECovType cov_type=FULL);
CGaussian(const SGVector<float64_t> mean, SGMatrix<float64_t> cov, ECovType cov_type=FULL);
virtual ~CGaussian();

/** Compute the constant part */
Expand Down Expand Up @@ -104,7 +104,7 @@ class CGaussian : public CDistribution
* @param point point for which to compute the PDF
* @return computed PDF
*/
virtual inline float64_t compute_PDF(const SGVector<float64_t>& point)
virtual inline float64_t compute_PDF(SGVector<float64_t> point)
{
return CMath::exp(compute_log_PDF(point));
}
Expand All @@ -114,7 +114,7 @@ class CGaussian : public CDistribution
* @param point point for which to compute the log PDF
* @return computed log PDF
*/
virtual float64_t compute_log_PDF(const SGVector<float64_t>& point);
virtual float64_t compute_log_PDF(SGVector<float64_t> point);

/** get mean
*
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/distributions/Histogram.cpp
Expand Up @@ -145,7 +145,7 @@ float64_t CHistogram::get_log_model_parameter(int32_t num_param)
return hist[num_param];
}

bool CHistogram::set_histogram(const SGVector<float64_t>& histogram)
bool CHistogram::set_histogram(const SGVector<float64_t> histogram)
{
ASSERT(histogram.vlen==get_num_model_parameters());

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/distributions/Histogram.h
Expand Up @@ -79,7 +79,7 @@ class CHistogram : public CDistribution
*
* @param histogram new histogram
*/
virtual bool set_histogram(const SGVector<float64_t>& histogram);
virtual bool set_histogram(const SGVector<float64_t> histogram);

/** get histogram
*
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/distributions/LinearHMM.cpp
Expand Up @@ -244,7 +244,7 @@ SGVector<float64_t> CLinearHMM::get_transition_probs()
return SGVector<float64_t>(transition_probs, num_params);
}

bool CLinearHMM::set_transition_probs(const SGVector<float64_t>& probs)
bool CLinearHMM::set_transition_probs(const SGVector<float64_t> probs)
{
ASSERT(probs.vlen == num_params);

Expand All @@ -268,7 +268,7 @@ SGVector<float64_t> CLinearHMM::get_log_transition_probs()
return SGVector<float64_t>(log_transition_probs, num_params);
}

bool CLinearHMM::set_log_transition_probs(const SGVector<float64_t>& probs)
bool CLinearHMM::set_log_transition_probs(const SGVector<float64_t> probs)
{
ASSERT(probs.vlen == num_params);

Expand Down
4 changes: 2 additions & 2 deletions src/shogun/distributions/LinearHMM.h
Expand Up @@ -189,7 +189,7 @@ class CLinearHMM : public CDistribution
* @param probs new logarithm transition probs
* @return if setting was successful
*/
virtual bool set_log_transition_probs(const SGVector<float64_t>& probs);
virtual bool set_log_transition_probs(const SGVector<float64_t> probs);

/** get all transition probs
*
Expand All @@ -202,7 +202,7 @@ class CLinearHMM : public CDistribution
* @param probs new transition probs
* @return if setting was successful
*/
virtual bool set_transition_probs(const SGVector<float64_t>& probs);
virtual bool set_transition_probs(const SGVector<float64_t> probs);

/** @return object name */
inline virtual const char* get_name() const { return "LinearHMM"; }
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/evaluation/ClusteringEvaluation.cpp
Expand Up @@ -19,7 +19,7 @@
using namespace shogun;
using namespace std;

int32_t CClusteringEvaluation::find_match_count(const SGVector<int32_t>& l1, int32_t m1, const SGVector<int32_t>& l2, int32_t m2)
int32_t CClusteringEvaluation::find_match_count(SGVector<int32_t> l1, int32_t m1, SGVector<int32_t> l2, int32_t m2)
{
int32_t match_count=0;
for (int32_t i=l1.vlen-1; i >= 0; --i)
Expand All @@ -31,7 +31,7 @@ int32_t CClusteringEvaluation::find_match_count(const SGVector<int32_t>& l1, int
return match_count;
}

int32_t CClusteringEvaluation::find_mismatch_count(const SGVector<int32_t>& l1, int32_t m1, const SGVector<int32_t>& l2, int32_t m2)
int32_t CClusteringEvaluation::find_mismatch_count(SGVector<int32_t> l1, int32_t m1, SGVector<int32_t> l2, int32_t m2)
{
return l1.vlen - find_match_count(l1, m1, l2, m2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/evaluation/ClusteringEvaluation.h
Expand Up @@ -55,12 +55,12 @@ class CClusteringEvaluation: public CEvaluation
* @param m2 the second label to match
* @return number of matches
*/
int32_t find_match_count(const SGVector<int32_t>& l1, int32_t m1, const SGVector<int32_t>& l2, int32_t m2);
int32_t find_match_count(SGVector<int32_t> l1, int32_t m1, SGVector<int32_t> l2, int32_t m2);

/** find number of mismatches in the two labels sequence.
* @see find_match_count
*/
int32_t find_mismatch_count(const SGVector<int32_t>& l1, int32_t m1, const SGVector<int32_t>& l2, int32_t m2);
int32_t find_mismatch_count(SGVector<int32_t> l1, int32_t m1, SGVector<int32_t> l2, int32_t m2);
};

} // namespace shogun
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/CombinedDotFeatures.cpp
Expand Up @@ -372,7 +372,7 @@ SGVector<float64_t> CCombinedDotFeatures::get_subfeature_weights()
return SGVector<float64_t>(weights,num_weights);
}

void CCombinedDotFeatures::set_subfeature_weights(const SGVector<float64_t>& weights)
void CCombinedDotFeatures::set_subfeature_weights(SGVector<float64_t> weights)
{
int32_t i = 0;
CListElement* current = NULL ;
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/CombinedDotFeatures.h
Expand Up @@ -284,7 +284,7 @@ class CCombinedDotFeatures : public CDotFeatures
*
* @param weights new subfeature weights
*/
virtual void set_subfeature_weights(const SGVector<float64_t>& weights);
virtual void set_subfeature_weights(SGVector<float64_t> weights);

/** @return object name */
inline virtual const char* get_name() const { return "CombinedDotFeatures"; }
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/DotFeatures.cpp
Expand Up @@ -59,7 +59,7 @@ CDotFeatures::CDotFeatures(CFile* loader)
init();
}

float64_t CDotFeatures::dense_dot_vec(int32_t vec_idx1, const SGVector<float64_t>& vec2)
float64_t CDotFeatures::dense_dot_vec(int32_t vec_idx1, SGVector<float64_t> vec2)
{
return dense_dot(vec_idx1, vec2.vector, vec2.vlen);
}
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/DotFeatures.h
Expand Up @@ -82,7 +82,7 @@ class CDotFeatures : public CFeatures
* @param vec_idx1 index of first vector
* @param vec2 dense vector
*/
virtual float64_t dense_dot_vec(int32_t vec_idx1, const SGVector<float64_t>& vec2);
virtual float64_t dense_dot_vec(int32_t vec_idx1, const SGVector<float64_t> vec2);

/** compute dot product between vector1 and a dense vector
*
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/features/Features.cpp
Expand Up @@ -349,7 +349,7 @@ void CFeatures::unset_property(EFeatureProperty p)
properties &= (properties | p) ^ p;
}

void CFeatures::add_subset(const SGVector<index_t>& subset)
void CFeatures::add_subset(SGVector<index_t> subset)
{
m_subset_stack->add_subset(subset);
subset_changed_post();
Expand All @@ -367,7 +367,7 @@ void CFeatures::remove_all_subsets()
subset_changed_post();
}

CFeatures* CFeatures::copy_subset(const SGVector<index_t>& indices)
CFeatures* CFeatures::copy_subset(SGVector<index_t> indices)
{
SG_ERROR("copy_subset and therefore model storage of CMachine "
"(required for cross-validation and model-selection is ",
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/features/Features.h
Expand Up @@ -228,7 +228,7 @@ class CFeatures : public CSGObject
*
* @param subset subset of indices to add
* */
virtual void add_subset(const SGVector<index_t>& subset);
virtual void add_subset(SGVector<index_t> subset);

/** removes that last added subset from subset stack, if existing
* Calls subset_changed_post() afterwards */
Expand All @@ -250,7 +250,7 @@ class CFeatures : public CSGObject
* @param indices indices of feature elements to copy
* @return new CFeatures instance with copies of feature data
*/
virtual CFeatures* copy_subset(const SGVector<index_t>& indices);
virtual CFeatures* copy_subset(SGVector<index_t> indices);

protected:

Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/Labels.cpp
Expand Up @@ -33,7 +33,7 @@ CLabels::CLabels(int32_t num_lab)
labels=SGVector<float64_t>(num_lab);
}

CLabels::CLabels(const SGVector<float64_t>& src)
CLabels::CLabels(SGVector<float64_t> src)
: CSGObject()
{
init();
Expand Down Expand Up @@ -165,7 +165,7 @@ SGVector<int32_t> CLabels::get_int_labels()
return intlab;
}

void CLabels::set_int_labels(const SGVector<int32_t>& lab)
void CLabels::set_int_labels(SGVector<int32_t> lab)
{
if (m_subset_stack->has_subsets())
SG_ERROR("set_int_labels() is not possible on subset");
Expand Down Expand Up @@ -246,7 +246,7 @@ int32_t CLabels::get_num_labels()
? m_subset_stack->get_size() : labels.vlen;
}

void CLabels::add_subset(const SGVector<index_t>& subset)
void CLabels::add_subset(SGVector<index_t> subset)
{
m_subset_stack->add_subset(subset);
}
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/features/Labels.h
Expand Up @@ -48,7 +48,7 @@ class CLabels : public CSGObject
*
* @param src labels to set
*/
CLabels(const SGVector<float64_t>& src);
CLabels(const SGVector<float64_t> src);

/* constructor
*
Expand Down Expand Up @@ -190,7 +190,7 @@ class CLabels : public CSGObject
*
* @param labels INT labels
*/
void set_int_labels(const SGVector<int32_t>& labels);
void set_int_labels(SGVector<int32_t> labels);

/** get number of labels, depending on whether a subset is set
*
Expand All @@ -206,7 +206,7 @@ class CLabels : public CSGObject
*
* @param subset subset of indices to add
* */
virtual void add_subset(const SGVector<index_t>& subset);
virtual void add_subset(SGVector<index_t> subset);

/** removes that last added subset from subset stack, if existing
* Calls subset_changed_post() afterwards */
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/features/SimpleFeatures.cpp
Expand Up @@ -131,7 +131,7 @@ template<class ST> ST* CSimpleFeatures<ST>::get_feature_vector(int32_t num, int3
return feat;
}

template<class ST> void CSimpleFeatures<ST>::set_feature_vector(const SGVector<ST>& vector, int32_t num)
template<class ST> void CSimpleFeatures<ST>::set_feature_vector(SGVector<ST> vector, int32_t num)
{
/* index conversion for subset, only for array access */
int32_t real_num=m_subset_stack->subset_idx_conversion(num);
Expand Down Expand Up @@ -598,7 +598,7 @@ template<class ST> void CSimpleFeatures<ST>::free_feature_iterator(void* iterato
SG_FREE(it);
}

template<class ST> CFeatures* CSimpleFeatures<ST>::copy_subset(const SGVector<index_t>& indices)
template<class ST> CFeatures* CSimpleFeatures<ST>::copy_subset(SGVector<index_t> indices)
{
SGMatrix<ST> feature_matrix_copy(num_features, indices.vlen);

Expand Down
4 changes: 2 additions & 2 deletions src/shogun/features/SimpleFeatures.h
Expand Up @@ -134,7 +134,7 @@ template<class ST> class CSimpleFeatures: public CDotFeatures
* @param vector vector
* @param num index if vector to set
*/
void set_feature_vector(const SGVector<ST>& vector, int32_t num);
void set_feature_vector(SGVector<ST> vector, int32_t num);

/** get feature vector num
*
Expand Down Expand Up @@ -501,7 +501,7 @@ template<class ST> class CSimpleFeatures: public CDotFeatures
* @param indices indices of feature elements to copy
* @return new CFeatures instance with copies of feature data
*/
virtual CFeatures* copy_subset(const SGVector<index_t>& indices);
virtual CFeatures* copy_subset(SGVector<index_t> indices);

/** checks if the contents of this CSimpleFeatures object are the same to
* the contents of rhs
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/features/SparseFeatures.cpp
Expand Up @@ -1086,7 +1086,7 @@ template<class ST> void CSparseFeatures<ST>::free_feature_iterator(void* iterato
SG_FREE(it);
}

template<class ST> CFeatures* CSparseFeatures<ST>::copy_subset(const SGVector<index_t>& indices)
template<class ST> CFeatures* CSparseFeatures<ST>::copy_subset(SGVector<index_t> indices)
{
SGSparseMatrix<ST> matrix_copy=SGSparseMatrix<ST>(indices.vlen,
get_dim_feature_space());
Expand Down

0 comments on commit 2d8d9bc

Please sign in to comment.