-
-
Save c3h3/88d3f54df3141358f255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This program is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation; either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* Written (W) 2013 Soumyajit De | |
*/ | |
#include <shogun/lib/common.h> | |
#include <shogun/lib/SGVector.h> | |
#include <shogun/lib/SGSparseVector.h> | |
#include <shogun/lib/SGSparseMatrix.h> | |
using namespace shogun; | |
// this is fine | |
void test1() | |
{ | |
const int32_t size=10; | |
const int32_t num_feat=size/2; | |
SGSparseMatrix<float64_t> m(size, size); | |
for (index_t i=0; i<size; ++i) | |
{ | |
m.sparse_matrix[i]=SGSparseVector<float64_t>(num_feat); | |
for (index_t j=0; j<num_feat; ++j) | |
{ | |
SGSparseVectorEntry<float64_t> entry; | |
entry.feat_index=(j+1)*2; | |
entry.entry=0.5; | |
m.sparse_matrix[i].features[j]=entry; | |
} | |
} | |
} | |
// this is not | |
void test2() | |
{ | |
const int32_t size=10; | |
const int32_t num_feat=size/2; | |
SGSparseMatrix<complex64_t> m(size, size); | |
for (index_t i=0; i<size; ++i) | |
{ | |
m.sparse_matrix[i]=SGSparseVector<complex64_t>(num_feat); | |
for (index_t j=0; j<num_feat; ++j) | |
{ | |
SGSparseVectorEntry<complex64_t> entry; | |
entry.feat_index=(j+1)*2; | |
entry.entry=0.5; | |
m.sparse_matrix[i].features[j]=entry; | |
} | |
} | |
} | |
int main(int argc, char** argv) | |
{ | |
init_shogun_with_defaults(); | |
sg_io->set_loglevel(MSG_DEBUG); | |
test1(); | |
test2(); | |
exit_shogun(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment