# How to Implement the Intel® GPP Vector Module

### Challenge

Implement Intel® Graphics Performance Primitives (Intel® GPP) to provide basic vector operations. These include operations such as addition, subtraction, dot-product, cross-product, scaling, length, normalization, and transformation.

### Solution

Use the functions in the Intel GPP Vector Module. These functions operate on operands represented in Qm.n and Q16.16 format. This module uses two data structures: GPP_VEC3D and GPP_VEC4D.

GPP_VEC3D, used to store the geometric position of a three-dimensional vector, is defined as follows:

 ```typedef struct{ I32 x; I32 y; I32 z; } GPP_VEC3D; ```

GPP_VEC4D

 ```typedef struct{ I32 x; I32 y; I32 z; I32 w; } GPP_VEC4D; gppVec3DLength _n_32s(GPP_VEC3D* v, U32* pDst, U32 n); ```

GPP_VEC3DGPP_VEC3DQm.n

 ```v->x = 327680 ( 5.0000f) v->y = 327680 ( 5.0000f) v->z = 327680 ( 5.0000f) ```

Q16.16

 ```gppVec3DLength_16_32s(v1, &len1); *len1 = 567542 ```

Qm.nQ22.10

 ```v->x = 5120 ( 5.0000f) v->y = 5120 ( 5.0000f) v->z = 5120 ( 5.0000f) gppVec3DLength_n_32s(v1, &len2, 10); *len2 = 8864 FEM: 5.0000f, 5.0000f, 5.0000f = 8.6602 = 8.6602 Len_16: 327680, 327680 , 327680 = 567542 = 8.6600 Len_n(n=10): 5120, 5120, 5120 = 8864 = 8.6563 ```

Q22.10

GPP_MATRIX4X4

 ```GppStatus gppVec3DTransform_16_32s (GPP_VEC3D* sv, GPP_VEC4D* dv, GPP_MATRIX4X4 m); ```

 ```GppStatus gppVec3DTransform_n_32s (GPP_VEC3D* sv, GPP_VEC4D* dv GPP_MATRIX4X4 m, U32 n); ```

This item is part of a series about optimizing 3D graphics engines using Intel GPP; the series is introduced in the separate item "How to Optimize 3D Graphics on the Intel® XScale® Microarchitecture."

### Source

Intel® GPP for Intel® PCA Application Processors - Vector, Matrix and Raster Modules

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.