31 if ( x>=0&&y>=0 || x<=0&&y<=0)
48 template <
class FuncType,
int ytype>
50 FuncType opp,
bool swap)
52 typedef typename FuncType::result_type data_type;
55 (std::string(
"Unsupported data type in ")+
58 (std::string(
"Incompatible data types between ")+
63 (std::string(
"Numbers of components do not match between ")+
66 std::vector<Pane*> zpanes;
67 std::vector<const Pane*> xpanes, ypanes;
73 (std::string(
"Numbers of panes do not match between ")+
76 std::vector<Pane*>::iterator zit, zend;
77 std::vector<const Pane*>::const_iterator xit;
78 const Pane **yit=NULL;
81 const data_type *yval=NULL;
85 yval =
reinterpret_cast<const data_type *
>( yin);
87 y =
reinterpret_cast<const Attribute *
>(yin);
92 (std::string(
"Numbers of panes do not match between ")+
99 (std::string(
"Numbers of items do not match between ")+
102 yval =
reinterpret_cast<const data_type *
>( y->
pointer());
111 (std::string(
"Numbers of components do not match between ")+
114 for( zit=zpanes.begin(), zend=zpanes.end(), xit=xpanes.begin(); zit!=zend;
115 ++zit, ++xit, yit+=( ytype!=
BLAS_VOID && yit!=NULL)) {
118 int zstrd=get_stride<BLAS_VEC2D>(pz);
119 const bool zstg = num_dims!=zstrd;
122 int xstrd = get_stride<BLAS_VEC2D>(px);
124 (std::string(
"Numbers of items do not match between ")+
126 " on pane "+
to_str((*zit)->id())).c_str());
128 const bool xstg = num_dims!=xstrd || xstrd==0;
131 int ystrd = get_stride<ytype>(py);
134 (std::string(
"Numbers of items do not match between ")+
136 " on pane "+
to_str((*zit)->id())).c_str());
138 const bool ystg = py && (ynum_dims!=num_dims || ynum_dims!=ystrd);
141 if ( !xstg && !zstg && !ystg && ytype !=
BLAS_VEC
142 && (ytype !=
BLAS_SCNE || num_dims==1)) {
143 const data_type *xval = (
const data_type *)px->
pointer();
144 data_type *zval = (data_type *)pz->
pointer();
148 yval =
reinterpret_cast<const data_type *
>(py->
pointer());
152 for(
Size i = 0,
s = length*num_dims;
i<
s; ++
i, ++zval, ++xval)
153 *zval = opp( *xval, getref<data_type,ytype,0>(yval,
i,0,1));
155 for(
Size i = 0, s = length*num_dims;
i<
s; ++
i, ++zval, ++xval)
156 *zval = opp( getref<data_type,ytype,0>(yval,
i,0,1), *xval);
160 for(
int i = 0;
i < num_dims; ++
i) {
161 Attribute *pz_i = num_dims==1?pz:(*zit)->attribute(z->
id()+
i+1);
162 data_type *zval = (data_type *)pz_i->
pointer();
163 zstrd=get_stride<BLAS_VEC2D>(pz_i);
165 const Attribute *px_i = num_dims==1?px:(*xit)->attribute(x->
id()+
i+1);
166 const data_type *xval = (
const data_type *)px_i->
pointer();
167 xstrd=get_stride<BLAS_VEC2D>(px_i);
170 const Attribute *py_i=ynum_dims==1?py:(*yit)->attribute(y->
id()+
i+1);
171 yval =
reinterpret_cast<const data_type *
>( py_i->
pointer());
172 ystrd = get_stride<ytype>( py_i);
176 if ( swap ==
false) {
177 for(
int j = 0;
j <
length; ++
j, zval+=zstrd, xval+=xstrd)
178 *zval = opp( *xval, getref<data_type,ytype,1>(yval,
j,
i,ystrd));
181 for(
int j = 0;
j <
length; ++
j, zval+=zstrd, xval+=xstrd)
182 *zval = opp( getref<data_type,ytype,1>(yval,
j,
i,ystrd), *xval);
191 template <
class FuncType>
195 typedef typename FuncType::result_type data_type;
199 calc<FuncType,BLAS_SCALAR>(z, y, x, opp,
true);
201 calc<FuncType,BLAS_VEC>(
z,
y,
x, opp,
true);
205 calc<FuncType,BLAS_SCALAR>(z, x, y, opp,
false);
207 calc<FuncType,BLAS_VEC>(
z,
x,
y, opp,
false);
210 calc<FuncType,BLAS_SCNE>(
z,
y,
x, opp,
true);
214 calc<FuncType,BLAS_SCNE>(z, x, y, opp,
false);
216 calc<FuncType,BLAS_VEC2D>(
z,
x,
y, opp,
false);
229 (std::string(
"Unsupported data type in ")+
245 (std::string(
"Unsupported data type in ")+
261 (std::string(
"Unsupported data type in ")+
264 calcChoose(x, y, z, std::multiplies<double>());
277 (std::string(
"Unsupported data type in ")+
292 (std::string(
"Unsupported data type in ")+
305 calc<std::plus<int>,
BLAS_VOID>(
z,
x,
y, std::plus<int>(), swap);
308 (std::string(
"Unsupported data type in ")+
309 z->fullname()).c_str());
310 calc<std::plus<double>,BLAS_VOID>(
z,
x,
y, std::plus<double>(), swap);
324 (std::string(
"Unsupported data type in ")+
325 z->fullname()).c_str());
337 calc<std::minus<int>,
BLAS_VOID>(
z,
x,
y, std::minus<int>(), swap);
340 (std::string(
"Unsupported data type in ")+
341 z->fullname()).c_str());
342 calc<std::minus<double>,BLAS_VOID>(
z,
x,
y, std::minus<double>(), swap);
353 calc<std::multiplies<int>,
BLAS_VOID>(
z,
x,
y, std::multiplies<int>(), swap);
356 (std::string(
"Unsupported data type in ")+
357 z->fullname()).c_str());
358 calc<std::multiplies<double>,BLAS_VOID>(
z,
x,
y, std::multiplies<double>(), swap);
369 calc<std::divides<int>,
BLAS_VOID>(
z,
x,
y, std::divides<int>(), swap);
372 (std::string(
"Unsupported data type in ")+
373 z->fullname()).c_str());
374 calc<std::divides<double>,BLAS_VOID>(
z,
x,
y, std::divides<double>(), swap);
static void div_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for division with y as a scalar pointer.
static void sub(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for subtraction.
void swap(int &a, int &b)
int COM_Type
Indices for derived data types.
A Pane object contains a mesh, pane attribute, and field variables.
static void calc(Attribute *z, const Attribute *x, const void *yin, FuncType opp, bool swap=false)
Performs the operation: z = x op y.
An Attribute object is a data member of a window.
void int int REAL REAL * y
#define COM_assertion_msg(EX, msg)
bool is_windowed() const
Checks whether the attribute is associated with the window.
static void limit1(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for limit1.
const std::string & name() const
Obtain the window's name.
const Window * window() const
Obtain a constant pointer to the parent window of the attribute.
double length(Vector3D *const v, int n)
const void * pointer() const
Obtain a constant pointer to the physical address.
static void add(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for addition.
static void mul_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for multiplication with y as a scalar pointer.
void int int int REAL REAL REAL * z
int COM_compatible_types(COM_Type type1, COM_Type type2)
static void div(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for division.
static void calcChoose(const Attribute *x, const Attribute *y, Attribute *z, FuncType opp)
Chooses which calc function to call based on type of y.
Definition for Rocblas API.
static std::string to_str(int i)
COM_Type data_type() const
Obtain the data type of each component of the attribute.
int id() const
Obtain the id (or index) of the attribute.
static void maxof_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
void panes(std::vector< int > &ps, int rank=-2)
Obtain all the local panes of the window.
static void add_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
int size_of_items() const
Obtain the number of items in the attribute.
std::string fullname() const
Obtain the full name of the attribute including window name suitable for printing out error messages...
static void mul(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for multiplication.
int size_of_components() const
Obtain the number of components in the attribute.
static void sub_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for subtraction with y as a scalar pointer.