OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
object_s_di_op< op, v_src, v_dst, OBJ_ENCAP, prp...> Struct Template Reference

It copy the properties from one object to another applying an operation. More...

Detailed Description

template<template< typename, typename > class op, typename v_src, typename v_dst, int... prp>
struct object_s_di_op< op, v_src, v_dst, OBJ_ENCAP, prp...>

It copy the properties from one object to another applying an operation.

Given a set of properties for the destination object (0,1,3) it copy that properties to the source object properties (0,1,2) applying an operation

For object we mean an object that follow the OpenFPM data structure format, see openFPM_data wiki for more information

Create a compile-time object and copy to the selected properties applying an operation

typedef Point_test<float> p;
typedef Point_test<float>::type vboost;
typedef object_creator<Point_test<float>::type,0,1,4>::type vboost_red;
object<vboost> dst;
object<vboost_red> src;
// fill the source properties 0,1,2 with data
boost::fusion::at_c<0>(src.data) = 1.0;
boost::fusion::at_c<1>(src.data) = 2.0;
for (size_t i = 0 ; i < 3 ; i++)
boost::fusion::at_c<2>(src.data)[i] = i + 5.0;
boost::fusion::at_c<0>(dst.data) = 2.0;
boost::fusion::at_c<1>(dst.data) = 3.0;
for (size_t i = 0 ; i < 3 ; i++)
boost::fusion::at_c<4>(dst.data)[i] = i + 7.0;
// copy from src to dst
object_s_di_op<add_,object<vboost_red>,object<vboost>,OBJ_NORMAL,0,1,4>(src,dst);
// Check the result
BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::x>(dst.data),3.0);
BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::y>(dst.data),5.0);
for (size_t i = 0 ; i < 3 ; i++)
BOOST_REQUIRE_EQUAL(boost::fusion::at_c<p::v>(dst.data)[i],2*i + 12.0);

Create a compile-time Encap object and copy to the selected properties applying an operation

typedef encapc<1,Point_test<float>,openfpm::vector<Point_test<float>>::layout_type> encap_dst;
typedef encapc<1,object<vboost_red>,openfpm::vector<object<vboost_red>>::layout_type> encap_src;
v_point.resize(2);
v_point_red.resize(2);
v_point_red.template get<0>(0) = 11.0;
v_point_red.template get<1>(0) = 12.0;
v_point.template get<0>(0) = 10.0;
v_point.template get<1>(0) = 9.0;
for (size_t i = 0 ; i < 3 ; i++)
v_point_red.template get<2>(0)[i] = i + 8.0;
for (size_t i = 0 ; i < 3 ; i++)
v_point.template get<4>(0)[i] = i + 3.0;
auto dst_e = v_point.get(0);
auto src_e = v_point_red.get(0);
BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::x>(),21.0);
BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::y>(),21.0);
for (size_t i = 0 ; i < 3 ; i++)
BOOST_REQUIRE_EQUAL(v_point.get(0).template get<p::v>()[i],2*i + 11.0);

Definition at line 436 of file object_s_di.hpp.

#include <object_s_di.hpp>

Public Member Functions

 object_s_di_op (const v_src &vs, v_dst &&vd)
 Implementation of the copy with operation. More...
 
 object_s_di_op (const v_src &vs, v_dst &vd)
 Implementation of the copy with operation. More...
 

Constructor & Destructor Documentation

template<template< typename, typename > class op, typename v_src , typename v_dst , int... prp>
object_s_di_op< op, v_src, v_dst, OBJ_ENCAP, prp...>::object_s_di_op ( const v_src &  vs,
v_dst &&  vd 
)
inline

Implementation of the copy with operation.

Parameters
vssource object
vddestination object

Definition at line 444 of file object_s_di.hpp.

template<template< typename, typename > class op, typename v_src , typename v_dst , int... prp>
object_s_di_op< op, v_src, v_dst, OBJ_ENCAP, prp...>::object_s_di_op ( const v_src &  vs,
v_dst &  vd 
)
inline

Implementation of the copy with operation.

Parameters
vssource object
vddestination object

Definition at line 456 of file object_s_di.hpp.


The documentation for this struct was generated from the following file: