Example how to use for bvector re-mapping / transformation based on sparse_vector as a translation table.Example discusses how use of NULL (unassigned) sparse_vector<> semantics affects behavior of image transformation algorithm.
- See also
- bm::sparse_vector<>
-
bm::set2set_11_transform
#include <iostream>
#include <vector>
using namespace std;
static
{
{
cout << sv.
size() <<
": [ EMPTY ]" << endl;
return;
}
cout << sv.
size() <<
": [ ";
for (
unsigned i = 0; i < sv.
size(); ++i)
{
if (is_null)
cout << "NULL";
else
cout << v << "";
cout << " ]";
else
cout << ", ";
}
cout << endl;
}
inline
{
cout <<
"( count = " << bv.
count() <<
")" <<
": [";
{
cout << *en << ", ";
}
cout << "]" << endl;
}
{
try
{
sv_transform.set(2, 25);
sv_transform.set(3, 35);
sv_transform.set(7, 75);
sv_transform.set(1000, 2000);
sv_transform.set(256, 2001);
func.
run(bv_in, sv_transform, bv_out);
std::cout << "re-mapped vector:" << endl;
bool found = func.
remap(1, sv_transform, to);
if (!found)
std::cout << from << " not mapped" << std::endl;
else
std::cout << from << " mapped to " << to << std::endl;
sv_transform2.
set(2, 25);
sv_transform2.
set(3, 35);
sv_transform2.
set(7, 75);
sv_transform2.
set(1000, 2000);
sv_transform2.
set(256, 2001);
found = func.
remap(1, sv_transform2, to);
if (!found)
std::cout << from << " not mapped" << std::endl;
else
std::cout << from << " mapped to " << to << std::endl;
func.
run(bv_in, sv_transform2, bv_out);
std::cout << "re-mapped vector2:" << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}