int hpx_main(boost::program_options::variables_map& vm) { std::size_t size = 1; for (std::size_t i = 0; i != 20; ++i) { // create argument for action std::vector<double> data1; data1.resize(size << i); hpx::serialization::serialize_buffer<double> buffer1(data1.data(), data1.size(), hpx::serialization::serialize_buffer<double>::reference); test_normal_serialization<test_action1>(buffer1); test_zero_copy_serialization<test_action1>(buffer1); std::vector<int> data2; data2.resize(size << i); hpx::serialization::serialize_buffer<int> buffer2(data2.data(), data2.size(), hpx::serialization::serialize_buffer<int>::reference); test_normal_serialization(buffer1, buffer2); test_zero_copy_serialization(buffer1, buffer2); test_normal_serialization(42.0, buffer1, "42.0", 42, buffer2); test_zero_copy_serialization(42.0, buffer1, "42.0", 42, buffer2); data_buffer<double> buffer3(size << i); test_normal_serialization<test_action4>(buffer3); test_zero_copy_serialization<test_action4>(buffer3); } return hpx::finalize(); }
void testCMarginBuffer() { const int64_t cols = 23; const int64_t rows = 54; const int64_t numPixels = cols * rows; const int64_t numElements = (cols + 2 * margin) * (rows + 2 * margin); CMarginBuffer2D<margin> buffer1(cols, rows); EXPECT_EQ(cols, buffer1.cols()); EXPECT_EQ(rows, buffer1.rows()); EXPECT_EQ(numPixels, buffer1.numPixels()); EXPECT_EQ(numElements, buffer1.numElements()); // generate test data generateTestData(buffer1); // check the data in the buffer for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)), static_cast<Real>(x)), buffer1.pixel(x, y)); } } // create a compatible buffer auto buffer2 = buffer1.createCompatibleBuffer(); EXPECT_EQ(cols, buffer1.cols()); EXPECT_EQ(rows, buffer2.rows()); EXPECT_EQ(numPixels, buffer2.numPixels()); EXPECT_EQ(numElements, buffer2.numElements()); EXPECT_TRUE(buffer1.compatible(buffer2)); EXPECT_TRUE(buffer2.compatible(buffer1)); // copy the data in the new buffer buffer2.assign(buffer1); // clear the first buffer const Complex clearValue(42.0, -8.0); buffer1.setValue(clearValue); // check the data in the first buffer for (int64_t y = 0; y < rows; ++y) for (int64_t x = 0; x < cols; ++x) EXPECT_EQ(clearValue, buffer1.pixel(x, y)); // check the data in the second buffer for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)), static_cast<Real>(x)), buffer2.pixel(x, y)); } } // test addAssign buffer1.setValue(Complex(1.0, -1.0)); generateTestData(buffer2); buffer1 += buffer2; for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)) + R(1.0), static_cast<Real>(x) - R(1.0)), buffer1.pixel(x, y)); } } // test multiplyAssign(CMarginBuffer) buffer1.setValue(Complex(1.0, -1.0)); generateTestData(buffer2); buffer1 *= buffer2; for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)) + static_cast<Real>(x), -std::sin(static_cast<Real>(y)) + static_cast<Real>(x)), buffer1.pixel(x, y)); } } // test multiplyAssign(Complex) generateTestData(buffer1); buffer1 *= Complex(1.0, -1.0); for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)) + static_cast<Real>(x), -std::sin(static_cast<Real>(y)) + static_cast<Real>(x)), buffer1.pixel(x, y)); } } // test multiplyAssign(Real) generateTestData(buffer1); buffer1 *= 5.0; for (int64_t y = 0; y < rows; ++y) { for (int64_t x = 0; x < cols; ++x) { EXPECT_EQ(Complex(std::sin(static_cast<Real>(y)) * R(5.0), static_cast<Real>(x) * R(5.0)), buffer1.pixel(x, y)); } } // create a third buffer const Complex initialValue(-49.0, 7.0); CMarginBuffer2D<margin> buffer3(cols + 1, rows, initialValue); EXPECT_FALSE(buffer3.compatible(buffer1)); EXPECT_FALSE(buffer1.compatible(buffer3)); for (int64_t y = 0; y < rows; ++y) for (int64_t x = 0; x < cols; ++x) EXPECT_EQ(initialValue, buffer3.pixel(x, y)); std::mt19937 generator; std::uniform_real_distribution<Real> distribution(0.0, Math::twoPi); for (int64_t y = 0; y < rows; ++y) for (int64_t x = 0; x < cols + 1; ++x) buffer3.pixel(x, y) = fromArg(distribution(generator)); EXPECT_EQ(buffer3.numPixels(), buffer3.absSqrReduce()); // todo: test multiplyAssign // todo: test info }
//Lecture du fichier DIMAP Dimap::Dimap(std::string const &filename) { direct_samp_num_coef.clear(); direct_samp_den_coef.clear(); direct_line_num_coef.clear(); direct_line_den_coef.clear(); indirect_samp_num_coef.clear(); indirect_samp_den_coef.clear(); indirect_line_num_coef.clear(); indirect_line_den_coef.clear(); cElXMLTree tree(filename.c_str()); { std::list<cElXMLTree*> noeuds=tree.GetAll(std::string("Direct_Model")); std::list<cElXMLTree*>::iterator it_grid,fin_grid=noeuds.end(); std::string coefSampN="SAMP_NUM_COEFF"; std::string coefSampD="SAMP_DEN_COEFF"; std::string coefLineN="LINE_NUM_COEFF"; std::string coefLineD="LINE_DEN_COEFF"; for (int c=1; c<21;c++) { std::stringstream ss; ss<<"_"<<c; coefSampN.append(ss.str()); coefSampD.append(ss.str()); coefLineN.append(ss.str()); coefLineD.append(ss.str()); for(it_grid=noeuds.begin();it_grid!=fin_grid;++it_grid) { double value; std::istringstream buffer((*it_grid)->GetUnique(coefSampN.c_str())->GetUniqueVal()); buffer >> value; direct_samp_num_coef.push_back(value); std::istringstream buffer2((*it_grid)->GetUnique(coefSampD.c_str())->GetUniqueVal()); buffer2 >> value; direct_samp_den_coef.push_back(value); std::istringstream buffer3((*it_grid)->GetUnique(coefLineN.c_str())->GetUniqueVal()); buffer3 >> value; direct_line_num_coef.push_back(value); std::istringstream buffer4((*it_grid)->GetUnique(coefLineD.c_str())->GetUniqueVal()); buffer4 >> value; direct_line_den_coef.push_back(value); } coefSampN=coefSampN.substr(0,14); coefSampD=coefSampD.substr(0,14); coefLineN=coefLineN.substr(0,14); coefLineD=coefLineD.substr(0,14); } for(it_grid=noeuds.begin();it_grid!=fin_grid;++it_grid) { std::istringstream buffer((*it_grid)->GetUnique("ERR_BIAS_X")->GetUniqueVal()); buffer >> dirErrBiasX; std::istringstream bufferb((*it_grid)->GetUnique("ERR_BIAS_Y")->GetUniqueVal()); bufferb >> dirErrBiasY; } } { std::list<cElXMLTree*> noeudsInv=tree.GetAll(std::string("Inverse_Model")); std::list<cElXMLTree*>::iterator it_gridInd,fin_gridInd=noeudsInv.end(); std::string coefSampN="SAMP_NUM_COEFF"; std::string coefSampD="SAMP_DEN_COEFF"; std::string coefLineN="LINE_NUM_COEFF"; std::string coefLineD="LINE_DEN_COEFF"; for (int c=1; c<21;c++) { double value; std::stringstream ss; ss<<"_"<<c; coefSampN.append(ss.str()); coefSampD.append(ss.str()); coefLineN.append(ss.str()); coefLineD.append(ss.str()); for(it_gridInd=noeudsInv.begin();it_gridInd!=fin_gridInd;++it_gridInd) { std::istringstream bufferInd((*it_gridInd)->GetUnique(coefSampN.c_str())->GetUniqueVal()); bufferInd >> value; indirect_samp_num_coef.push_back(value); std::istringstream bufferInd2((*it_gridInd)->GetUnique(coefSampD.c_str())->GetUniqueVal()); bufferInd2 >> value; indirect_samp_den_coef.push_back(value); std::istringstream bufferInd3((*it_gridInd)->GetUnique(coefLineN.c_str())->GetUniqueVal()); bufferInd3 >> value; indirect_line_num_coef.push_back(value); std::istringstream bufferInd4((*it_gridInd)->GetUnique(coefLineD.c_str())->GetUniqueVal()); bufferInd4 >> value; indirect_line_den_coef.push_back(value); } coefSampN=coefSampN.substr(0,14); coefSampD=coefSampD.substr(0,14); coefLineN=coefLineN.substr(0,14); coefLineD=coefLineD.substr(0,14); } for(it_gridInd=noeudsInv.begin();it_gridInd!=fin_gridInd;++it_gridInd) { std::istringstream buffer((*it_gridInd)->GetUnique("ERR_BIAS_ROW")->GetUniqueVal()); buffer >> indirErrBiasRow; std::istringstream bufferb((*it_gridInd)->GetUnique("ERR_BIAS_COL")->GetUniqueVal()); bufferb >> indirErrBiasCol; } } { std::list<cElXMLTree*> noeudsRFM=tree.GetAll(std::string("RFM_Validity")); std::list<cElXMLTree*>::iterator it_gridRFM,fin_gridRFM=noeudsRFM.end(); { std::list<cElXMLTree*> noeudsInv=tree.GetAll(std::string("Direct_Model_Validity_Domain")); std::list<cElXMLTree*>::iterator it_gridInd,fin_gridInd=noeudsInv.end(); for(it_gridInd=noeudsInv.begin();it_gridInd!=fin_gridInd;++it_gridInd) { std::istringstream bufferInd((*it_gridInd)->GetUnique("FIRST_ROW")->GetUniqueVal()); bufferInd >> first_row; std::istringstream bufferInd2((*it_gridInd)->GetUnique("FIRST_COL")->GetUniqueVal()); bufferInd2 >> first_col; std::istringstream bufferInd3((*it_gridInd)->GetUnique("LAST_ROW")->GetUniqueVal()); bufferInd3 >> last_row; std::istringstream bufferInd4((*it_gridInd)->GetUnique("LAST_COL")->GetUniqueVal()); bufferInd4 >> last_col; } } { std::list<cElXMLTree*> noeudsInv=tree.GetAll(std::string("Inverse_Model_Validity_Domain")); std::list<cElXMLTree*>::iterator it_gridInd,fin_gridInd=noeudsInv.end(); for(it_gridInd=noeudsInv.begin();it_gridInd!=fin_gridInd;++it_gridInd) { std::istringstream bufferInd((*it_gridInd)->GetUnique("FIRST_LON")->GetUniqueVal()); bufferInd >> first_lon; std::istringstream bufferInd2((*it_gridInd)->GetUnique("FIRST_LAT")->GetUniqueVal()); bufferInd2 >> first_lat; std::istringstream bufferInd3((*it_gridInd)->GetUnique("LAST_LON")->GetUniqueVal()); bufferInd3 >> last_lon; std::istringstream bufferInd4((*it_gridInd)->GetUnique("LAST_LAT")->GetUniqueVal()); bufferInd4 >> last_lat; } } for(it_gridRFM=noeudsRFM.begin();it_gridRFM!=fin_gridRFM;++it_gridRFM) { std::istringstream buffer((*it_gridRFM)->GetUnique("LONG_SCALE")->GetUniqueVal()); buffer>> long_scale; std::istringstream buffer2((*it_gridRFM)->GetUnique("LONG_OFF")->GetUniqueVal()); buffer2 >> long_off; std::istringstream buffer3((*it_gridRFM)->GetUnique("LAT_SCALE")->GetUniqueVal()); buffer3 >> lat_scale; std::istringstream buffer4((*it_gridRFM)->GetUnique("LAT_OFF")->GetUniqueVal()); buffer4 >> lat_off; std::istringstream buffer5((*it_gridRFM)->GetUnique("HEIGHT_SCALE")->GetUniqueVal()); buffer5 >> height_scale; std::istringstream buffer6((*it_gridRFM)->GetUnique("HEIGHT_OFF")->GetUniqueVal()); buffer6 >> height_off; std::istringstream buffer7((*it_gridRFM)->GetUnique("SAMP_SCALE")->GetUniqueVal()); buffer7 >> samp_scale; std::istringstream buffer8((*it_gridRFM)->GetUnique("SAMP_OFF")->GetUniqueVal()); buffer8 >> samp_off; std::istringstream buffer9((*it_gridRFM)->GetUnique("LINE_SCALE")->GetUniqueVal()); buffer9 >> line_scale; std::istringstream buffer10((*it_gridRFM)->GetUnique("LINE_OFF")->GetUniqueVal()); buffer10 >> line_off; } } }