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

alibConcat
Concatenates some arrays along the leading dimension. The API here is aimed at vector concatenation, but depending on how the parameters are interpreted this same memory manipulation can represent concatenation of n-dimensional arrays along the leading dimension, e.g., vertical concatenation of matrices. The common uses for this routine are:
*Concatenates some vectors to form a bigger vector.
*Concatenates m (1,p) row-vectors to form a (m,p) matrix.
*Concatenates some (*,m) matrices to form a bigger (*,m) matrix.
*Concatenates m (1,p,q) matrices to form a (m,p,q) three-dimensional array.
*Concatenates some (*,n1,...,nj) arrays to form bigger (*,n1,...,nj) array.
The PV-WAVE API for this routine is the Array Concatenation Operators [ ].
Prototypes
void alibConcatb( wvlong m, wvlong *n, UCHAR **p, UCHAR *q )
void alibConcats( wvlong m, wvlong *n, short **p, short *q )
void alibConcati( wvlong m, wvlong *n, int **p, int *q )
void alibConcatl( wvlong m, wvlong *n, wvlong **p, wvlong *q )
void alibConcatf( wvlong m, wvlong *n, float **p, float *q )
void alibConcatd( wvlong m, wvlong *n, double **p, double *q )
void alibConcatc( wvlong m, wvlong *n, COMPLEX **p, COMPLEX *q )
void alibConcatz( wvlong m, wvlong *n, DCOMPLEX **p, DCOMPLEX *q )
Parameters
m — (Input) The number of arrays to be concatenated.
*n — (Input) The m-element array specifying a number of elements for each source array.
**p — (Input) The m-element array of pointers to the source arrays. The number of elements in array p[i] is n[i].
*q — (Input/Output) The destination array. On return, array q contains the concatenation of the m arrays p.
Example
The following examples show how the concatenation of one-dimensional arrays in memory can also represent the concatenation of n-dimensional arrays along the leading 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 */
   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 2-element row-vector b0" );
   alibPrintArrayb( 1, 1, 1, 2, b0, NULL);
   printf( "\n\n show 3-element row-vector b1" );
      alibPrintArrayb( 1, 1, 1, 3, b1, NULL);
   printf( "\n\n concatenate b0 and b1 to make 5-element row-vector b" );
      n[0] = 2;
      n[1] = 3;
      alibConcatb( 2, n, bi, b );
      alibPrintArrayb( 1, 1, 1, 5, b, NULL);
   printf( "\n\n show (3,4) array b0" );
      alibPrintArrayb( 1, 1, 3, 4, b0, NULL);
   printf( "\n\n show (2,4) array b1" );
      alibPrintArrayb( 1, 1, 2, 4, b1, NULL);
   printf( "\n\n show (1,4) row-vector b2" );
      alibPrintArrayb( 1, 1, 1, 4, b2, NULL);
   printf( "\n\n concatenate b0, b1, and b2 to make (6,4) array b" );
      n[0] = 12;
      n[1] = 8;
      n[2] = 4;
      alibConcatb( 3, n, bi, b );
      alibPrintArrayb( 1, 1, 6, 4, b, NULL);
   printf( "\n\n show (2,3,4) array b0" );
      alibPrintArrayb( 1, 2, 3, 4, b0, NULL);
   printf( "\n\n show (1,3,4) array b1" );
      alibPrintArrayb( 1, 1, 3, 4, b1, NULL);
   printf( "\n\n concatenate b0 and b1 to make (3,3,4) array b" );
      n[0] = 24;
      n[1] = 12;
      alibConcatb( 2, n, bi, b );
      alibPrintArrayb( 1, 3, 3, 4, b, NULL);
   printf( "\n\n show (2,3,4) array b0" );
      alibPrintArrayb( 1, 2, 3, 4, b0, NULL);
   printf( "\n\n show (2,3,4) array b1" );
      alibPrintArrayb( 1, 2, 3, 4, b1, NULL);
   printf( "\n\n concatenate 3d b0 and 3d b1 to make (2,2,3,4) 4d array b" );
      n[0] = 24;
      n[1] = 24;
      alibConcatb( 2, n, bi, b );
      alibPrintArrayb( 2, 2, 3, 4, b, NULL);
}
 
Output:
 
 show 2-element row-vector b0
 
   0   1
 
 show 3-element row-vector b1
 
 100 101 102
 
 concatenate b0 and b1 to make 5-element row-vector b
 
   0   1 100 101 102
 
 show (3,4) array b0
 
   0   1   2   3
   4   5   6   7
   8   9  10  11
 
 show (2,4) array b1
 
 100 101 102 103
 104 105 106 107
 
 show (1,4) row-vector b2
 
 200 201 202 203
 
 concatenate b0, b1, and b2 to make (6,4) array b
 
   0   1   2   3
   4   5   6   7
   8   9  10  11
 100 101 102 103
 104 105 106 107
 200 201 202 203
 
 show (2,3,4) 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 (1,3,4) array b1
 
 100 101 102 103
 104 105 106 107
 108 109 110 111
 
 concatenate b0 and b1 to make (3,3,4) array b
 
   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
 
 show (2,3,4) 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 (2,3,4) 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 3d b0 and 3d b1 to make (2,2,3,4) 4d array b
 
   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

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