Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <xmmintrin.h>
- #define MAX_DOTS 7
- #define N 3
- #define NS 8
- typedef union
- {
- float c[4];
- __v4sf vect;
- } dot __attribute__ ((aligned (16)));
- typedef struct
- {
- dot dots[MAX_DOTS];
- unsigned int dots_num;
- } set;
- union node_data
- {
- struct node *children[8];
- set dots;
- };
- struct node
- {
- unsigned int flags;
- dot bb_min;
- dot bb_max;
- union node_data data;
- };
- dot voxel = {{1.0, 1.0, 1.0, 0.0}};
- dot calc_avg (const dot *set, unsigned int n)
- {
- dot res;
- int i;
- __builtin_ia32_xorps (res.vect, res.vect);
- for (i=0; i<n; i++) res.vect += set[i].vect;
- res.vect /= (float)n;
- return res;
- }
- /*void calc_bounding_box (const dot *set, unsigned int n, dot *min, dot *max)
- {
- int i;
- min->vect = set[0].vect;
- max->vect = set[0].vect;
- for (i=1; i<n; i++)
- {
- min->vect = __buildin_ia32_minps (min->vect, set[i].vect);
- max->vect = __buildin_ia32_maxps (max->vect, set[i].vect);
- }
- }*/
- int main ()
- {
- dot res, min, max;
- dot set[2] = {{1.0,1.0, 2.0, 4.0}, {3.0, 2.0, 1.0, 10.0}};
- res = calc_avg (set, 2);
- // calc_bounding_box (set, 2, &min, &max);
- printf ("%f %f %f %f\n", res.c[0], res.c[1], res.c[2], res.c[3]);
- printf ("%f %f %f %f\n", min.c[0], min.c[1], min.c[2], min.c[3]);
- printf ("%f %f %f %f\n", max.c[0], max.c[1], max.c[2], max.c[3]);
- printf ("%i %i\n", sizeof(__m128),sizeof(__v4sf));
- printf ("%i\n", sizeof (struct node));
- }
Advertisement
Add Comment
Please, Sign In to add comment