diff --git a/fastlib/trunk/contrib/dongryel/multigrid/multigrid_dev.h b/fastlib/trunk/contrib/dongryel/multigrid/multigrid_dev.h index 9c61e62f1b..3e87936ba7 100644 --- a/fastlib/trunk/contrib/dongryel/multigrid/multigrid_dev.h +++ b/fastlib/trunk/contrib/dongryel/multigrid/multigrid_dev.h @@ -24,7 +24,7 @@ void Multigrid::Coarsen_( // previous level. const std::vector &fine_point_indices = level_in.point_indices(); std::vector shuffle_indices(fine_point_indices.size()); - for (int i = 0; i < shuffle_indices.size(); i++) { + for (unsigned int i = 0; i < shuffle_indices.size(); i++) { shuffle_indices[i] = i; } std::random_shuffle(shuffle_indices.begin(), shuffle_indices.end()); @@ -35,7 +35,7 @@ void Multigrid::Coarsen_( // point. std::vector< std::pair > coarse_point_indices; - for (int i = 0; i < fine_point_indices.size(); i++) { + for (unsigned int i = 0; i < fine_point_indices.size(); i++) { // The index of the fine node point. int fine_point_index = shuffle_indices[i]; @@ -46,7 +46,7 @@ void Multigrid::Coarsen_( // Compute the sum of the affinities between the current fine node // point and the existing set of coarse points. double sum_coarse_affinities = 0; - for (int j = 0; j < coarse_point_indices.size(); j++) { + for (unsigned int j = 0; j < coarse_point_indices.size(); j++) { // The physical index of the coarse node point. int coarse_point_index = coarse_point_indices[j].first; @@ -57,7 +57,7 @@ void Multigrid::Coarsen_( // Compute the sum of the affinities between the current fine node // and all of the points. double sum_all_affinities = 0; - for (int j = 0; j < fine_point_indices.size(); j++) { + for (unsigned int j = 0; j < fine_point_indices.size(); j++) { sum_all_affinities += level_in.get(fine_point_index, j); } @@ -101,7 +101,7 @@ void Multigrid::Init( // The next level to be generated. MultigridLevel &next_level = levels_[ levels_.size() - 1 ]; - Coarsen_(previous_level, &next_level); + Coarsen_(*previous_level, &next_level); // Change the previous level pointer. previous_level = &next_level; diff --git a/fastlib/trunk/contrib/dongryel/multigrid/multigrid_test.cc b/fastlib/trunk/contrib/dongryel/multigrid/multigrid_test.cc index ebb5f1d0a3..46d06c9ba9 100644 --- a/fastlib/trunk/contrib/dongryel/multigrid/multigrid_test.cc +++ b/fastlib/trunk/contrib/dongryel/multigrid/multigrid_test.cc @@ -19,6 +19,21 @@ class MultigridTest { int num_dimensions = math::RandInt(10, 70); left_hand_side_out->Init(num_dimensions, num_dimensions); right_hand_side_out->Init(num_dimensions); + + for(int j = 0; j < left_hand_side_out->n_cols(); j++) { + for(int i = 0; i < left_hand_side_out->n_rows(); i++) { + if(i == j) { + left_hand_side_out->set(i, j, 4.0); + } + else if(i == j + 1 || i + 1 == j) { + left_hand_side_out->set(i, j, -1.0); + } + else { + left_hand_side_out->set(i, j, 0.0); + } + } + (*right_hand_side_out)[j] = math::Random(1.5, 4.0); + } } public: @@ -30,6 +45,8 @@ class MultigridTest { Matrix left_hand_side; Vector right_hand_side; RandomSystem_(&left_hand_side, &right_hand_side); + + multigrid.Init(left_hand_side, right_hand_side, 1000); } void Start() {