RWalib C Array Library User Guide > Printing Utilities > alibPrintArray
  

alibPrintArray
Prints an (m,n,p,q) array. Arrays of less than four dimensions are handled with leading dimensions of length 1. Arrays of more than four dimensions can be handled by merging consecutive dimensions.
Prototypes
void alibPrintArrayb( wvlong m, wvlong n, wvlong p, wvlong q, UCHAR *a, char *f )
void alibPrintArrays( wvlong m, wvlong n, wvlong p, wvlong q, short *a, char *f )
void alibPrintArrayi( wvlong m, wvlong n, wvlong p, wvlong q, int *a, char *f )
void alibPrintArrayl( wvlong m, wvlong n, wvlong p, wvlong q, wvlong *a, char *f )
void alibPrintArrayf( wvlong m, wvlong n, wvlong p, wvlong q, float *a, char *f )
void alibPrintArrayd( wvlong m, wvlong n, wvlong p, wvlong q, double *a, char *f )
void alibPrintArrayc( wvlong m, wvlong n, wvlong p, wvlong q, COMPLEX *a, char *f )
void alibPrintArrayz( wvlong m, wvlong n, wvlong p, wvlong q, DCOMPLEX *a, char *f )
Parameters
m — (Input) A dimension of the array. For arrays of less than four dimensions, set m=1.
n — (Input) A dimension of the array. For arrays of less than three dimensions, set m=n=1.
p — (Input) A dimension of the array. For row vectors, set m=n=p=1.
q — (Input) A dimension of the array. For column vectors, set m=n=q=1.
*a — (Input) The array to be printed.
*f — (Input) If not NULL, defines a print format string for each number.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    UCHAR    b[24] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
                      20,21,22,23};
    printf( "\n\n print b like a row vector" );
    alibPrintArrayb( 1, 1, 1, 24, b, NULL );
    printf( "\n\n print b like a column vector" );
    alibPrintArrayb( 1, 1, 24, 1, b, NULL );
    printf( "\n\n print b like a (2,12) matrix" );
    alibPrintArrayb( 1, 1, 2, 12, b, NULL );
    printf( "\n\n print b like a (2,3,4) array" );
    alibPrintArrayb( 1, 2, 3, 4, b, NULL );
    printf( "\n\n print b like a (2,3,2,2) array" );
    alibPrintArrayb( 2, 3, 2, 2, b, NULL );
    printf( "\n\n print b like a (2,3,2,2) array and specify a format" );
    alibPrintArrayb( 2, 3, 2, 2, b, "%20d" );
}
 
Output:
 
 print b like a row vector 
 
   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23
 
 print b like a column vector 
 
   0
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23 
 
 print b like a (2,12) matrix
 
   0   1   2   3   4   5   6   7   8   9  10  11
  12  13  14  15  16  17  18  19  20  21  22  23
 
 print b like a (2,3,4) array
 
   0   1   2   3
   4   5   6   7
   8   9  10  11
 
  12  13  14  15
  16  17  18  19
  20  21  22  23
 
 print b like a (2,3,2,2) array
 
   0   1
   2   3
 
   4   5
   6   7
 
   8   9
  10  11
 
  12  13
  14  15
 
  16  17
  18  19
 
  20  21
  22  23
 
 
 print b like a (2,3,2,2) array and specify a format
 
                   0                   1
                   2                   3
 
                   4                   5
                   6                   7
 
                   8                   9
                  10                  11
 
                  12                  13
                  14                  15
 
                  16                  17
                  18                  19
 
                  20                  21
                  22                  23
 

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