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::ArrayUtil_global_functions_concatenateArray Struct Reference

Concatenate two Arrays. More...

#include <ArrayUtil.h>

Public Member Functions

template<class T >
Array< T > concatenateArray (const Array< T > &left, const Array< T > &right)
 

Detailed Description

Concatenate two Arrays.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tArrayUtil

Prerequisite

Etymology

concatenateArray concatenates two Arrays into a new Array.

Synopsis

The function concatenates two Arrays into a new Array. The shape of both arrays must match except for the last dimension. The shape of the resulting array is equal to that of the input arrays with its last dimension as the sum of both last dimensions.

An exception ArrayConformanceError is thrown when the shapes do not match.

Motivation

The table system needed this function.

Example

Vector<Int> vector1(5);
Vector<Int> vector2(10);
indgen (vector1); // fill with values 0..4
indgen (vector2); // fill with values 0..9
Vector<Int> result = concatenateVector (vector1, vector2);

The example above results in a vector with length 15 and values 0,1,2,3,4,0,1,2,3,4,5,6,7,8,9.

It can also be used with matrices or arrays with higher dimensionality as long as all dimensions but the last one have equal length.

Matrix<Int> matrix1 (3,4);
Matrix<Int> matrix2 (3,5);
Matrix<Int> matrix3 (4,4);
// Concatenation of matrix1 and matrix 2 will succeed and result
// in a 3x9 matrix.
Matrix<Int> matrixConc = concatenateArray (matrix1, matrix2);
if (matrixConc.shape() != IPosition(2,3,9)) {
cout << "Error in shape of concatenated matrices" << endl;
}
// Concatenation of matrix1 and matrix3 will fail, because the
// first dimensions have a different length (3 vs. 4).
try {
concatenateArray (matrix1, matrix2);
} catch (ArrayConformanceError x) {
cout << x.getMesg() << endl;
}

Example

Definition at line 169 of file ArrayUtil.h.

Member Function Documentation

template<class T >
Array<T> casacore::ArrayUtil_global_functions_concatenateArray::concatenateArray ( const Array< T > &  left,
const Array< T > &  right 
)

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