#include <chrono>
#include <iostream>
#include <vector>
std::cout << "ortho_adapt algorithm benchmarks: \n";
regularizationConfig.
lambda_ = 0.0001;
size_t number_points_to_refine = 1;
size_t number_points_to_coarsen = 1;
std::cout <<
"dim = " << gridConfig.
dim_ <<
"\n";
std::cout <<
"lvl = " << gridConfig.
level_ <<
"\n";
std::cout <<
"lambda = " << regularizationConfig.
lambda_ <<
"\n\n";
std::unique_ptr<sgpp::base::Grid> grid = std::unique_ptr<sgpp::base::Grid>{
gridFactory.
createGrid(gridConfig, std::vector<std::vector <size_t>>())
};
std::cout <<
"initial matrix size = " << offline.
getGridSize();
std::cout << "\n\ndecomposition took ";
auto begin = std::chrono::high_resolution_clock::now();
auto end = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).
count() <<
"ms" << std::endl;
size_t refine_size = offline.
getGridSize() + number_points_to_refine;
size_t coarsen_size = refine_size - number_points_to_coarsen;
for (
size_t i = 0;
i < number_points_to_refine;
i++) {
for (
size_t j = 0;
j < refine_size;
j++) {
double value = (static_cast<double>(rand()) / (RAND_MAX));
}
online.add_new_refine_point(vec);
}
std::cout << "\nrefining " << number_points_to_refine << " points took ";
begin = std::chrono::high_resolution_clock::now();
online.sherman_morrison_adapt(number_points_to_refine, true);
end = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).
count() <<
"ms" << std::endl;
std::vector<size_t> coarsen_indices = {};
for (
size_t i = 0;
i < number_points_to_coarsen;
i++) {
size_t index = ((size_t)rand() % (refine_size - coarsen_size)) + offline.
getGridSize();
coarsen_indices.push_back(index);
}
std::cout << "\ncoarsening " << number_points_to_coarsen << " points took ";
online.sherman_morrison_adapt(0, false, coarsen_indices);
end = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).
count() <<
"ms" << std::endl;
return 0;
}