1 #ifndef DataFormat_Math_ExtVec_H 2 #define DataFormat_Math_ExtVec_H 7 #define VECTOR_EXT(N) __attribute__( ( ext_vector_type( N ) ) ) 9 #define VECTOR_EXT(N) __attribute__( ( vector_size( N ) ) ) 13 typedef
float VECTOR_EXT( 16 ) cms_float32x4_t;
14 typedef
float VECTOR_EXT( 32 ) cms_float32x8_t;
15 typedef
double VECTOR_EXT( 16 ) cms_float64x2_t;
16 typedef
double VECTOR_EXT( 32 ) cms_float64x4_t;
17 typedef
double VECTOR_EXT( 64 ) cms_float64x8_t;
19 typedef
long double VECTOR_EXT( 32 ) cms_float128x2_t;
20 typedef
long double VECTOR_EXT( 64 ) cms_float128x4_t;
21 typedef
long double VECTOR_EXT( 128 ) cms_float128x8_t;
81 template<
typename Vec,
typename F>
87 for (
int i=0;
i!=
N;++
i) ret[
i] =
f(v[
i]);
92 template<
typename Vec>
97 Vec x1200{ x[1], x[2], x[0], x[0] };
98 Vec y2010{ y[2], y[0], y[1], y[0] };
99 Vec x2010{ x[2], x[0], x[1], x[0] };
100 Vec y1200{ y[1], y[2], y[0], y[0] };
101 return x1200 * y2010 - x2010 * y1200;
104 template<
typename V1,
typename V2>
107 return x[0]*
y[1]-
x[1]*
y[0];
144 for (
int i=0;
i!=
N;++
i) ret+=
x[
i]*
y[
i];
148 template<
typename V1,
typename V2 >
153 for (
int i=0;
i!=2;++
i) ret+=
x[
i]*
y[
i];
194 axis{{(Vec){
T(1),0,0,0}},
203 axis{ {(Vec){
xx,
xy,
xz,0}},
209 return Rot3( axis[0][0], axis[1][0], axis[2][0],
210 axis[0][1], axis[1][1], axis[2][1],
211 axis[0][2], axis[1][2], axis[2][2]
227 return v[0]*axis[0] + v[1]*axis[1] + v[2]*axis[2];
236 return Rot3(rotateBack(r.
axis[0]),rotateBack(r.
axis[1]),rotateBack(r.
axis[2]));
258 axis{{(Vec){
T(1),0}},
271 return Rot2( axis[0][0], axis[1][0],
272 axis[0][1], axis[1][1]
287 return v[0]*axis[0] + v[1]*axis[1];
296 return Rot2(rotateBack(r.
axis[0]),rotateBack(r.
axis[1]));
317 std::ostream &
operator<<(std::ostream & out, Vec2F
const & v);
318 std::ostream &
operator<<(std::ostream & out, Vec4F
const & v);
319 std::ostream &
operator<<(std::ostream & out, Vec4D
const & v);
321 std::ostream & operator<<(std::ostream & out, As3D<Vec4F>
const &
v);
322 std::ostream & operator<<(std::ostream & out, As3D<Vec4D>
const &
v);
324 std::ostream &
operator<<(std::ostream & out, Rot3F
const & v);
325 std::ostream &
operator<<(std::ostream & out, Rot3D
const & v);
326 std::ostream &
operator<<(std::ostream & out, Rot2F
const & v);
327 std::ostream &
operator<<(std::ostream & out, Rot2D
const & v);
332 std::ostream &
operator<<(std::ostream & out, ::Vec4F
const & v) {
333 return out <<
'(' << v[0] <<
", " << v[1] <<
", "<< v[2] <<
", "<< v[3] <<
')';
335 std::ostream &
operator<<(std::ostream & out, ::Vec4D
const & v) {
336 return out <<
'(' << v[0] <<
", " << v[1] <<
", "<< v[2] <<
", "<< v[3] <<
')';
338 std::ostream &
operator<<(std::ostream & out, ::Vec2F
const & v) {
339 return out <<
'(' << v[0] <<
", " << v[1] <<
')';
341 std::ostream &
operator<<(std::ostream & out, ::Vec2D
const & v) {
342 return out <<
'(' << v[0] <<
", " << v[1] <<
')';
345 std::ostream & operator<<(std::ostream & out, ::As3D<Vec4F>
const &
v) {
346 return out <<
'(' << v.v[0] <<
", " << v.v[1] <<
", "<< v.v[2] <<
')';
349 std::ostream & operator<<(std::ostream & out, ::As3D<Vec4D>
const &
v) {
350 return out <<
'(' << v.v[0] <<
", " << v.v[1] <<
", "<< v.v[2] <<
')';
353 std::ostream &
operator<<(std::ostream & out, ::Rot3F
const &
r){
357 std::ostream &
operator<<(std::ostream & out, ::Rot3D
const & r){
361 std::ostream &
operator<<(std::ostream & out, ::Rot2F
const & r){
362 return out << r.
axis[0] <<
'\n' << r.
axis[1];
365 std::ostream &
operator<<(std::ostream & out, ::Rot2D
const & r){
366 return out << r.
axis[0] <<
'\n' << r.
axis[1];
constexpr Vec2< T > rotate(Vec2< T > v) const
auto cross2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type
constexpr Vec4< T > y() const
constexpr Rot2(T xx, T xy, T yx, T yy)
constexpr Rot2 rotateBack(Rot2 const &r) const
typename ExtVecTraits< T, N >::type ExtVec
auto xy(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
constexpr Rot3 rotateBack(Rot3 const &r) const
std::ostream & operator<<(std::ostream &out, Vec2D const &v)
constexpr Rot3 transpose() const
Rot2 rotate(Rot2 const &r) const
constexpr Vec4< T > x() const
def template(fileName, svg, replaceme="REPLACEME")
constexpr Vec4< T > z() const
Rot3 rotate(Rot3 const &r) const
constexpr Vec2< T > y() const
constexpr Vec2< T > x() const
constexpr Rot2 transpose() const
constexpr Rot3< T > operator*(Rot3< T > const &rh, Rot3< T > const &lh)
constexpr Rot3(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz)
constexpr Vec4< T > rotateBack(Vec4< T > v) const
constexpr Rot3(Vec4< T > ix, Vec4< T > iy, Vec4< T > iz)
constexpr Vec2< T > rotateBack(Vec2< T > v) const
auto dot(V x, V y) -> typename std::remove_reference< decltype(x[0])>::type
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
As3D< V > as3D(V const &v)
constexpr Vec4< T > rotate(Vec4< T > v) const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
auto dot2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type
constexpr Rot2(Vec2< T > ix, Vec2< T > iy)