Please enter what you're looking for to continue your search
 

vec_extract
ADD TO COMPARE ADDED TO COMPARE

 IBM-Z (64 bits)/ IBM-Z  View official documentation
Purpose:
Returns the value of element b from the vector a. This function uses the modulo arithmetic on b to determine the element number. For example, if b is out of range, the compiler uses b modulo the number of elements in the vector to determine the element position. Minimum Arch: Z11.

Prototypes

Usage:
signed long long result = vec_extract( vector signed long long a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector signed long long a = {
  100000LL, 200000LL
 };
 signed long long d = vec_extract(a, 1);
 printf("a: ");
 for (int i = 0; i < 2; i++)
  printf("%8lld ", a[i]);
  printf("\nd: %lld\n", d);

  return 0;
 }
Usage:
int result = vec_extract( vector signed int a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector signed int a = {
  1000, 2000, 3000, 4000
 };
 signed int d = vec_extract(a, 1);
 printf("a: ");
 for (int i = 0; i < 4; i++)
  printf("%8d ", a[i]);
  printf("\nd: %d\n", d);

  return 0;
 }
Usage:
unsigned long long result = vec_extract( vector bool long long a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned long long a_temp = {
  1ULL, 0ULL
 };
 vector bool long long a = (vector bool long long)a_temp;
 unsigned long long d = vec_extract(a, 0);
 printf("a: ");
 for (int i = 0; i < 2; i++)
  printf("%8lld ", ((vector signed long long)a)[i]);
  printf("\nd: %llu\n", d);

  return 0;
 }
Usage:
unsigned short result = vec_extract( vector unsigned short a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned short a = {
  100, 200, 300, 400, 500, 600, 700, 800
 };
 unsigned short d = vec_extract(a, 6);
 printf("a: ");
 for (int i = 0; i < 8; i++)
  printf("%5u ", a[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
unsigned int result = vec_extract( vector unsigned int a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned int a = {
  1000, 2000, 3000, 4000
 };
 unsigned int d = vec_extract(a, 3);
 printf("a: ");
 for (int i = 0; i < 4; i++)
  printf("%8u ", a[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
unsigned char result = vec_extract( vector bool char a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned char a_temp = {
  1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
 };
 vector bool char a = (vector bool char)a_temp;
 unsigned char d = vec_extract(a, 3);
 printf("a: ");
 for (int i = 0; i < 16; i++)
  printf("%3d ", ((vector signed char)a)[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
unsigned int result = vec_extract( vector bool int a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned int a_temp = {
  1, 0, 1, 0
 };
 vector bool int a = (vector bool int)a_temp;
 unsigned int d = vec_extract(a, 2);
 printf("a: ");
 for (int i = 0; i < 4; i++)
  printf("%8d ", ((vector signed int)a)[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
float result = vec_extract( vector float a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector float a = {
  1.5f, 2.7f, 3.14f, 4.2f
 };
 float d = vec_extract(a, 2);
 printf("a: ");
 for (int i = 0; i < 4; i++)
  printf("%8.2f ", a[i]);
  printf("\nd: %.2f\n", d);

  return 0;
 }
Usage:
signed char result = vec_extract( vector signed char a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector signed char a = {
  10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160
 };
 signed char d0 = vec_extract(a, 0);
 signed char d5 = vec_extract(a, 5);
 signed char d15 = vec_extract(a, 15);
 printf("a: ");
 for (int i = 0; i < 16; i++)
  printf("%3d ", a[i]);
  printf("\n");
  printf("vec_extract(a, 0):  %d\n", d0);
  printf("vec_extract(a, 5):  %d\n", d5);
  printf("vec_extract(a, 15): %d\n", d15);

  return 0;
 }
Usage:
unsigned short result = vec_extract( vector bool short a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned short a_temp = {
  1, 0, 1, 0, 1, 0, 1, 0
 };
 vector bool short a = (vector bool short)a_temp;
 unsigned short d = vec_extract(a, 2);
 printf("a: ");
 for (int i = 0; i < 8; i++)
  printf("%5d ", ((vector signed short)a)[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
double result = vec_extract( vector double a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector double a = {
  1.5, 2.7
 };
 double d = vec_extract(a, 1);
 printf("a: ");
 for (int i = 0; i < 2; i++)
  printf("%8.2f ", a[i]);
  printf("\nd: %.2f\n", d);

  return 0;
 }
Usage:
unsigned long long result = vec_extract( vector unsigned long long a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned long long a = {
  100000ULL, 200000ULL
 };
 unsigned long long d = vec_extract(a, 0);
 printf("a: ");
 for (int i = 0; i < 2; i++)
  printf("%8llu ", a[i]);
  printf("\nd: %llu\n", d);

  return 0;
 }
Usage:
unsigned char result = vec_extract( vector unsigned char a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector unsigned char a = {
  10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160
 };
 unsigned char d = vec_extract(a, 7);
 printf("a: ");
 for (int i = 0; i < 16; i++)
  printf("%3u ", a[i]);
  printf("\nd: %u\n", d);

  return 0;
 }
Usage:
signed short result = vec_extract( vector signed short a, int b )
Example:
#include <vecintrin.h>
#include <stdio.h>
int main() {
 vector signed short a = {
  100, 200, 300, 400, 500, 600, 700, 800
 };
 signed short d = vec_extract(a, 3);
 printf("a: ");
 for (int i = 0; i < 8; i++)
  printf("%5d ", a[i]);
  printf("\nd: %d\n", d);

  return 0;
 }
SIMD Intrinsics Summary
SIMD Engines: 6
C Intrinsics: 10444
NEON: 4353
AVX2: 405
AVX512: 4717
SSE4.2: 598
VSX: 192
IBM-Z: 179