Code Examples

The manual contains a number of code examples to demonstrate both some particular features of the small matrix functions and how these functions can be called.

Many of these code examples output result data together with status code and associated messages in case when error condition was met.

To keep the example code simpler, special definitions of print statements are used for better representation of results, as well as print status codes and messages.

The code definitions given below make it possible to build the examples contained in the manual by straightforward copying and pasting the example code fragments.

Code Definitions  

/*
// The functions providing simple output of the result
// for single precision and double precision real data.
// These functions are only for tight data:
//   Stride2 = sizeof(dataType)
//   Srtide1 = width*sizeof(dataType)
//   Stride0 = length*sizeof(dataType) - for vector array
//   Stride0 = width*height*sizeof(dataType) - for matrix array
*/
 
#define genPRINT_m(TYPE) \
void printf_m_Ipp##TYPE(const 
char* msg, Ipp##TYPE* buf, \
                     int width, int height, IppStatus st ) \
{   int i, j; \
    if( st < ippStsNoErr ) { \
        printf( "-- error %d, %s\n", st, ippGetStatusString( st )); \
    } else { \
        printf("%s \n", msg ); \
        for( j=0; j <  height; j++) { \
		    for( i=0; i < width; i++) { \
	            printf("%f  ", buf[j*width+i]); } \
		    printf("\n"); } } \
}
 
#define genPRINT_ma(TYPE) \
void printf_ma_Ipp##TYPE(const char* msg, Ipp##TYPE## *buf, \
                     int width, int height, int count, IppStatus st ) \
{   int i, j, k; \
    if( st < ippStsNoErr ) { \
        printf( "-- error %d, %s\n", st, ippGetStatusString( st )); \
    } else { \
        printf("%s \n", msg ); \
        for( j=0; j <  height; j++) { \
		    for( k=0; k < count; k++) { \
                for( i=0; i < width; i++){ \
	             printf("%f ", buf[j*width+i+k*width*height]); \
		    } printf("    "); } printf("\n");}} \
}
 
#define genPRINT_m_L(TYPE) \
void printf_ma_Ipp##TYPE##_L(const 
char* msg, Ipp##TYPE** buf, \
                     int width, int height, int count, IppStatus st )\
{   int i, j, k; \
    Ipp##TYPE## *dst;  \
    if( st < ippStsNoErr ) { \
        printf( "-- error %d, %s\n", st, ippGetStatusString( st )); \
    } else { \
        printf("%s \n", msg ); \
        for( j=0; j <  height; j++) { \
		    for( k=0; k < count; k++) { \
		        dst = (Ipp##TYPE##*)buf[k]; \
                for( i=0; i < width; i++) { \
	                printf("%f ", dst[j*width+i]); } \
		    printf("    "); } printf("\n"); } } \
}
 
#define genPRINT_m_P(TYPE) \
void printf_m_Ipp##TYPE##_P(const char* msg, Ipp##TYPE** buf, \
                       int width, int height, IppStatus st ) \
{   int i, j; \
    if( st < ippStsNoErr ) { \
        printf( "-- error %d, %s\n", st, ippGetStatusString( st )); \
    } else { \
        printf("%s \n", msg ); \
        for( j=0; j <  height; j++) { \
            for( i=0; i < width; i++) { \
 	            printf("%f ", *buf[j*width+i]); } \
		    printf("\n"); } } \
}
 
#define genPRINT_va(TYPE) \
void printf_va_Ipp##TYPE(const char* msg, Ipp##TYPE* buf, \
                     int length, int count, IppStatus st ) \
{   int i, j; \
    if( st < ippStsNoErr ) { \
        printf( "-- error %d, %s\n", st, ippGetStatusString( st )); \
    } else { \
        printf("%s \n", msg ); \
        for( j=0; j <  count; j++) { \
		    for( i=0; i < length; i++) { \
	            printf("%f  ", buf[j*length+i]); } \
		    printf("\n"); } } \
}
 
void printf_v_int(const char* msg, int* buf, int length) \
{   int i; \
    printf("%s \n", msg ); \
    for( i=0; i < length; i++) \
	    printf("%d  ", buf[i]); \
    printf("\n"); \
}

genPRINT_va( 32f );
genPRINT_m( 32f );
genPRINT_ma( 32f );
genPRINT_m_P( 32f );
genPRINT_m_L( 32f );

genPRINT_va( 64f );
genPRINT_m( 64f );
genPRINT_ma( 64f );
genPRINT_m_P( 64f );
genPRINT_m_L( 64f );
 

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.