RWalib C Array Library User Guide > Concatenation and Tiling > alibConcatR
  

alibConcatR
Concatenates arrays along any dimension. The API here is aimed at horizontal concatenation of matrices, but depending on how parameters are interpreted, this same memory manipulation can represent concatenation of n-dimensional arrays along any dimension. Note though that for concatenation along the leading dimension or along a trailing degenerate dimension, it is computationally more efficient to use alibConcat or alibInterleave. The common uses of this routine are:
*Concatenates (k,*) matrices to make a bigger (k,*) matrix.
*Concatenates n-dimensional arrays along a middle dimension or the trailing dimension.
The PV-WAVE API for this routine is the Array Concatenation Operators [ ].
Prototypes
void alibConcatRb( wvlong k, wvlong m, wvlong *n, UCHAR **p, UCHAR *q )
void alibConcatRs( wvlong k, wvlong m, wvlong *n, short **p, short *q )
void alibConcatRi( wvlong k, wvlong m, wvlong *n, int **p, int *q )
void alibConcatRl( wvlong k, wvlong m, wvlong *n, wvlong **p, wvlong *q )
void alibConcatRf( wvlong k, wvlong m, wvlong *n, float **p, float *q )
void alibConcatRd( wvlong k, wvlong m, wvlong *n, double **p, double *q )
void alibConcatRc( wvlong k, wvlong m, wvlong *n, COMPLEX **p, COMPLEX *q )
void alibConcatRz( wvlong k, wvlong m, wvlong *n, DCOMPLEX **p, DCOMPLEX *q )
Parameters
k — (Input) The number of rows in the matrices to be concatenated, or for general n-dimensional concatenations, k equals the product of all dimensions preceding the dimension along which concatenation takes place.
m — (Input) The number of arrays to be concatenated.
*n — (Input) The m-element array where n[i] is the number of columns in the ith matrix to be concatenated, or for general n-dimensional concatenations, n[i] is the number of elements in the ith array divided by k.
**p — (Input) The m-element array of pointers to the source arrays. The number of elements in array p[i] is k*n[i].
*q — (Input/Output) The destination array. On return, array q contains the concatenation of the m source arrays p.
Example
The following examples show horizontal concatenation of matrices as well as concatenations along middle and trailing dimensions in higher-dimensional arrays.
#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 */
   wvlong n[3];
   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,2) matrix b0" );
      alibPrintArrayb( 1, 1, 4, 2, b0, NULL);
   printf( "\n\n show (4,1) matrix b1" );
      alibPrintArrayb( 1, 1, 4, 1, b1, NULL);
   printf( "\n\n show (4,3) matrix b2" );
      alibPrintArrayb( 1, 1, 4, 3, b2, NULL);
   printf( "\n\n concatenate b0, b1, and b2 into (4,6) matrix b" );
      n[0] = 2;
      n[1] = 1;
      n[2] = 3;
      alibConcatRb( 4, 3, n, bi, b );
      alibPrintArrayb( 1, 1, 4, 6, b, NULL);
   printf( "\n\n show (3,4,2) array b0" );
      alibPrintArrayb( 1, 3, 4, 2, b0, NULL);
   printf( "\n\n show (3,5,2) array b1" );
      alibPrintArrayb( 1, 3, 5, 2, b1, NULL);
   printf( "\n\n concatenate b0 and b1 into (3,9,2) array b" );
      n[0] = 8;
      n[1] = 10;
      alibConcatRb( 3, 2, n, bi, b );
      alibPrintArrayb( 1, 3, 9, 2, b, NULL);
   printf( "\n\n show (4,2,3) array b0" );
      alibPrintArrayb( 1, 4, 2, 3, b0, NULL);
   printf( "\n\n show (4,2,2) array b1" );
      alibPrintArrayb( 1, 4, 2, 2, b1, NULL);
   printf( "\n\n concatenate b0 and b1 into (4,2,5) array b" );
      n[0] = 3;
      n[1] = 2;
      alibConcatRb( 8, 2, n, bi, b );
      alibPrintArrayb( 1, 4, 2, 5, b, NULL);
   printf( "\n\n show (2,2,4,2) array b0" );
      alibPrintArrayb( 2, 2, 4, 2, b0, NULL);
   printf( "\n\n show (2,2,3,2) array b1" );
      alibPrintArrayb( 2, 2, 3, 2, b1, NULL);
   printf( "\n\n concatenate b0 and b1 into (2,2,7,2) array b" );
      n[0] = 8;
      n[1] = 6;
      alibConcatRb( 4, 2, n, bi, b );
      alibPrintArrayb( 2, 2, 7, 2, b, NULL);
}
 
Output:
 
 show (4,2) matrix b0
 
   0   1
   2   3
   4   5
   6   7
 
 show (4,1) matrix b1
 
 100
 101
 102
 103
 
 show (4,3) matrix b2
 
 200 201 202
 203 204 205
 206 207 208
 209 210 211
 
 concatenate b0, b1, and b2 into (4,6) matrix b
 
   0   1 100 200 201 202
   2   3 101 203 204 205
   4   5 102 206 207 208
   6   7 103 209 210 211
 
 show (3,4,2) array b0
 
   0   1
   2   3
   4   5
   6   7
 
   8   9
  10  11
  12  13
  14  15
 
  16  17
  18  19
  20  21
  22  23
 
 show (3,5,2) array b1
 
 100 101
 102 103
 104 105
 106 107
 108 109
 
 110 111
 112 113
 114 115
 116 117
 118 119
 
 120 121
 122 123
 124 125
 126 127
 128 129
 
 concatenate b0 and b1 into (3,9,2) array b
 
   0   1
   2   3
   4   5
   6   7
 100 101
 102 103
 104 105
 106 107
 108 109
 
   8   9
  10  11
  12  13
  14  15
 110 111
 112 113
 114 115
 116 117
 118 119
 
  16  17
  18  19
  20  21
  22  23
 120 121
 122 123
 124 125
 126 127
 128 129
 
 
 show (4,2,3) array b0
 
   0   1   2
   3   4   5
 
   6   7   8
   9  10  11
 
  12  13  14
  15  16  17
 
  18  19  20
  21  22  23
 
 show (4,2,2) array b1
 
 100 101
 102 103
 
 104 105
 106 107
 
 108 109
 110 111
 
 112 113
 114 115
 
 concatenate b0 and b1 into (4,2,5) array b
 
   0   1   2 100 101
   3   4   5 102 103
 
   6   7   8 104 105
   9  10  11 106 107
 
  12  13  14 108 109
  15  16  17 110 111
 
  18  19  20 112 113
  21  22  23 114 115
 
 show (2,2,4,2) array b0
 
   0   1
   2   3
   4   5
   6   7
 
   8   9
  10  11
  12  13
  14  15
 
  16  17
  18  19
  20  21
  22  23
 
  24  25
  26  27
  28  29
  30  31
 
 show (2,2,3,2) array b1
 
 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 b0 and b1 into (2,2,7,2) array b
 
   0   1
   2   3
   4   5
   6   7
 100 101
 102 103
 104 105
 
   8   9
  10  11
  12  13
  14  15
 106 107
 108 109
 110 111
 
  16  17
  18  19
  20  21
  22  23
 112 113
 114 115
 116 117
 
  24  25
  26  27
  28  29
  30  31
 118 119
 120 121
 122 123

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.