Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis12/src/include/Diderot/inline-vec6.h
ViewVC logotype

View of /branches/vis12/src/include/Diderot/inline-vec6.h

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2590 - (download) (as text) (annotate)
Thu Apr 17 19:26:31 2014 UTC (6 years, 5 months ago) by jhr
File size: 2125 byte(s)
  Resolved bug 023
/*! \file inline-vec6.h
 * \author John Reppy
 * \brief inline functions for 6-element vectors

 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.


#include "Diderot/types.h"

STATIC_INLINE Diderot_vec6_t vec6 (
    Diderot_real_t a, Diderot_real_t b, Diderot_real_t c,
    Diderot_real_t d, Diderot_real_t e, Diderot_real_t f)
  // Note that Diderot_vec6_t is represented as an 8-element vector
    return __extension__ (Diderot_vec6_t){ a, b, c, d, e, f, 0.0, 0.0 };

STATIC_INLINE Diderot_vec6_t loadVec6 (void *vp)
    Diderot_real_t *p = (Diderot_real_t *)vp;
    return vec6(p[0], p[1], p[2], p[3], p[4], p[5]);

STATIC_INLINE Diderot_vec6_t scale6 (Diderot_real_t s, Diderot_vec6_t v)
    return vec6(s, s, s, s, s, s) * v;

STATIC_INLINE Diderot_vec6_t clamp6 (Diderot_vec6_t lo, Diderot_vec6_t hi, Diderot_vec6_t v)
  // FIXME: there is probably a vectorized way to compute this
    Diderot_union6_t a, b, c;
    a.v = lo; b.v = hi; c.v = v;
    return vec6(
	clamp(a.r[0], b.r[0], c.r[0]),
	clamp(a.r[1], b.r[1], c.r[1]),
	clamp(a.r[2], b.r[2], c.r[2]),
	clamp(a.r[3], b.r[3], c.r[3]),
	clamp(a.r[4], b.r[4], c.r[4]),
	clamp(a.r[5], b.r[5], c.r[5]));

STATIC_INLINE Diderot_vec6_t lerp6 (Diderot_vec6_t a, Diderot_vec6_t b, Diderot_real_t t)
    return a + scale6(t, b - a);

STATIC_INLINE Diderot_vec6_t floor6 (Diderot_vec6_t v)
    Diderot_union6_t u;
    u.v = v;
    return vec6(FLOOR(u.r[0]), FLOOR(u.r[1]), FLOOR(u.r[2]), FLOOR(u.r[3]), FLOOR(u.r[4]), FLOOR(u.r[5]));

STATIC_INLINE Diderot_real_t dot6 (Diderot_vec6_t u, Diderot_vec6_t v)
    Diderot_union6_t uv = __extension__ (Diderot_union6_t)(u*v);
    return uv.r[0] + uv.r[1] + uv.r[2] + uv.r[3] + uv.r[4] + uv.r[5];

STATIC_INLINE Diderot_real_t length6 (Diderot_vec6_t v)
    return SQRT(dot6(v, v));

STATIC_INLINE Diderot_vec6_t normalize6 (Diderot_vec6_t v)
    return scale6(1.0 / length6(v), v);

#endif /* !_DIDEROT_INLINE_VEC6_H_ */

ViewVC Help
Powered by ViewVC 1.0.0