Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/puffin444/shogun
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Jul 11, 2012
2 parents 179b38e + 7a90611 commit 7b220bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
32 changes: 18 additions & 14 deletions src/shogun/regression/gp/ExactInferenceMethod.cpp
Expand Up @@ -26,19 +26,15 @@ using namespace shogun;

CExactInferenceMethod::CExactInferenceMethod() : CInferenceMethod()
{
update_train_kernel();
update_chol();
update_alpha();
update_all();
update_parameter_hash();
}

CExactInferenceMethod::CExactInferenceMethod(CKernel* kern, CFeatures* feat,
CMeanFunction* m, CLabels* lab, CLikelihoodModel* mod) :
CInferenceMethod(kern, feat, m, lab, mod)
{
update_train_kernel();
update_chol();
update_alpha();
update_all();
}

CExactInferenceMethod::~CExactInferenceMethod()
Expand All @@ -47,28 +43,36 @@ CExactInferenceMethod::~CExactInferenceMethod()

void CExactInferenceMethod::update_all()
{
m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();
if (m_labels)
m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();

if(m_features->has_property(FP_DOT))
if (m_features && m_features->has_property(FP_DOT) && m_features->get_num_vectors())
m_feature_matrix =
((CDotFeatures*)m_features)->get_computed_dot_feature_matrix();

else if(m_features->get_feature_class() == C_COMBINED)
else if (m_features && m_features->get_feature_class() == C_COMBINED)
{
CDotFeatures* feat =
(CDotFeatures*)((CCombinedFeatures*)m_features)->
get_first_feature_obj();

m_feature_matrix = feat->get_computed_dot_feature_matrix();
if (feat->get_num_vectors())
m_feature_matrix = feat->get_computed_dot_feature_matrix();

SG_UNREF(feat);
}

update_data_means();
update_train_kernel();
update_chol();
update_alpha();

if (m_kernel)
update_train_kernel();

if (m_ktrtr.num_cols*m_ktrtr.num_rows)
{
update_chol();
update_alpha();
}
}

void CExactInferenceMethod::check_members()
Expand Down
16 changes: 10 additions & 6 deletions src/shogun/regression/gp/InferenceMethod.cpp
Expand Up @@ -69,17 +69,18 @@ void CInferenceMethod::set_features(CFeatures* feat)
SG_UNREF(m_features);
m_features=feat;

if (m_features && m_features->has_property(FP_DOT))
if (m_features && m_features->has_property(FP_DOT) && m_features->get_num_vectors())
m_feature_matrix =
((CDotFeatures*)m_features)->get_computed_dot_feature_matrix();

else if(m_features && m_features->get_feature_class() == C_COMBINED)
else if (m_features && m_features->get_feature_class() == C_COMBINED)
{
CDotFeatures* subfeat =
(CDotFeatures*)((CCombinedFeatures*)m_features)->
get_first_feature_obj();

m_feature_matrix = subfeat->get_computed_dot_feature_matrix();

if (m_features->get_num_vectors())
m_feature_matrix = subfeat->get_computed_dot_feature_matrix();

SG_UNREF(subfeat);
}
Expand Down Expand Up @@ -117,8 +118,11 @@ void CInferenceMethod::set_labels(CLabels* lab)
SG_UNREF(m_labels);
m_labels = lab;

m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();
if (m_labels)
{
m_label_vector =
((CRegressionLabels*) m_labels)->get_labels().clone();
}

update_data_means();
update_alpha();
Expand Down

0 comments on commit 7b220bf

Please sign in to comment.