12 #ifndef SSTMAC_COMMON_MESSAGES_VECTORPAYLOAD_H_INCLUDED 13 #define SSTMAC_COMMON_MESSAGES_VECTORPAYLOAD_H_INCLUDED 17 #include <sstmac/common/messages/payload.h> 26 template<
typename Type,
typename VectorType = std::vector<Type> >
35 typedef VectorType arraytype;
51 Type* casted = (Type*) data;
53 for (
int i = 0; i < count; ++i) {
64 construct(
const arraytype &inval,
int dim1, ptrdiff_t stride = 1) {
93 for (
int i = 0; i <
dims_.size(); i++) {
96 return sizeof(Type) * dimsize;
106 virtual payload::const_ptr
107 add(
const payload::const_ptr &other)
const {
110 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
112 for (
int i = 0; i <
dims_[0]; i++) {
114 newval[i] =
underneath_[i] + casted->typed_data()[i];
118 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
125 virtual payload::const_ptr
126 prod(
const payload::const_ptr &other)
const {
129 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
131 for (
int i = 0; i <
dims_[0]; i++) {
133 newval[i] =
underneath_[i] * casted->typed_data()[i];
137 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
149 virtual payload::const_ptr
150 min(
const payload::const_ptr &other)
const {
153 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
155 for (
int i = 0; i <
dims_[0]; i++) {
158 : casted->typed_data()[i];
162 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
174 virtual payload::const_ptr
175 max(
const payload::const_ptr &other)
const {
178 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
180 for (
int i = 0; i <
dims_[0]; i++) {
183 : casted->typed_data()[i];
187 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
201 equals(
const payload::const_ptr &other)
const {
204 for (
int i = 0; i <
dims_[0]; i++) {
218 virtual payload::const_ptr
222 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
224 for (
int i = 0; i <
dims_[0]; i++) {
225 newval[i] =
underneath_[i] || casted->typed_data()[i];
228 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
240 virtual payload::const_ptr
244 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
246 for (
int i = 0; i <
dims_[0]; i++) {
247 newval[i] = ((
underneath_[i] || casted->typed_data()[i])
251 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
263 virtual payload::const_ptr
267 Type* newval = (Type*) malloc(
sizeof(Type) *
dims_[0]);
269 for (
int i = 0; i <
dims_[0]; i++) {
270 newval[i] =
underneath_[i] && casted->typed_data()[i];
273 payload::const_ptr ret =
new Vector1Payload(newval, dims_[0],
true, 1);
285 virtual payload::const_ptr
295 virtual payload::const_ptr
305 virtual payload::const_ptr
321 std::stringstream ss;
322 ss <<
"vector1_payload(" 323 <<
typeid(Type).name() <<
", " <<
dims_[0]
330 dims_.push_back(dim1);
334 for (
int i = 0; i < dim1; i++) {
341 dims_.push_back(dim1);
345 for (
int i = 0; i < dim1; i++) {
virtual payload::const_ptr bitwise_or(const payload::const_ptr &other) const
Logical or comparator.
virtual bool equals(const payload::const_ptr &other) const
Equals comparator.
virtual payload::const_ptr logical_or(const payload::const_ptr &other) const
Logical or comparator.
#define ptr_safe_cast(type,...)
First entry in VA_ARGS is the obj Second entry is optional being an error msg.
void * data() const
Access the underlying data in a const context.
virtual payload::const_ptr prod(const payload::const_ptr &other) const
virtual std::string to_string() const
Strinfier.
virtual payload::const_ptr add(const payload::const_ptr &other) const
Add operator.
virtual void serialize_order(serializer &ser)
virtual ~vector1_payload()
Network payload consisting of a boost multiarray.
virtual payload::const_ptr min(const payload::const_ptr &other) const
Less than comparator.
virtual payload::const_ptr max(const payload::const_ptr &other) const
Greater than comparator.
virtual payload::const_ptr logical_and(const payload::const_ptr &other) const
Logical and comparator.
#define ImplementSerializable(obj)
vector1_payload(const arraytype &inval, int dim1, ptrdiff_t stride)
This class is basically a wrapper for objects to declare the order in which their members should be s...
payload::const_ptr clone() const
Clone this object.
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
virtual payload::const_ptr bitwise_xor(const payload::const_ptr &other) const
Logical xor comparator.
vector1_payload(Type *inval, int dim1, bool cloning, ptrdiff_t stride)
#define spkt_throw_printf(exc, template_str,...)
virtual long byte_length() const
General errors, or base class for more specific errors.
virtual payload::const_ptr logical_xor(const payload::const_ptr &other) const
Logical xor comparator.
virtual payload::const_ptr bitwise_and(const payload::const_ptr &other) const
Logical and comparator.
A function was intentionally unimplemented because it doesn't make sense, or it is ongoing work...
const Type * typed_data() const
static const_ptr construct(const arraytype &inval, int dim1, ptrdiff_t stride=1)
vector1_payload< Type, VectorType > Vector1Payload