casacore
|
Operations for 2 Arrays with possibly different shapes. More...
#include <ArrayOpsDiffShapes.h>
Public Member Functions | |
template<typename T , typename Alloc > | |
LogicalArray | reformedMask (const Array< T, Alloc > &data, const T truthvalue, const IPosition &desiredform) |
Returns a LogicalArray with elements (at pos) set to (data(pos) == truthvalue). More... | |
bool | rightExpandableToLeft (const IPosition &leftShape, const IPosition &rightShape) |
Can arrays left and right with respective shapes leftShape and rightShape be used in function(left, right,...) for the other functions declared here? More... | |
template<typename L , typename AllocL , typename R , typename AllocR , typename BinaryOperator > | |
void | binOpExpandInPlace (Array< L, AllocL > &left, const Array< R, AllocR > &right, BinaryOperator op) |
Apply op elementwise to left and right, replicating elements of right as necessary (see example above). More... | |
Operations for 2 Arrays with possibly different shapes.
This file contains global functions that attempt binary operations with arrays that have possibly differing shapes.
These functions perform operations on two arrays, left and right, which go chunk by chunk in left and element by element in right, as long as right spans a subspace of left. If left's shape has more dimensions than right's, each entry in right will effectively be replicated as necessary to act on each entry in the corresponding chunk of left. e.g. if left's shape is (256, 256, 1, 4), and right's is (256, 256), left(i, j, 1, l) will be operated on with right(i, j) for i & j from 0 to 255 and l from 0 to 3. Note that right must be either reformable to left's shape (same # of elements) or its shape must equal left's shape "as far as it goes", i.e. where right's dimensions are defined.
This example sets c(i, j) to a(i, j) + b(i). It checks that either b's shape can be reformed to a's (same # of elements) or that a's shape is the same as b's where b's dimensions are defined. The result of this operation is an Array.
Definition at line 82 of file ArrayOpsDiffShapes.h.
void casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions::binOpExpandInPlace | ( | Array< L, AllocL > & | left, |
const Array< R, AllocR > & | right, | ||
BinaryOperator | op | ||
) |
Apply op elementwise to left and right, replicating elements of right as necessary (see example above).
Throws an ArrayConformanceError exception if that cannot be done.
Currently assumes that it is the trailing axes of left that right will be replicated along. e.g. if left's shape is (1, 2, 4) and right's is (1, 2), the result will be left(i, j, k) op right(i, j) for all (i, j, k).
Like binOpExpandR(left, right, res, op), but work on left in place.
LogicalArray casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions::reformedMask | ( | const Array< T, Alloc > & | data, |
const T | truthvalue, | ||
const IPosition & | desiredform | ||
) |
Returns a LogicalArray with elements (at pos) set to (data(pos) == truthvalue).
data is effectively collapsed using anyEQ if necessary to fit desiredform. Throws an exception if that does not work.
bool casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions::rightExpandableToLeft | ( | const IPosition & | leftShape, |
const IPosition & | rightShape | ||
) |
Can arrays left and right with respective shapes leftShape and rightShape be used in function(left, right,...) for the other functions declared here?