casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions Struct Reference

Operations for 2 Arrays with possibly different shapes. More...

#include <ArrayOpsDiffShapes.h>

Public Member Functions

template<typename T >
LogicalArray reformedMask (const Array< T > &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 R , typename BinaryOperator >
void binOpExpandInPlace (Array< L > &left, const Array< R > &right, BinaryOperator op)
 Apply op elementwise to left and right, replicating elements of right as necessary (see example above). More...
 

Detailed Description

Operations for 2 Arrays with possibly different shapes.

Prerequisite

Etymology

This file contains global functions that attempt binary operations with arrays that have possibly differing shapes.

Synopsis

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.

Example

Array<Complex> a(10, 6);
Vector<Int> b(10);
Array<Complex> c(10, 6);
c = binOpExpandR(a, b, std::plus<Complex>());

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 86 of file ArrayOpsDiffShapes.h.

Member Function Documentation

template<typename L , typename R , typename BinaryOperator >
void casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions::binOpExpandInPlace ( Array< L > &  left,
const Array< R > &  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.

template<typename T >
LogicalArray casacore::ArrayOpsDiffShapes_global_functions_OpsDiff_functions::reformedMask ( const Array< T > &  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?


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