alibInterleave
Concatenates some arrays along a trailing degenerate dimension, i.e., along a trailing dimension of length 1. The API is aimed at vector interleaving, but depending on how parameters are interpreted, this same memory manipulation can represent concatenation of n-dimensional arrays along a trailing degenerate dimension, e.g., horizontal concatenation of (n,1) column vectors. The common uses of this routine are:
Interleaves
m n-element vectors to make an
mn-element vector.
Concatenates
m (
n,1) column vectors to make an (
n,
m) matrix.
Concatenates
m (
n,
p,1) matrices to make an (
n,
p,
m) three-dimensional array.
Concatenates
m (
n1,...,
nj,1) arrays to make a (
n1,...,
nj,
m) array.
For concatenation of
n-dimensional arrays along the leading dimension, see
alibConcat. The PV-WAVE API for this routine is the
Array Concatenation Operators [ ].
Prototypes
void alibInterleaveb( wvlong m, wvlong n, UCHAR **p, UCHAR *q )
void alibInterleaves( wvlong m, wvlong n, short **p, short *q )
void alibInterleavei( wvlong m, wvlong n, int **p, int *q )
void alibInterleavel( wvlong m, wvlong n, wvlong **p, wvlong *q )
void alibInterleavef( wvlong m, wvlong n, float **p, float *q )
void alibInterleaved( wvlong m, wvlong n, double **p, double *q )
void alibInterleavec( wvlong m, wvlong n, COMPLEX **p, COMPLEX *q )
void alibInterleavez( wvlong m, wvlong n, DCOMPLEX **p, DCOMPLEX *q )
Parameters
m — (Input) The number of arrays to be interleaved (or concatenated depending on whether or not the operation is interpreted as multidimensional).
n — (Input) The number of elements in each source array.
**p — (Input) The m-element array of pointers to n-element source arrays.
*q — (Input/Output) The destination array. On return, array q contains the interleaving (or concatenation depending on interpretation) of the m n-element source arrays p.
Example
The following examples show how the interleaving of one-dimensional arrays in memory can represent the concatenation of n-dimensional arrays along a trailing degenerate dimension.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
/* make enough example input data to use for all the */
/* examples */
UCHAR *b, b0[32], b1[32], b2[32], *bi[3]={b0,b1,b2};
alibinit( NULL, NULL, NULL, NULL );
alibIndexb( 32, 0, 1, b0 );
alibIndexb( 32, 100, 1, b1 );
alibIndexb( 32, 200, 1, b2 );
/* make an output array big enough for all the examples */
b = (UCHAR*)malloc(128*sizeof(UCHAR));
printf( "\n\n show 4-element vectors b0, b1, and b2" );
alibPrintArrayb( 1, 1, 1, 4, b0, NULL);
alibPrintArrayb( 1, 1, 1, 4, b1, NULL);
alibPrintArrayb( 1, 1, 1, 4, b2, NULL);
printf( "\n\n interleave b0, b1, and b2 to make 12-element vector b" );
alibInterleaveb( 3, 4, bi, b );
alibPrintArrayb( 1, 1, 1, 12, b, NULL);
printf( "\n\n print b as (4,3) matrix to show that the interleaving \n" );
printf( " can be regarded as a side-by-side concatenation of 3 columns" );
alibPrintArrayb( 1, 1, 4, 3, b, NULL);
printf( "\n\n show (3,4) matrices b0 and b1" );
alibPrintArrayb( 1, 1, 3, 4, b0, NULL);
alibPrintArrayb( 1, 1, 3, 4, b1, NULL);
printf( "\n\n concatenate matrices b0 and b1 to make (3,4,2) 3d array" );
alibInterleaveb( 2, 12, bi, b );
alibPrintArrayb( 1, 3, 4, 2, b, NULL);
printf( "\n\n show (3,2,4) arrays b0 and b1" );
alibPrintArrayb( 1, 3, 2, 4, b0, NULL);
alibPrintArrayb( 1, 3, 2, 4, b1, NULL);
printf( "\n\n concatenate 3d arrays b0 and b1 into (3,2,4,2) 4d array b");
alibInterleaveb( 2, 24, bi, b );
alibPrintArrayb( 3, 2, 4, 2, b, NULL);
}
Output:
show 4-element vectors b0, b1, and b2
0 1 2 3
100 101 102 103
200 201 202 203
interleave b0, b1, and b2 to make 12-element vector b
0 100 200 1 101 201 2 102 202 3 103 203
print b as (4,3) matrix to show that the interleaving
can be regarded as a side-by-side concatenation of 3 columns
0 100 200
1 101 201
2 102 202
3 103 203
show (3,4) matrices b0 and b1
0 1 2 3
4 5 6 7
8 9 10 11
100 101 102 103
104 105 106 107
108 109 110 111
concatenate matrices b0 and b1 to make (3,4,2) 3d array
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
10 110
11 111
show (3,2,4) arrays b0 and b1
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
100 101 102 103
104 105 106 107
108 109 110 111
112 113 114 115
116 117 118 119
120 121 122 123
concatenate 3d arrays b0 and b1 into (3,2,4,2) 4d array b
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
10 110
11 111
12 112
13 113
14 114
15 115
16 116
17 117
18 118
19 119
20 120
21 121
22 122
23 123
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.