Skip to content

Commit

Permalink
Fixed sparse matrix handling in static
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Jun 29, 2012
1 parent 9962e1d commit a10eab1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/shogun/features/SparseFeatures.cpp
Expand Up @@ -91,13 +91,10 @@ template<class ST> CSparseFeatures<ST>::~CSparseFeatures()
}
template<class ST> void CSparseFeatures<ST>::free_sparse_feature_matrix()
{
if (sparse_feature_matrix)
{
for (int32_t i=0; i<num_vectors; i++)
(&sparse_feature_matrix[i])->~SGSparseVector();
for (int32_t i=0; i<num_vectors; i++)
(&sparse_feature_matrix[i])->~SGSparseVector();

SG_FREE(sparse_feature_matrix);
}
SG_FREE(sparse_feature_matrix);
num_vectors=0;
num_features=0;
remove_all_subsets();
Expand Down
4 changes: 3 additions & 1 deletion src/shogun/io/AsciiFile.cpp
Expand Up @@ -318,7 +318,9 @@ void CAsciiFile::fname(SGSparseVector<sg_type>*& matrix, int32_t& num_feat, int3
blocksize=required_blocksize; \
dummy = SG_MALLOC(uint8_t, blocksize+1); /*allow setting of '\0' at EOL*/ \
matrix=SG_MALLOC(SGSparseVector<sg_type>, num_vec); \
\
for (int i=0; i<num_vec; i++) \
new (&matrix[i]) SGSparseVector<sg_type>(); \
\
rewind(file); \
sz=blocksize; \
int32_t lines=0; \
Expand Down
4 changes: 1 addition & 3 deletions src/shogun/ui/SGInterface.cpp
Expand Up @@ -1811,9 +1811,7 @@ bool CSGInterface::do_set_features(bool add, bool check_dot, int32_t repetitions
SGSparseVector<float64_t>* fmatrix=NULL;
get_sparse_matrix(fmatrix, num_feat, num_vec);

feat=new CSparseFeatures<float64_t>();
((CSparseFeatures<float64_t>*) feat)->
set_sparse_feature_matrix(SGSparseMatrix<float64_t>(fmatrix, num_feat, num_vec));
feat=new CSparseFeatures<float64_t>(fmatrix, num_feat, num_vec);
break;
}

Expand Down

0 comments on commit a10eab1

Please sign in to comment.