NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Math.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 #include "base/DLLImports.hpp"
30 
31 #include <math.h>
32 #include <vector_types.h>
33 #include <stdio.h>
34 
35 namespace FW
36 {
37 //------------------------------------------------------------------------
38 
39 FW_CUDA_FUNC F32 sqrt (F32 a) { return ::sqrtf(a); }
41 FW_CUDA_FUNC S32 abs (S32 a) { return (a >= 0) ? a : -a; }
42 FW_CUDA_FUNC S64 abs (S64 a) { return (a >= 0) ? a : -a; }
43 FW_CUDA_FUNC F32 abs (F32 a) { return ::fabsf(a); }
51 FW_CUDA_FUNC F32 asin (F32 a) { return ::asinf(a); }
53 FW_CUDA_FUNC F32 acos (F32 a) { return ::acosf(a); }
55 FW_CUDA_FUNC F32 atan (F32 a) { return ::atanf(a); }
58 FW_CUDA_FUNC F32 atan2 (F32 y, F32 x) { return ::atan2f(y, x); }
59 FW_CUDA_FUNC F32 floor (F32 a) { return ::floorf(a); }
61 FW_CUDA_FUNC F32 ceil (F32 a) { return ::ceilf(a); }
63 FW_CUDA_FUNC U64 doubleToBits (F64 a) { return *(U64*)&a; }
64 FW_CUDA_FUNC F64 bitsToDouble (U64 a) { return *(F64*)&a; }
65 
66 #if FW_CUDA
67 FW_CUDA_FUNC F32 pow (F32 a, F32 b) { return ::__powf(a, b); }
68 FW_CUDA_FUNC F32 exp (F32 a) { return ::__expf(a); }
69 FW_CUDA_FUNC F32 exp2 (F32 a) { return ::exp2f(a); }
71 FW_CUDA_FUNC F32 log (F32 a) { return ::__logf(a); }
72 FW_CUDA_FUNC F32 log2 (F32 a) { return ::__log2f(a); }
74 FW_CUDA_FUNC F32 sin (F32 a) { return ::__sinf(a); }
75 FW_CUDA_FUNC F32 cos (F32 a) { return ::__cosf(a); }
76 FW_CUDA_FUNC F32 tan (F32 a) { return ::__tanf(a); }
77 FW_CUDA_FUNC U32 floatToBits (F32 a) { return ::__float_as_int(a); }
78 FW_CUDA_FUNC F32 bitsToFloat (U32 a) { return ::__int_as_float(a); }
79 FW_CUDA_FUNC F32 exp2 (int a) { return ::exp2f((F32)a); }
80 FW_CUDA_FUNC F32 fastMin (F32 a, F32 b) { return ::fminf(a, b); }
81 FW_CUDA_FUNC F32 fastMax (F32 a, F32 b) { return ::fmaxf(a, b); }
82 FW_CUDA_FUNC F64 fastMin (F64 a, F64 b) { return ::fmin(a, b); }
83 FW_CUDA_FUNC F64 fastMax (F64 a, F64 b) { return ::fmax(a, b); }
84 #else
85 inline F32 pow (F32 a, F32 b) { return ::powf(a, b); }
86 inline F32 exp (F32 a) { return ::expf(a); }
87 inline F32 exp2 (F32 a) { return ::powf(2.0f, a); }
88 inline F64 exp2 (F64 a) { return ::pow(2.0, a); }
89 inline F32 log (F32 a) { return ::logf(a); }
90 inline F32 log2 (F32 a) { return ::logf(a) / ::logf(2.0f); }
91 inline F64 log2 (F64 a) { return ::log(a) / ::log(2.0); }
92 inline F32 sin (F32 a) { return ::sinf(a); }
93 inline F32 cos (F32 a) { return ::cosf(a); }
94 inline F32 tan (F32 a) { return ::tanf(a); }
95 inline U32 floatToBits (F32 a) { return *(U32*)&a; }
96 inline F32 bitsToFloat (U32 a) { return *(F32*)&a; }
97 inline F32 exp2 (int a) { return bitsToFloat(clamp(a + 127, 1, 254) << 23); }
98 inline F32 fastMin (F32 a, F32 b) { return (a + b - abs(a - b)) * 0.5f; }
99 inline F32 fastMax (F32 a, F32 b) { return (a + b + abs(a - b)) * 0.5f; }
100 inline F64 fastMin (F64 a, F64 b) { return (a + b - abs(a - b)) * 0.5f; }
101 inline F64 fastMax (F64 a, F64 b) { return (a + b + abs(a - b)) * 0.5f; }
102 #endif
103 
104 FW_CUDA_FUNC F32 scale (F32 a, int b) { return a * exp2(b); }
105 FW_CUDA_FUNC int popc8 (U32 mask);
109 
110 FW_CUDA_FUNC F32 fastClamp (F32 v, F32 lo, F32 hi) { return fastMin(fastMax(v, lo), hi); }
111 FW_CUDA_FUNC F64 fastClamp (F64 v, F64 lo, F64 hi) { return fastMin(fastMax(v, lo), hi); }
112 
113 template <class T> FW_CUDA_FUNC T sqr(const T& a) { return a * a; }
114 template <class T> FW_CUDA_FUNC T rcp(const T& a) { return (a) ? (T)1 / a : (T)0; }
115 template <class A, class B> FW_CUDA_FUNC A lerp(const A& a, const A& b, const B& t) { return (A)(a * ((B)1 - t) + b * t); }
116 
117 //------------------------------------------------------------------------
118 
119 template <class T, int L> class Vector;
120 
121 template <class T, int L, class S> class VectorBase
122 {
123 public:
125 
126  FW_CUDA_FUNC const T* getPtr (void) const { return ((S*)this)->getPtr(); }
127  FW_CUDA_FUNC T* getPtr (void) { return ((S*)this)->getPtr(); }
128  FW_CUDA_FUNC const T& get (int idx) const { FW_ASSERT(idx >= 0 && idx < L); return getPtr()[idx]; }
129  FW_CUDA_FUNC T& get (int idx) { FW_ASSERT(idx >= 0 && idx < L); return getPtr()[idx]; }
130  FW_CUDA_FUNC T set (int idx, const T& a) { T& slot = get(idx); T old = slot; slot = a; return old; }
131 
132  FW_CUDA_FUNC void set (const T& a) { T* tp = getPtr(); for (int i = 0; i < L; i++) tp[i] = a; }
133  FW_CUDA_FUNC void set (const T* ptr) { FW_ASSERT(ptr); T* tp = getPtr(); for (int i = 0; i < L; i++) tp[i] = ptr[i]; }
134  FW_CUDA_FUNC void setZero (void) { set((T)0); }
135 
136 #if !FW_CUDA
137  void print (void) const { const T* tp = getPtr(); for (int i = 0; i < L; i++) printf("%g\n", (F64)tp[i]); }
138  void sprint (char* vec, size_t s) const { int ctr = sprintf_s(vec, s, "( "); for (int i = 0; i < L-1; i++) ctr += sprintf_s(vec+ctr, s, "%.2f , ", (F64)get(i)); ctr += sprintf_s(vec+ctr, s, "%.2f )", (F64)get(L-1)); }
139 #endif
140 
141  FW_CUDA_FUNC bool isZero (void) const { const T* tp = getPtr(); for (int i = 0; i < L; i++) if (tp[i] != (T)0) return false; return true; }
142  FW_CUDA_FUNC T lenSqr (void) const { const T* tp = getPtr(); T r = (T)0; for (int i = 0; i < L; i++) r += sqr(tp[i]); return r; }
143  FW_CUDA_FUNC T length (void) const { return sqrt(lenSqr()); }
144  FW_CUDA_FUNC S normalized (T len = (T)1) const { return operator*(len * rcp(length())); }
145  FW_CUDA_FUNC void normalize (T len = (T)1) { set(normalized(len)); }
146  FW_CUDA_FUNC T min (void) const { const T* tp = getPtr(); T r = tp[0]; for (int i = 1; i < L; i++) r = FW::min(r, tp[i]); return r; }
147  FW_CUDA_FUNC T max (void) const { const T* tp = getPtr(); T r = tp[0]; for (int i = 1; i < L; i++) r = FW::max(r, tp[i]); return r; }
148  FW_CUDA_FUNC T sum (void) const { const T* tp = getPtr(); T r = tp[0]; for (int i = 1; i < L; i++) r += tp[i]; return r; }
149  FW_CUDA_FUNC S abs (void) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = FW::abs(tp[i]); return r; }
150 
151  FW_CUDA_FUNC Vector<T, L + 1> toHomogeneous(void) const { const T* tp = getPtr(); Vector<T, L + 1> r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i]; rp[L] = (T)1; return r; }
152  FW_CUDA_FUNC Vector<T, L - 1> toCartesian(void) const { const T* tp = getPtr(); Vector<T, L - 1> r; T* rp = r.getPtr(); T c = rcp(tp[L - 1]); for (int i = 0; i < L - 1; i++) rp[i] = tp[i] * c; return r; }
153 
154  FW_CUDA_FUNC const T& operator[] (int idx) const { return get(idx); }
155  FW_CUDA_FUNC T& operator[] (int idx) { return get(idx); }
156 
157  FW_CUDA_FUNC S& operator= (const T& a) { set(a); return *(S*)this; }
158  FW_CUDA_FUNC S& operator+= (const T& a) { set(operator+(a)); return *(S*)this; }
159  FW_CUDA_FUNC S& operator-= (const T& a) { set(operator-(a)); return *(S*)this; }
160  FW_CUDA_FUNC S& operator*= (const T& a) { set(operator*(a)); return *(S*)this; }
161  FW_CUDA_FUNC S& operator/= (const T& a) { set(operator/(a)); return *(S*)this; }
162  FW_CUDA_FUNC S& operator%= (const T& a) { set(operator%(a)); return *(S*)this; }
163  FW_CUDA_FUNC S& operator&= (const T& a) { set(operator&(a)); return *(S*)this; }
164  FW_CUDA_FUNC S& operator|= (const T& a) { set(operator|(a)); return *(S*)this; }
165  FW_CUDA_FUNC S& operator^= (const T& a) { set(operator^(a)); return *(S*)this; }
166  FW_CUDA_FUNC S& operator<<= (const T& a) { set(operator<<(a)); return *(S*)this; }
167  FW_CUDA_FUNC S& operator>>= (const T& a) { set(operator>>(a)); return *(S*)this; }
168 
169  FW_CUDA_FUNC S operator+ (void) const { return *this; }
170  FW_CUDA_FUNC S operator- (void) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = -tp[i]; return r; }
171  FW_CUDA_FUNC S operator~ (void) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = ~tp[i]; return r; }
172 
173  FW_CUDA_FUNC S operator+ (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] + a; return r; }
174  FW_CUDA_FUNC S operator- (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] - a; return r; }
175  FW_CUDA_FUNC S operator* (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] * a; return r; }
176  FW_CUDA_FUNC S operator/ (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] / a; return r; }
177  FW_CUDA_FUNC S operator% (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] % a; return r; }
178  FW_CUDA_FUNC S operator& (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] & a; return r; }
179  FW_CUDA_FUNC S operator| (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] | a; return r; }
180  FW_CUDA_FUNC S operator^ (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] ^ a; return r; }
181  FW_CUDA_FUNC S operator<< (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] << a; return r; }
182  FW_CUDA_FUNC S operator>> (const T& a) const { const T* tp = getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] >> a; return r; }
183 
184  template <class V> FW_CUDA_FUNC void set (const VectorBase<T, L, V>& v) { set(v.getPtr()); }
185  template <class V> FW_CUDA_FUNC T dot (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); T r = (T)0; for (int i = 0; i < L; i++) r += tp[i] * vp[i]; return r; }
186  template <class V> FW_CUDA_FUNC S min (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = FW::min(tp[i], vp[i]); return r; }
187  template <class V> FW_CUDA_FUNC S max (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = FW::max(tp[i], vp[i]); return r; }
188  template <class V, class W> FW_CUDA_FUNC S clamp (const VectorBase<T, L, V>& lo, const VectorBase<T, L, W>& hi) const { const T* tp = getPtr(); const T* lop = lo.getPtr(); const T* hip = hi.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = FW::clamp(tp[i], lop[i], hip[i]); return r; }
189 
190  template <class V> FW_CUDA_FUNC S& operator= (const VectorBase<T, L, V>& v) { set(v); return *(S*)this; }
191  template <class V> FW_CUDA_FUNC S& operator+= (const VectorBase<T, L, V>& v) { set(operator+(v)); return *(S*)this; }
192  template <class V> FW_CUDA_FUNC S& operator-= (const VectorBase<T, L, V>& v) { set(operator-(v)); return *(S*)this; }
193  template <class V> FW_CUDA_FUNC S& operator*= (const VectorBase<T, L, V>& v) { set(operator*(v)); return *(S*)this; }
194  template <class V> FW_CUDA_FUNC S& operator/= (const VectorBase<T, L, V>& v) { set(operator/(v)); return *(S*)this; }
195  template <class V> FW_CUDA_FUNC S& operator%= (const VectorBase<T, L, V>& v) { set(operator%(v)); return *(S*)this; }
196  template <class V> FW_CUDA_FUNC S& operator&= (const VectorBase<T, L, V>& v) { set(operator&(v)); return *(S*)this; }
197  template <class V> FW_CUDA_FUNC S& operator|= (const VectorBase<T, L, V>& v) { set(operator|(v)); return *(S*)this; }
198  template <class V> FW_CUDA_FUNC S& operator^= (const VectorBase<T, L, V>& v) { set(operator^(v)); return *(S*)this; }
199  template <class V> FW_CUDA_FUNC S& operator<<= (const VectorBase<T, L, V>& v) { set(operator<<(v)); return *(S*)this; }
200  template <class V> FW_CUDA_FUNC S& operator>>= (const VectorBase<T, L, V>& v) { set(operator>>(v)); return *(S*)this; }
201 
202  template <class V> FW_CUDA_FUNC S operator+ (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] + vp[i]; return r; }
203  template <class V> FW_CUDA_FUNC S operator- (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] - vp[i]; return r; }
204  template <class V> FW_CUDA_FUNC S operator* (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] * vp[i]; return r; }
205  template <class V> FW_CUDA_FUNC S operator/ (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] / vp[i]; return r; }
206  template <class V> FW_CUDA_FUNC S operator% (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] % vp[i]; return r; }
207  template <class V> FW_CUDA_FUNC S operator& (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] & vp[i]; return r; }
208  template <class V> FW_CUDA_FUNC S operator| (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] | vp[i]; return r; }
209  template <class V> FW_CUDA_FUNC S operator^ (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] ^ vp[i]; return r; }
210  template <class V> FW_CUDA_FUNC S operator<< (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] << vp[i]; return r; }
211  template <class V> FW_CUDA_FUNC S operator>> (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = tp[i] >> vp[i]; return r; }
212 
213  template <class V> FW_CUDA_FUNC bool operator== (const VectorBase<T, L, V>& v) const { const T* tp = getPtr(); const T* vp = v.getPtr(); for (int i = 0; i < L; i++) if (tp[i] != vp[i]) return false; return true; }
214  template <class V> FW_CUDA_FUNC bool operator!= (const VectorBase<T, L, V>& v) const { return (!operator==(v)); }
215 };
216 
217 //------------------------------------------------------------------------
218 
219 template <class T, int L> class Vector : public VectorBase<T, L, Vector<T, L> >
220 {
221 public:
223  FW_CUDA_FUNC Vector (T a) { set(a); }
224 
225  FW_CUDA_FUNC const T* getPtr (void) const { return m_values; }
226  FW_CUDA_FUNC T* getPtr (void) { return m_values; }
227  static FW_CUDA_FUNC Vector fromPtr (const T* ptr) { Vector v; v.set(ptr); return v; }
228 
229  template <class V> FW_CUDA_FUNC Vector(const VectorBase<T, L, V>& v) { set(v); }
230  template <class V> FW_CUDA_FUNC Vector& operator=(const VectorBase<T, L, V>& v) { set(v); return *this; }
231 
232 private:
233  T m_values[L];
234 };
235 
236 //------------------------------------------------------------------------
237 
238 class Vec2i : public VectorBase<S32, 2, Vec2i>, public int2
239 {
240 public:
241  FW_CUDA_FUNC Vec2i (void) { setZero(); }
242  FW_CUDA_FUNC Vec2i (S32 a) { set(a); }
243  FW_CUDA_FUNC Vec2i (S32 xx, S32 yy) { x = xx; y = yy; }
244 
245  FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
246  FW_CUDA_FUNC S32* getPtr (void) { return &x; }
247  static FW_CUDA_FUNC Vec2i fromPtr (const S32* ptr) { return Vec2i(ptr[0], ptr[1]); }
248 
249  FW_CUDA_FUNC Vec2i perpendicular(void) const { return Vec2i(-y, x); }
250 
251  template <class V> FW_CUDA_FUNC Vec2i(const VectorBase<S32, 2, V>& v) { set(v); }
252  template <class V> FW_CUDA_FUNC Vec2i& operator=(const VectorBase<S32, 2, V>& v) { set(v); return *this; }
253 };
254 
255 //------------------------------------------------------------------------
256 
257 class Vec3i : public VectorBase<S32, 3, Vec3i>, public int3
258 {
259 public:
260  FW_CUDA_FUNC Vec3i (void) { setZero(); }
261  FW_CUDA_FUNC Vec3i (S32 a) { set(a); }
262  FW_CUDA_FUNC Vec3i (S32 xx, S32 yy, S32 zz) { x = xx; y = yy; z = zz; }
263  FW_CUDA_FUNC Vec3i (const Vec2i& xy, S32 zz) { x = xy.x; y = xy.y; z = zz; }
264 
265  FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
266  FW_CUDA_FUNC S32* getPtr (void) { return &x; }
267  static FW_CUDA_FUNC Vec3i fromPtr (const S32* ptr) { return Vec3i(ptr[0], ptr[1], ptr[2]); }
268 
269  FW_CUDA_FUNC Vec2i getXY (void) const { return Vec2i(x, y); }
270 
271  template <class V> FW_CUDA_FUNC Vec3i(const VectorBase<S32, 3, V>& v) { set(v); }
272  template <class V> FW_CUDA_FUNC Vec3i& operator=(const VectorBase<S32, 3, V>& v) { set(v); return *this; }
273 };
274 
275 //------------------------------------------------------------------------
276 
277 class Vec4i : public VectorBase<S32, 4, Vec4i>, public int4
278 {
279 public:
280  FW_CUDA_FUNC Vec4i (void) { setZero(); }
281  FW_CUDA_FUNC Vec4i (S32 a) { set(a); }
282  FW_CUDA_FUNC Vec4i (S32 xx, S32 yy, S32 zz, S32 ww) { x = xx; y = yy; z = zz; w = ww; }
283  FW_CUDA_FUNC Vec4i (const Vec2i& xy, S32 zz, S32 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
284  FW_CUDA_FUNC Vec4i (const Vec3i& xyz, S32 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
285  FW_CUDA_FUNC Vec4i (const Vec2i& xy, const Vec2i& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
286 
287  FW_CUDA_FUNC const S32* getPtr (void) const { return &x; }
288  FW_CUDA_FUNC S32* getPtr (void) { return &x; }
289  static FW_CUDA_FUNC Vec4i fromPtr (const S32* ptr) { return Vec4i(ptr[0], ptr[1], ptr[2], ptr[3]); }
290 
291  FW_CUDA_FUNC Vec2i getXY (void) const { return Vec2i(x, y); }
292  FW_CUDA_FUNC Vec3i getXYZ (void) const { return Vec3i(x, y, z); }
293  FW_CUDA_FUNC Vec3i getXYW (void) const { return Vec3i(x, y, w); }
294 
295  template <class V> FW_CUDA_FUNC Vec4i(const VectorBase<S32, 4, V>& v) { set(v); }
296  template <class V> FW_CUDA_FUNC Vec4i& operator=(const VectorBase<S32, 4, V>& v) { set(v); return *this; }
297 };
298 
299 //------------------------------------------------------------------------
300 
301 class Vec2f : public VectorBase<F32, 2, Vec2f>, public float2
302 {
303 public:
304  FW_CUDA_FUNC Vec2f (void) { setZero(); }
305  FW_CUDA_FUNC Vec2f (F32 a) { set(a); }
306  FW_CUDA_FUNC Vec2f (F32 xx, F32 yy) { x = xx; y = yy; }
307  FW_CUDA_FUNC Vec2f (const Vec2i& v) { x = (F32)v.x; y = (F32)v.y; }
308 
309  FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
310  FW_CUDA_FUNC F32* getPtr (void) { return &x; }
311  static FW_CUDA_FUNC Vec2f fromPtr (const F32* ptr) { return Vec2f(ptr[0], ptr[1]); }
312 
313  FW_CUDA_FUNC operator Vec2i (void) const { return Vec2i((S32)x, (S32)y); }
314 
315  FW_CUDA_FUNC Vec2f perpendicular(void) const { return Vec2f(-y, x); }
316  FW_CUDA_FUNC F32 cross (const Vec2f& v) const { return x * v.y - y * v.x; }
317 
318  template <class V> FW_CUDA_FUNC Vec2f(const VectorBase<F32, 2, V>& v) { set(v); }
319  template <class V> FW_CUDA_FUNC Vec2f& operator=(const VectorBase<F32, 2, V>& v) { set(v); return *this; }
320 };
321 
322 //------------------------------------------------------------------------
323 
324 class Vec3f : public VectorBase<F32, 3, Vec3f>, public float3
325 {
326 public:
327  FW_CUDA_FUNC Vec3f (void) { setZero(); }
328  FW_CUDA_FUNC Vec3f (F32 a) { set(a); }
329  FW_CUDA_FUNC Vec3f (F32 xx, F32 yy, F32 zz) { x = xx; y = yy; z = zz; }
330  FW_CUDA_FUNC Vec3f (const Vec2f& xy, F32 zz) { x = xy.x; y = xy.y; z = zz; }
331  FW_CUDA_FUNC Vec3f (const Vec3i& v) { x = (F32)v.x; y = (F32)v.y; z = (F32)v.z; }
332 
333  FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
334  FW_CUDA_FUNC F32* getPtr (void) { return &x; }
335  static FW_CUDA_FUNC Vec3f fromPtr (const F32* ptr) { return Vec3f(ptr[0], ptr[1], ptr[2]); }
336 
337  FW_CUDA_FUNC operator Vec3i (void) const { return Vec3i((S32)x, (S32)y, (S32)z); }
338  FW_CUDA_FUNC Vec2f getXY (void) const { return Vec2f(x, y); }
339 
340  FW_CUDA_FUNC Vec3f cross (const Vec3f& v) const { return Vec3f(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }
341 
342  template <class V> FW_CUDA_FUNC Vec3f(const VectorBase<F32, 3, V>& v) { set(v); }
343  template <class V> FW_CUDA_FUNC Vec3f& operator=(const VectorBase<F32, 3, V>& v) { set(v); return *this; }
344 };
345 
346 //------------------------------------------------------------------------
347 
348 class Vec4f : public VectorBase<F32, 4, Vec4f>, public float4
349 {
350 public:
351  FW_CUDA_FUNC Vec4f (void) { setZero(); }
352  FW_CUDA_FUNC Vec4f (F32 a) { set(a); }
353  FW_CUDA_FUNC Vec4f (F32 xx, F32 yy, F32 zz, F32 ww) { x = xx; y = yy; z = zz; w = ww; }
354  FW_CUDA_FUNC Vec4f (const Vec2f& xy, F32 zz, F32 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
355  FW_CUDA_FUNC Vec4f (const Vec3f& xyz, F32 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
356  FW_CUDA_FUNC Vec4f (const Vec2f& xy, const Vec2f& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
357  FW_CUDA_FUNC Vec4f (const Vec4i& v) { x = (F32)v.x; y = (F32)v.y; z = (F32)v.z; w = (F32)v.w; }
358 
359  FW_CUDA_FUNC const F32* getPtr (void) const { return &x; }
360  FW_CUDA_FUNC F32* getPtr (void) { return &x; }
361  static FW_CUDA_FUNC Vec4f fromPtr (const F32* ptr) { return Vec4f(ptr[0], ptr[1], ptr[2], ptr[3]); }
362 
363  FW_CUDA_FUNC operator Vec4i (void) const { return Vec4i((S32)x, (S32)y, (S32)z, (S32)w); }
364  FW_CUDA_FUNC Vec2f getXY (void) const { return Vec2f(x, y); }
365  FW_CUDA_FUNC Vec3f getXYZ (void) const { return Vec3f(x, y, z); }
366  FW_CUDA_FUNC Vec3f getXYW (void) const { return Vec3f(x, y, w); }
367 
368 #if !FW_CUDA
369  static Vec4f fromABGR (U32 abgr);
370  U32 toABGR (void) const;
371 #endif
372 
373  template <class V> FW_CUDA_FUNC Vec4f(const VectorBase<F32, 4, V>& v) { set(v); }
374  template <class V> FW_CUDA_FUNC Vec4f& operator=(const VectorBase<F32, 4, V>& v) { set(v); return *this; }
375 };
376 
377 //------------------------------------------------------------------------
378 
379 class Vec2d : public VectorBase<F64, 2, Vec2d>, public double2
380 {
381 public:
382  FW_CUDA_FUNC Vec2d (void) { setZero(); }
383  FW_CUDA_FUNC Vec2d (F64 a) { set(a); }
384  FW_CUDA_FUNC Vec2d (F64 xx, F64 yy) { x = xx; y = yy; }
385  FW_CUDA_FUNC Vec2d (const Vec2i& v) { x = (F64)v.x; y = (F64)v.y; }
386  FW_CUDA_FUNC Vec2d (const Vec2f& v) { x = v.x; y = v.y; }
387 
388  FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
389  FW_CUDA_FUNC F64* getPtr (void) { return &x; }
390  static FW_CUDA_FUNC Vec2d fromPtr (const F64* ptr) { return Vec2d(ptr[0], ptr[1]); }
391 
392  FW_CUDA_FUNC operator Vec2i (void) const { return Vec2i((S32)x, (S32)y); }
393  FW_CUDA_FUNC operator Vec2f (void) const { return Vec2f((F32)x, (F32)y); }
394 
395  FW_CUDA_FUNC Vec2d perpendicular(void) const { return Vec2d(-y, x); }
396  FW_CUDA_FUNC F64 cross (const Vec2d& v) const { return x * v.y - y * v.x; }
397 
398  template <class V> FW_CUDA_FUNC Vec2d(const VectorBase<F64, 2, V>& v) { set(v); }
399  template <class V> FW_CUDA_FUNC Vec2d& operator=(const VectorBase<F64, 2, V>& v) { set(v); return *this; }
400 };
401 
402 //------------------------------------------------------------------------
403 
404 class Vec3d : public VectorBase<F64, 3, Vec3d>, public double3
405 {
406 public:
407  FW_CUDA_FUNC Vec3d (void) { setZero(); }
408  FW_CUDA_FUNC Vec3d (F64 a) { set(a); }
409  FW_CUDA_FUNC Vec3d (F64 xx, F64 yy, F64 zz) { x = xx; y = yy; z = zz; }
410  FW_CUDA_FUNC Vec3d (const Vec2d& xy, F64 zz) { x = xy.x; y = xy.y; z = zz; }
411  FW_CUDA_FUNC Vec3d (const Vec3i& v) { x = (F64)v.x; y = (F64)v.y; z = (F64)v.z; }
412  FW_CUDA_FUNC Vec3d (const Vec3f& v) { x = v.x; y = v.y; z = v.z; }
413 
414  FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
415  FW_CUDA_FUNC F64* getPtr (void) { return &x; }
416  static FW_CUDA_FUNC Vec3d fromPtr (const F64* ptr) { return Vec3d(ptr[0], ptr[1], ptr[2]); }
417 
418  FW_CUDA_FUNC operator Vec3i (void) const { return Vec3i((S32)x, (S32)y, (S32)z); }
419  FW_CUDA_FUNC operator Vec3f (void) const { return Vec3f((F32)x, (F32)y, (F32)z); }
420  FW_CUDA_FUNC Vec2d getXY (void) const { return Vec2d(x, y); }
421 
422  FW_CUDA_FUNC Vec3d cross (const Vec3d& v) const { return Vec3d(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }
423 
424  template <class V> FW_CUDA_FUNC Vec3d(const VectorBase<F64, 3, V>& v) { set(v); }
425  template <class V> FW_CUDA_FUNC Vec3d& operator=(const VectorBase<F64, 3, V>& v) { set(v); return *this; }
426 };
427 
428 //------------------------------------------------------------------------
429 
430 class Vec4d : public VectorBase<F64, 4, Vec4d>, public double4
431 {
432 public:
433  FW_CUDA_FUNC Vec4d (void) { setZero(); }
434  FW_CUDA_FUNC Vec4d (F64 a) { set(a); }
435  FW_CUDA_FUNC Vec4d (F64 xx, F64 yy, F64 zz, F64 ww) { x = xx; y = yy; z = zz; w = ww; }
436  FW_CUDA_FUNC Vec4d (const Vec2d& xy, F64 zz, F64 ww) { x = xy.x; y = xy.y; z = zz; w = ww; }
437  FW_CUDA_FUNC Vec4d (const Vec3d& xyz, F64 ww) { x = xyz.x; y = xyz.y; z = xyz.z; w = ww; }
438  FW_CUDA_FUNC Vec4d (const Vec2d& xy, const Vec2d& zw) { x = xy.x; y = xy.y; z = zw.x; w = zw.y; }
439  FW_CUDA_FUNC Vec4d (const Vec4i& v) { x = (F64)v.x; y = (F64)v.y; z = (F64)v.z; w = (F64)v.w; }
440  FW_CUDA_FUNC Vec4d (const Vec4f& v) { x = v.x; y = v.y; z = v.z; w = v.w; }
441 
442  FW_CUDA_FUNC const F64* getPtr (void) const { return &x; }
443  FW_CUDA_FUNC F64* getPtr (void) { return &x; }
444  static FW_CUDA_FUNC Vec4d fromPtr (const F64* ptr) { return Vec4d(ptr[0], ptr[1], ptr[2], ptr[3]); }
445 
446  FW_CUDA_FUNC operator Vec4i (void) const { return Vec4i((S32)x, (S32)y, (S32)z, (S32)w); }
447  FW_CUDA_FUNC operator Vec4f (void) const { return Vec4f((F32)x, (F32)y, (F32)z, (F32)w); }
448  FW_CUDA_FUNC Vec2d getXY (void) const { return Vec2d(x, y); }
449  FW_CUDA_FUNC Vec3d getXYZ (void) const { return Vec3d(x, y, z); }
450  FW_CUDA_FUNC Vec3d getXYW (void) const { return Vec3d(x, y, w); }
451 
452  template <class V> FW_CUDA_FUNC Vec4d(const VectorBase<F64, 4, V>& v) { set(v); }
453  template <class V> FW_CUDA_FUNC Vec4d& operator=(const VectorBase<F64, 4, V>& v) { set(v); return *this; }
454 };
455 
456 //------------------------------------------------------------------------
457 
458 template <class T, int L, class S> FW_CUDA_FUNC T lenSqr (const VectorBase<T, L, S>& v) { return v.lenSqr(); }
459 template <class T, int L, class S> FW_CUDA_FUNC T length (const VectorBase<T, L, S>& v) { return v.length(); }
460 template <class T, int L, class S> FW_CUDA_FUNC S normalize (const VectorBase<T, L, S>& v, T len = (T)1) { return v.normalized(len); }
461 template <class T, int L, class S> FW_CUDA_FUNC T min (const VectorBase<T, L, S>& v) { return v.min(); }
462 template <class T, int L, class S> FW_CUDA_FUNC T max (const VectorBase<T, L, S>& v) { return v.max(); }
463 template <class T, int L, class S> FW_CUDA_FUNC T sum (const VectorBase<T, L, S>& v) { return v.sum(); }
464 template <class T, int L, class S> FW_CUDA_FUNC S abs (const VectorBase<T, L, S>& v) { return v.abs(); }
465 
466 template <class T, int L, class S> FW_CUDA_FUNC S operator+ (const T& a, const VectorBase<T, L, S>& b) { return b + a; }
467 template <class T, int L, class S> FW_CUDA_FUNC S operator- (const T& a, const VectorBase<T, L, S>& b) { return -b + a; }
468 template <class T, int L, class S> FW_CUDA_FUNC S operator* (const T& a, const VectorBase<T, L, S>& b) { return b * a; }
469 template <class T, int L, class S> FW_CUDA_FUNC S operator/ (const T& a, const VectorBase<T, L, S>& b) { const T* bp = b.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = a / bp[i]; return r; }
470 template <class T, int L, class S> FW_CUDA_FUNC S operator% (const T& a, const VectorBase<T, L, S>& b) { const T* bp = b.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = a % bp[i]; return r; }
471 template <class T, int L, class S> FW_CUDA_FUNC S operator& (const T& a, const VectorBase<T, L, S>& b) { return b & a; }
472 template <class T, int L, class S> FW_CUDA_FUNC S operator| (const T& a, const VectorBase<T, L, S>& b) { return b | a; }
473 template <class T, int L, class S> FW_CUDA_FUNC S operator^ (const T& a, const VectorBase<T, L, S>& b) { return b ^ a; }
474 template <class T, int L, class S> FW_CUDA_FUNC S operator<< (const T& a, const VectorBase<T, L, S>& b) { const T* bp = b.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = a << bp[i]; return r; }
475 template <class T, int L, class S> FW_CUDA_FUNC S operator>> (const T& a, const VectorBase<T, L, S>& b) { const T* bp = b.getPtr(); S r; T* rp = r.getPtr(); for (int i = 0; i < L; i++) rp[i] = a >> bp[i]; return r; }
476 
477 template <class T, int L, class S, class V> FW_CUDA_FUNC T dot(const VectorBase<T, L, S>& a, const VectorBase<T, L, V>& b) { return a.dot(b); }
478 
481 FW_CUDA_FUNC F32 cross (const Vec2f& a, const Vec2f& b) { return a.cross(b); }
482 FW_CUDA_FUNC F64 cross (const Vec2d& a, const Vec2d& b) { return a.cross(b); }
483 FW_CUDA_FUNC Vec3f cross (const Vec3f& a, const Vec3f& b) { return a.cross(b); }
484 FW_CUDA_FUNC Vec3d cross (const Vec3d& a, const Vec3d& b) { return a.cross(b); }
485 
486 #define MINMAX(T) \
487  FW_CUDA_FUNC T min(const T& a, const T& b) { return a.min(b); } \
488  FW_CUDA_FUNC T min(T& a, T& b) { return a.min(b); } \
489  FW_CUDA_FUNC T max(const T& a, const T& b) { return a.max(b); } \
490  FW_CUDA_FUNC T max(T& a, T& b) { return a.max(b); } \
491  FW_CUDA_FUNC T min(const T& a, const T& b, const T& c) { return a.min(b).min(c); } \
492  FW_CUDA_FUNC T min(T& a, T& b, T& c) { return a.min(b).min(c); } \
493  FW_CUDA_FUNC T max(const T& a, const T& b, const T& c) { return a.max(b).max(c); } \
494  FW_CUDA_FUNC T max(T& a, T& b, T& c) { return a.max(b).max(c); } \
495  FW_CUDA_FUNC T min(const T& a, const T& b, const T& c, const T& d) { return a.min(b).min(c).min(d); } \
496  FW_CUDA_FUNC T min(T& a, T& b, T& c, T& d) { return a.min(b).min(c).min(d); } \
497  FW_CUDA_FUNC T max(const T& a, const T& b, const T& c, const T& d) { return a.max(b).max(c).max(d); } \
498  FW_CUDA_FUNC T max(T& a, T& b, T& c, T& d) { return a.max(b).max(c).max(d); } \
499  FW_CUDA_FUNC T clamp(const T& v, const T& lo, const T& hi) { return v.clamp(lo, hi); } \
500  FW_CUDA_FUNC T clamp(T& v, T& lo, T& hi) { return v.clamp(lo, hi); }
501 
502 MINMAX(Vec2i) MINMAX(Vec3i) MINMAX(Vec4i)
503 MINMAX(Vec2f) MINMAX(Vec3f) MINMAX(Vec4f)
504 MINMAX(Vec2d) MINMAX(Vec3d) MINMAX(Vec4d)
505 #undef MINMAX
506 
507 //------------------------------------------------------------------------
508 
509 template <class T, int L, class S> class MatrixBase
510 {
511 public:
513 
514  template <class V> static FW_CUDA_FUNC S translate (const VectorBase<T, L - 1, V>& v);
515  template <class V> static FW_CUDA_FUNC S scale (const VectorBase<T, L - 1, V>& v);
516  template <class V> static FW_CUDA_FUNC S scale (const VectorBase<T, L, V>& v);
517 
518  FW_CUDA_FUNC const T* getPtr (void) const { return ((S*)this)->getPtr(); }
519  FW_CUDA_FUNC T* getPtr (void) { return ((S*)this)->getPtr(); }
520  FW_CUDA_FUNC const T& get (int idx) const { FW_ASSERT(idx >= 0 && idx < L * L); return getPtr()[idx]; }
521  FW_CUDA_FUNC T& get (int idx) { FW_ASSERT(idx >= 0 && idx < L * L); return getPtr()[idx]; }
522  FW_CUDA_FUNC const T& get (int r, int c) const { FW_ASSERT(r >= 0 && r < L && c >= 0 && c < L); return getPtr()[r + c * L]; }
523  FW_CUDA_FUNC T& get (int r, int c) { FW_ASSERT(r >= 0 && r < L && c >= 0 && c < L); return getPtr()[r + c * L]; }
524  FW_CUDA_FUNC T set (int idx, const T& a) { T& slot = get(idx); T old = slot; slot = a; return old; }
525  FW_CUDA_FUNC T set (int r, int c, const T& a) { T& slot = get(r, c); T old = slot; slot = a; return old; }
526  FW_CUDA_FUNC const Vector<T, L>& col (int c) const { FW_ASSERT(c >= 0 && c < L); return *(const Vector<T, L>*)(getPtr() + c * L); }
527  FW_CUDA_FUNC Vector<T, L>& col (int c) { FW_ASSERT(c >= 0 && c < L); return *(Vector<T, L>*)(getPtr() + c * L); }
528  FW_CUDA_FUNC const Vector<T, L>& getCol (int c) const { return col(c); }
529  FW_CUDA_FUNC Vector<T, L> getRow (int r) const;
530 
531  FW_CUDA_FUNC void set (const T& a) { for (int i = 0; i < L * L; i++) get(i) = a; }
532  FW_CUDA_FUNC void set (const T* ptr) { FW_ASSERT(ptr); for (int i = 0; i < L * L; i++) get(i) = ptr[i]; }
533  FW_CUDA_FUNC void setZero (void) { set((T)0); }
534  FW_CUDA_FUNC void setIdentity (void) { setZero(); for (int i = 0; i < L; i++) get(i, i) = (T)1; }
535 
536 #if !FW_CUDA
537  void print (void) const;
538 #endif
539 
540  FW_CUDA_FUNC T det (void) const;
541  FW_CUDA_FUNC S transposed (void) const;
542  FW_CUDA_FUNC S inverted (void) const;
543  FW_CUDA_FUNC void transpose (void) { set(transposed()); }
544  FW_CUDA_FUNC void invert (void) { set(inverted()); }
545 
546  FW_CUDA_FUNC const T& operator() (int r, int c) const { return get(r, c); }
547  FW_CUDA_FUNC T& operator() (int r, int c) { return get(r, c); }
548 
549  FW_CUDA_FUNC S& operator= (const T& a) { set(a); return *(S*)this; }
550  FW_CUDA_FUNC S& operator+= (const T& a) { set(operator+(a)); return *(S*)this; }
551  FW_CUDA_FUNC S& operator-= (const T& a) { set(operator-(a)); return *(S*)this; }
552  FW_CUDA_FUNC S& operator*= (const T& a) { set(operator*(a)); return *(S*)this; }
553  FW_CUDA_FUNC S& operator/= (const T& a) { set(operator/(a)); return *(S*)this; }
554  FW_CUDA_FUNC S& operator%= (const T& a) { set(operator%(a)); return *(S*)this; }
555  FW_CUDA_FUNC S& operator&= (const T& a) { set(operator&(a)); return *(S*)this; }
556  FW_CUDA_FUNC S& operator|= (const T& a) { set(operator|(a)); return *(S*)this; }
557  FW_CUDA_FUNC S& operator^= (const T& a) { set(operator^(a)); return *(S*)this; }
558  FW_CUDA_FUNC S& operator<<= (const T& a) { set(operator<<(a)); return *(S*)this; }
559  FW_CUDA_FUNC S& operator>>= (const T& a) { set(operator>>(a)); return *(S*)this; }
560 
561  FW_CUDA_FUNC S operator+ (void) const { return *this; }
562  FW_CUDA_FUNC S operator- (void) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = -get(i); return r; }
563  FW_CUDA_FUNC S operator~ (void) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = ~get(i); return r; }
564 
565  FW_CUDA_FUNC S operator+ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) + a; return r; }
566  FW_CUDA_FUNC S operator- (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) - a; return r; }
567  FW_CUDA_FUNC S operator* (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) * a; return r; }
568  FW_CUDA_FUNC S operator/ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) / a; return r; }
569  FW_CUDA_FUNC S operator% (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) % a; return r; }
570  FW_CUDA_FUNC S operator& (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) & a; return r; }
571  FW_CUDA_FUNC S operator| (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) | a; return r; }
572  FW_CUDA_FUNC S operator^ (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) ^ a; return r; }
573  FW_CUDA_FUNC S operator<< (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) << a; return r; }
574  FW_CUDA_FUNC S operator>> (const T& a) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) >> a; return r; }
575 
576  template <class V> FW_CUDA_FUNC void setCol (int c, const VectorBase<T, L, V>& v) { col(c) = v; }
577  template <class V> FW_CUDA_FUNC void setRow (int r, const VectorBase<T, L, V>& v);
578  template <class V> FW_CUDA_FUNC void set (const MatrixBase<T, L, V>& v) { set(v.getPtr()); }
579 
580  template <class V> FW_CUDA_FUNC S& operator= (const MatrixBase<T, L, V>& v) { set(v); return *(S*)this; }
581  template <class V> FW_CUDA_FUNC S& operator+= (const MatrixBase<T, L, V>& v) { set(operator+(v)); return *(S*)this; }
582  template <class V> FW_CUDA_FUNC S& operator-= (const MatrixBase<T, L, V>& v) { set(operator-(v)); return *(S*)this; }
583  template <class V> FW_CUDA_FUNC S& operator*= (const MatrixBase<T, L, V>& v) { set(operator*(v)); return *(S*)this; }
584  template <class V> FW_CUDA_FUNC S& operator/= (const MatrixBase<T, L, V>& v) { set(operator/(v)); return *(S*)this; }
585  template <class V> FW_CUDA_FUNC S& operator%= (const MatrixBase<T, L, V>& v) { set(operator%(v)); return *(S*)this; }
586  template <class V> FW_CUDA_FUNC S& operator&= (const MatrixBase<T, L, V>& v) { set(operator&(v)); return *(S*)this; }
587  template <class V> FW_CUDA_FUNC S& operator|= (const MatrixBase<T, L, V>& v) { set(operator|(v)); return *(S*)this; }
588  template <class V> FW_CUDA_FUNC S& operator^= (const MatrixBase<T, L, V>& v) { set(operator^(v)); return *(S*)this; }
589  template <class V> FW_CUDA_FUNC S& operator<<= (const MatrixBase<T, L, V>& v) { set(operator<<(v)); return *(S*)this; }
590  template <class V> FW_CUDA_FUNC S& operator>>= (const MatrixBase<T, L, V>& v) { set(operator>>(v)); return *(S*)this; }
591 
592  template <class V> FW_CUDA_FUNC V operator* (const VectorBase<T, L, V>& v) const;
593  template <class V> FW_CUDA_FUNC V operator* (const VectorBase<T, L - 1, V>& v) const;
594 
595  template <class V> FW_CUDA_FUNC S operator+ (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) + v.get(i); return r; }
596  template <class V> FW_CUDA_FUNC S operator- (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) - v.get(i); return r; }
597  template <class V> FW_CUDA_FUNC S operator* (const MatrixBase<T, L, V>& v) const;
598  template <class V> FW_CUDA_FUNC S operator/ (const MatrixBase<T, L, V>& v) const { return operator*(v.inverted()); }
599  template <class V> FW_CUDA_FUNC S operator% (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) % v.get(i); return r; }
600  template <class V> FW_CUDA_FUNC S operator& (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) & v.get(i); return r; }
601  template <class V> FW_CUDA_FUNC S operator| (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) | v.get(i); return r; }
602  template <class V> FW_CUDA_FUNC S operator^ (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) ^ v.get(i); return r; }
603  template <class V> FW_CUDA_FUNC S operator<< (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) << v.get(i); return r; }
604  template <class V> FW_CUDA_FUNC S operator>> (const MatrixBase<T, L, V>& v) const { S r; for (int i = 0; i < L * L; i++) r.get(i) = get(i) >> v.get(i); return r; }
605 
606  template <class V> FW_CUDA_FUNC bool operator== (const MatrixBase<T, L, V>& v) const { for (int i = 0; i < L * L; i++) if (get(i) != v.get(i)) return false; return true; }
607  template <class V> FW_CUDA_FUNC bool operator!= (const MatrixBase<T, L, V>& v) const { return (!operator==(v)); }
608 };
609 
610 //------------------------------------------------------------------------
611 
612 template <class T, int L> class Matrix : public MatrixBase<T, L, Matrix<T, L> >
613 {
614 public:
616  FW_CUDA_FUNC explicit Matrix (T a) { set(a); }
617 
618  FW_CUDA_FUNC const T* getPtr (void) const { return m_values; }
619  FW_CUDA_FUNC T* getPtr (void) { return m_values; }
620  static FW_CUDA_FUNC Matrix fromPtr (const T* ptr) { Matrix v; v.set(ptr); return v; }
621 
622  template <class V> FW_CUDA_FUNC Matrix(const MatrixBase<T, L, V>& v) { set(v); }
623  template <class V> FW_CUDA_FUNC Matrix& operator=(const MatrixBase<T, L, V>& v) { set(v); return *this; }
624 
625 private:
626  T m_values[L * L];
627 };
628 
629 //------------------------------------------------------------------------
630 
631 class Mat2f : public MatrixBase<F32, 2, Mat2f>
632 {
633 public:
635  FW_CUDA_FUNC explicit Mat2f (F32 a) { set(a); }
636 
637  FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
638  FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
639  static FW_CUDA_FUNC Mat2f fromPtr (const F32* ptr) { Mat2f v; v.set(ptr); return v; }
640 
641  template <class V> FW_CUDA_FUNC Mat2f(const MatrixBase<F32, 2, V>& v) { set(v); }
642  template <class V> FW_CUDA_FUNC Mat2f& operator=(const MatrixBase<F32, 2, V>& v) { set(v); return *this; }
643 
644 public:
647 };
648 
649 //------------------------------------------------------------------------
650 
651 class Mat3f : public MatrixBase<F32, 3, Mat3f>
652 {
653 public:
655  FW_CUDA_FUNC explicit Mat3f (F32 a) { set(a); }
656 
657  FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
658  FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
659  static FW_CUDA_FUNC Mat3f fromPtr (const F32* ptr) { Mat3f v; v.set(ptr); return v; }
660 
661  template <class V> FW_CUDA_FUNC Mat3f(const MatrixBase<F32, 3, V>& v) { set(v); }
662  template <class V> FW_CUDA_FUNC Mat3f& operator=(const MatrixBase<F32, 3, V>& v) { set(v); return *this; }
663 
664 #if !FW_CUDA
665  static Mat3f rotation (const Vec3f& axis, F32 angle); // Rotation of "angle" radians around "axis". Axis must be unit!
666 #endif
667 
668 public:
672 };
673 
674 //------------------------------------------------------------------------
675 
676 class Mat4f : public MatrixBase<F32, 4, Mat4f>
677 {
678 public:
680  FW_CUDA_FUNC explicit Mat4f (F32 a) { set(a); }
681 
682  FW_CUDA_FUNC const F32* getPtr (void) const { return &m00; }
683  FW_CUDA_FUNC F32* getPtr (void) { return &m00; }
684  static FW_CUDA_FUNC Mat4f fromPtr (const F32* ptr) { Mat4f v; v.set(ptr); return v; }
685 
686 #if !FW_CUDA
687  Mat3f getXYZ (void) const;
688  static Mat4f fitToView (const Vec2f& pos, const Vec2f& size, const Vec2f& viewSize);
689  static Mat4f perspective (F32 fov, F32 nearDist, F32 farDist);
690 #endif
691 
692  template <class V> FW_CUDA_FUNC Mat4f(const MatrixBase<F32, 4, V>& v) { set(v); }
693  template <class V> FW_CUDA_FUNC Mat4f& operator=(const MatrixBase<F32, 4, V>& v) { set(v); return *this; }
694 
695 public:
700 };
701 
702 //------------------------------------------------------------------------
703 
704 class Mat2d : public MatrixBase<F64, 2, Mat2d>
705 {
706 public:
708  FW_CUDA_FUNC Mat2d (const Mat2f& a) { for (int i = 0; i < 2 * 2; i++) set(i, (F64)a.get(i)); }
709  FW_CUDA_FUNC explicit Mat2d (F64 a) { set(a); }
710 
711  FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
712  FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
713  static FW_CUDA_FUNC Mat2d fromPtr (const F64* ptr) { Mat2d v; v.set(ptr); return v; }
714 
715  FW_CUDA_FUNC operator Mat2f (void) const { Mat2f r; for (int i = 0; i < 2 * 2; i++) r.set(i, (F32)get(i)); return r; }
716 
717  template <class V> FW_CUDA_FUNC Mat2d(const MatrixBase<F64, 2, V>& v) { set(v); }
718  template <class V> FW_CUDA_FUNC Mat2d& operator=(const MatrixBase<F64, 2, V>& v) { set(v); return *this; }
719 
720 public:
723 };
724 
725 //------------------------------------------------------------------------
726 
727 class Mat3d : public MatrixBase<F64, 3, Mat3d>
728 {
729 public:
731  FW_CUDA_FUNC Mat3d (const Mat3f& a) { for (int i = 0; i < 3 * 3; i++) set(i, (F64)a.get(i)); }
732  FW_CUDA_FUNC explicit Mat3d (F64 a) { set(a); }
733 
734  FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
735  FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
736  static FW_CUDA_FUNC Mat3d fromPtr (const F64* ptr) { Mat3d v; v.set(ptr); return v; }
737 
738  FW_CUDA_FUNC operator Mat3f (void) const { Mat3f r; for (int i = 0; i < 3 * 3; i++) r.set(i, (F32)get(i)); return r; }
739 
740 #if !FW_CUDA
741  static Mat3d rotation (const Vec3d& axis, F64 angle); // Rotation of "angle" radians around "axis". Axis must be unit!
742 #endif
743 
744  template <class V> FW_CUDA_FUNC Mat3d(const MatrixBase<F64, 3, V>& v) { set(v); }
745  template <class V> FW_CUDA_FUNC Mat3d& operator=(const MatrixBase<F64, 3, V>& v) { set(v); return *this; }
746 
747 public:
751 };
752 
753 //------------------------------------------------------------------------
754 
755 class Mat4d : public MatrixBase<F64, 4, Mat4d>
756 {
757 public:
759  FW_CUDA_FUNC Mat4d (const Mat4f& a) { for (int i = 0; i < 4 * 4; i++) set(i, (F64)a.get(i)); }
760  FW_CUDA_FUNC explicit Mat4d (F64 a) { set(a); }
761 
762  FW_CUDA_FUNC const F64* getPtr (void) const { return &m00; }
763  FW_CUDA_FUNC F64* getPtr (void) { return &m00; }
764  static FW_CUDA_FUNC Mat4d fromPtr (const F64* ptr) { Mat4d v; v.set(ptr); return v; }
765 
766  FW_CUDA_FUNC operator Mat4f (void) const { Mat4f r; for (int i = 0; i < 4 * 4; i++) r.set(i, (F32)get(i)); return r; }
767 
768  template <class V> FW_CUDA_FUNC Mat4d(const MatrixBase<F64, 4, V>& v) { set(v); }
769  template <class V> FW_CUDA_FUNC Mat4d& operator=(const MatrixBase<F64, 4, V>& v) { set(v); return *this; }
770 
771 public:
776 };
777 
778 //------------------------------------------------------------------------
779 
780 template <class T, int L, class S> FW_CUDA_FUNC Matrix<T, L> outerProduct(const VectorBase<T, L, S>& a, const VectorBase<T, L, S>& b);
781 
782 template <class T, int L, class S> FW_CUDA_FUNC T det (const MatrixBase<T, L, S>& v) { return v.det(); }
783 template <class T, int L, class S> FW_CUDA_FUNC S transpose (const MatrixBase<T, L, S>& v) { return v.transposed(); }
784 template <class T, int L, class S> FW_CUDA_FUNC S invert (const MatrixBase<T, L, S>& v) { return v.inverted(); }
785 
786 template <class T, int L, class S> FW_CUDA_FUNC S operator+ (const T& a, const MatrixBase<T, L, S>& b) { return b + a; }
787 template <class T, int L, class S> FW_CUDA_FUNC S operator- (const T& a, const MatrixBase<T, L, S>& b) { return -b + a; }
788 template <class T, int L, class S> FW_CUDA_FUNC S operator* (const T& a, const MatrixBase<T, L, S>& b) { return b * a; }
789 template <class T, int L, class S> FW_CUDA_FUNC S operator/ (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a / b.get(i); return r; }
790 template <class T, int L, class S> FW_CUDA_FUNC S operator% (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a % b.get(i); return r; }
791 template <class T, int L, class S> FW_CUDA_FUNC S operator& (const T& a, const MatrixBase<T, L, S>& b) { return b & a; }
792 template <class T, int L, class S> FW_CUDA_FUNC S operator| (const T& a, const MatrixBase<T, L, S>& b) { return b | a; }
793 template <class T, int L, class S> FW_CUDA_FUNC S operator^ (const T& a, const MatrixBase<T, L, S>& b) { return b ^ a; }
794 template <class T, int L, class S> FW_CUDA_FUNC S operator<< (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a << b.get(i); return r; }
795 template <class T, int L, class S> FW_CUDA_FUNC S operator>> (const T& a, const MatrixBase<T, L, S>& b) { S r; for (int i = 0; i < L * L; i++) r.get(i) = a >> b.get(i); return r; }
796 
797 //------------------------------------------------------------------------
798 
800 {
801  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
802  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
803  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
804  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
805  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
806  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
807  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
808  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
809  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
810  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
811  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
812  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
813  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
814  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
815  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
816  4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
817 };
818 
820 {
821  return c_popc8LUT[mask & 0xFFu];
822 }
823 
825 {
826  return c_popc8LUT[mask & 0xFFu] + c_popc8LUT[(mask >> 8) & 0xFFu];
827 }
828 
830 {
831  int result = c_popc8LUT[mask & 0xFFu];
832  result += c_popc8LUT[(mask >> 8) & 0xFFu];
833  result += c_popc8LUT[(mask >> 16) & 0xFFu];
834  result += c_popc8LUT[mask >> 24];
835  return result;
836 }
837 
839 {
840  U32 lo = (U32)mask;
841  U32 hi = (U32)(mask >> 32);
842  int result = c_popc8LUT[lo & 0xffu] + c_popc8LUT[hi & 0xffu];
843  result += c_popc8LUT[(lo >> 8) & 0xffu] + c_popc8LUT[(hi >> 8) & 0xffu];
844  result += c_popc8LUT[(lo >> 16) & 0xffu] + c_popc8LUT[(hi >> 16) & 0xffu];
845  result += c_popc8LUT[lo >> 24] + c_popc8LUT[hi >> 24];
846  return result;
847 }
848 
849 //------------------------------------------------------------------------
850 
851 template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::translate(const VectorBase<T, L - 1, V>& v)
852 {
853  S r;
854  for (int i = 0; i < L - 1; i++)
855  r(i, L - 1) = v[i];
856  return r;
857 }
858 
859 //------------------------------------------------------------------------
860 
861 template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::scale(const VectorBase<T, L - 1, V>& v)
862 {
863  S r;
864  for (int i = 0; i < L - 1; i++)
865  r(i, i) = v[i];
866  return r;
867 }
868 
869 //------------------------------------------------------------------------
870 
871 template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::scale(const VectorBase<T, L, V>& v)
872 {
873  S r;
874  for (int i = 0; i < L; i++)
875  r(i, i) = v[i];
876  return r;
877 }
878 
879 //------------------------------------------------------------------------
880 
881 template <class T, int L, class S> Vector<T, L> MatrixBase<T, L, S>::getRow(int idx) const
882 {
883  Vector<T, L> r;
884  for (int i = 0; i < L; i++)
885  r[i] = get(idx, i);
886  return r;
887 }
888 
889 //------------------------------------------------------------------------
890 
891 #if !FW_CUDA
892 template <class T, int L, class S> void MatrixBase<T, L, S>::print(void) const
893 {
894  for (int i = 0; i < L; i++)
895  {
896  for (int j = 0; j < L; j++)
897  printf("%-16g", (F64)get(i, j));
898  printf("\n");
899  }
900 }
901 #endif
902 
903 //------------------------------------------------------------------------
904 
905 template <class T, int L, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, L, S>& v)
906 {
907  T r = (T)0;
908  T s = (T)1;
909  for (int i = 0; i < L; i++)
910  {
911  Matrix<T, L - 1> sub;
912  for (int j = 0; j < L - 1; j++)
913  for (int k = 0; k < L - 1; k++)
914  sub(j, k) = v((j < i) ? j : j + 1, k + 1);
915  r += sub.det() * v(i, 0) * s;
916  s = -s;
917  }
918  return r;
919 }
920 
921 //------------------------------------------------------------------------
922 
923 template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 1, S>& v)
924 {
925  return v(0, 0);
926 }
927 
928 //------------------------------------------------------------------------
929 
930 template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 2, S>& v)
931 {
932  return v(0, 0) * v(1, 1) - v(0, 1) * v(1, 0);
933 }
934 
935 //------------------------------------------------------------------------
936 
937 template <class T, class S> FW_CUDA_FUNC T detImpl(const MatrixBase<T, 3, S>& v)
938 {
939  return v(0, 0) * v(1, 1) * v(2, 2) - v(0, 0) * v(1, 2) * v(2, 1) +
940  v(1, 0) * v(2, 1) * v(0, 2) - v(1, 0) * v(2, 2) * v(0, 1) +
941  v(2, 0) * v(0, 1) * v(1, 2) - v(2, 0) * v(0, 2) * v(1, 1);
942 }
943 
944 //------------------------------------------------------------------------
945 
946 template <class T, int L, class S> T MatrixBase<T, L, S>::det(void) const
947 {
948  return detImpl(*this);
949 }
950 
951 //------------------------------------------------------------------------
952 
953 template <class T, int L, class S> S MatrixBase<T, L, S>::transposed(void) const
954 {
955  S r;
956  for (int i = 0; i < L; i++)
957  for (int j = 0; j < L; j++)
958  r(i, j) = get(j, i);
959  return r;
960 }
961 
962 //------------------------------------------------------------------------
963 
964 template <class T, int L, class S> S MatrixBase<T, L, S>::inverted(void) const
965 {
966  S r;
967  T d = (T)0;
968  T si = (T)1;
969  for (int i = 0; i < L; i++)
970  {
971  T sj = si;
972  for (int j = 0; j < L; j++)
973  {
974  Matrix<T, L - 1> sub;
975  for (int k = 0; k < L - 1; k++)
976  for (int l = 0; l < L - 1; l++)
977  sub(k, l) = get((k < j) ? k : k + 1, (l < i) ? l : l + 1);
978  T dd = sub.det() * sj;
979  r(i, j) = dd;
980  d += dd * get(j, i);
981  sj = -sj;
982  }
983  si = -si;
984  }
985  return r * rcp(d) * L;
986 }
987 
988 //------------------------------------------------------------------------
989 
990 template <class T, int L, class S> template <class V> void MatrixBase<T, L, S>::setRow(int idx, const VectorBase<T, L, V>& v)
991 {
992  for (int i = 0; i < L; i++)
993  get(idx, i) = v[i];
994 }
995 
996 //------------------------------------------------------------------------
997 
998 template <class T, int L, class S> template<class V> V MatrixBase<T, L, S>::operator*(const VectorBase<T, L, V>& v) const
999 {
1000  V r;
1001  for (int i = 0; i < L; i++)
1002  {
1003  T rr = (T)0;
1004  for (int j = 0; j < L; j++)
1005  rr += get(i, j) * v[j];
1006  r[i] = rr;
1007  }
1008  return r;
1009 }
1010 
1011 //------------------------------------------------------------------------
1012 
1013 template <class T, int L, class S> template<class V> V MatrixBase<T, L, S>::operator*(const VectorBase<T, L - 1, V>& v) const
1014 {
1015  T w = get(L - 1, L - 1);
1016  for (int i = 0; i < L - 1; i++)
1017  w += get(L - 1, i) * v[i];
1018  w = rcp(w);
1019 
1020  V r;
1021  for (int i = 0; i < L - 1; i++)
1022  {
1023  T rr = get(i, L - 1);
1024  for (int j = 0; j < L - 1; j++)
1025  rr += get(i, j) * v[j];
1026  r[i] = rr * w;
1027  }
1028  return r;
1029 }
1030 
1031 //------------------------------------------------------------------------
1032 
1033 template <class T, int L, class S> template <class V> S MatrixBase<T, L, S>::operator*(const MatrixBase<T, L, V>& v) const
1034 {
1035  S r;
1036  for (int i = 0; i < L; i++)
1037  {
1038  for (int j = 0; j < L; j++)
1039  {
1040  T rr = (T)0;
1041  for (int k = 0; k < L; k++)
1042  rr += get(i, k) * v(k, j);
1043  r(i, j) = rr;
1044  }
1045  }
1046  return r;
1047 }
1048 
1049 //------------------------------------------------------------------------
1050 
1051 template <class T, int L, class S> Matrix<T, L> outerProduct(const VectorBase<T, L, S>& a, const VectorBase<T, L, S>& b)
1052 {
1053  Matrix<T, L> res;
1054  for (int i = 0; i < L; i++)
1055  for (int j = 0; j < L; j++)
1056  res.get(i, j) = a.get(i) * b.get(j);
1057  return res;
1058 }
1059 
1060 //------------------------------------------------------------------------
1061 }
FW_CUDA_FUNC const T * getPtr(void) const
Definition: Math.hpp:518
F32 m20
Definition: Math.hpp:696
FW_CUDA_FUNC Vec4d(const Vec3d &xyz, F64 ww)
Definition: Math.hpp:437
F64 m20
Definition: Math.hpp:748
FW_CUDA_FUNC Vector(void)
Definition: Math.hpp:222
FW_CUDA_FUNC void set(const T *ptr)
Definition: Math.hpp:133
FW_CUDA_FUNC S operator+(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:466
FW_CUDA_FUNC void set(const VectorBase< T, L, V > &v)
Definition: Math.hpp:184
FW_CUDA_FUNC S operator&(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:471
FW_CUDA_FUNC Vec4d(const Vec4i &v)
Definition: Math.hpp:439
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei const GLvoid pointer GLuint GLuint const GLchar name GLenum GLsizei GLenum GLsizei GLsizei height GLenum GLuint renderbuffer GLenum GLenum GLint params GLuint GLsizei range GLuint GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLsizei GLsizei GLsizei const GLubyte GLsizei GLenum const GLvoid coords GLuint GLenum GLsizei const GLvoid pathString GLuint GLenum const GLvoid GLbitfield GLuint GLsizei GLenum GLuint GLfloat emScale GLuint GLuint srcPath GLuint GLuint GLenum const GLfloat transformValues GLuint GLenum GLint value GLuint GLenum GLfloat value GLenum GLint GLuint mask
Definition: DLLImports.inl:400
U32 floatToBits(F32 a)
Definition: Math.hpp:95
FW_CUDA_FUNC S operator<<(const T &a) const
Definition: Math.hpp:573
FW_CUDA_FUNC T * getPtr(void)
Definition: Math.hpp:519
FW_CUDA_FUNC Vec4d(const Vec2d &xy, F64 zz, F64 ww)
Definition: Math.hpp:436
FW_CUDA_FUNC void set(const T *ptr)
Definition: Math.hpp:532
FW_CUDA_FUNC T length(const VectorBase< T, L, S > &v)
Definition: Math.hpp:459
F64 m13
Definition: Math.hpp:775
FW_CUDA_FUNC Vec4d(const VectorBase< F64, 4, V > &v)
Definition: Math.hpp:452
FW_CUDA_FUNC void setRow(int r, const VectorBase< T, L, V > &v)
FW_CUDA_FUNC Vec3f(F32 a)
Definition: Math.hpp:328
FW_CUDA_FUNC Vec3i getXYZ(void) const
Definition: Math.hpp:292
FW_CUDA_FUNC Vec3i getXYW(void) const
Definition: Math.hpp:293
FW_CUDA_FUNC Vec2f getXY(void) const
Definition: Math.hpp:364
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:637
FW_CUDA_FUNC Vec3f & operator=(const VectorBase< F32, 3, V > &v)
Definition: Math.hpp:343
F32 m11
Definition: Math.hpp:670
FW_CUDA_FUNC S operator+(void) const
Definition: Math.hpp:561
FW_CUDA_FUNC Mat3d & operator=(const MatrixBase< F64, 3, V > &v)
Definition: Math.hpp:745
FW_CUDA_FUNC S abs(const VectorBase< T, L, S > &v)
Definition: Math.hpp:464
F64 m00
Definition: Math.hpp:748
FW_CUDA_FUNC int popc64(U64 mask)
Definition: Math.hpp:838
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:443
FW_CUDA_FUNC Mat4f(void)
Definition: Math.hpp:679
FW_CUDA_FUNC Mat2d(const MatrixBase< F64, 2, V > &v)
Definition: Math.hpp:717
FW_CUDA_FUNC Vec4i & operator=(const VectorBase< S32, 4, V > &v)
Definition: Math.hpp:296
static FW_CUDA_FUNC Mat3f fromPtr(const F32 *ptr)
Definition: Math.hpp:659
F64 m02
Definition: Math.hpp:750
FW_CUDA_FUNC Vec2i(void)
Definition: Math.hpp:241
FW_CUDA_FUNC Vec3i(const Vec2i &xy, S32 zz)
Definition: Math.hpp:263
FW_CUDA_FUNC Vec2f & operator=(const VectorBase< F32, 2, V > &v)
Definition: Math.hpp:319
F64 log2(F64 a)
Definition: Math.hpp:91
F64 m02
Definition: Math.hpp:774
F32 m32
Definition: Math.hpp:698
static FW_CUDA_FUNC Vec2f fromPtr(const F32 *ptr)
Definition: Math.hpp:311
FW_CUDA_FUNC F32 acos(F32 a)
Definition: Math.hpp:53
F32 m01
Definition: Math.hpp:697
F32 m21
Definition: Math.hpp:697
FW_CUDA_FUNC S & operator=(const T &a)
Definition: Math.hpp:157
FW_CUDA_FUNC F64 exp(F64 a)
Definition: Math.hpp:46
FW_CUDA_FUNC T set(int idx, const T &a)
Definition: Math.hpp:524
FW_CUDA_FUNC Mat3f(F32 a)
Definition: Math.hpp:655
FW_CUDA_FUNC S & operator>>=(const T &a)
Definition: Math.hpp:559
FW_CUDA_FUNC Vec2f(F32 a)
Definition: Math.hpp:305
F64 m00
Definition: Math.hpp:721
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:359
FW_CUDA_FUNC F64 atan2(F64 y, F64 x)
Definition: Math.hpp:57
FW_CUDA_FUNC Mat3f(void)
Definition: Math.hpp:654
FW_CUDA_FUNC T lenSqr(const VectorBase< T, L, S > &v)
Definition: Math.hpp:458
FW_CUDA_FUNC Matrix(void)
Definition: Math.hpp:615
FW_CUDA_FUNC Vec2d perpendicular(void) const
Definition: Math.hpp:395
FW_CUDA_FUNC F32 scale(F32 a, int b)
Definition: Math.hpp:104
FW_CUDA_FUNC Mat4d(const Mat4f &a)
Definition: Math.hpp:759
FW_CUDA_FUNC Vec2i(S32 xx, S32 yy)
Definition: Math.hpp:243
FW_CUDA_FUNC T max(void) const
Definition: Math.hpp:147
FW_CUDA_FUNC Vec3d(void)
Definition: Math.hpp:407
FW_CUDA_FUNC Vec4d(const Vec4f &v)
Definition: Math.hpp:440
FW_CUDA_FUNC Vec4i(const Vec2i &xy, const Vec2i &zw)
Definition: Math.hpp:285
FW_CUDA_FUNC Mat4d & operator=(const MatrixBase< F64, 4, V > &v)
Definition: Math.hpp:769
FW_CUDA_FUNC Mat2f(void)
Definition: Math.hpp:634
F32 fastMax(F32 a, F32 b)
Definition: Math.hpp:99
FW_CUDA_FUNC Vec3d getXYW(void) const
Definition: Math.hpp:450
F64 m01
Definition: Math.hpp:722
static FW_CUDA_FUNC Vec3i fromPtr(const S32 *ptr)
Definition: Math.hpp:267
void ** ptr
Definition: DLLImports.cpp:74
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:309
FW_CUDA_FUNC Vec3d(const VectorBase< F64, 3, V > &v)
Definition: Math.hpp:424
FW_CUDA_FUNC Vec2d(const Vec2i &v)
Definition: Math.hpp:385
FW_CUDA_FUNC Mat4f(F32 a)
Definition: Math.hpp:680
FW_CUDA_FUNC F64 cos(F64 a)
Definition: Math.hpp:49
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:442
FW_CUDA_FUNC Vec2d(const VectorBase< F64, 2, V > &v)
Definition: Math.hpp:398
F32 tan(F32 a)
Definition: Math.hpp:94
static FW_CUDA_FUNC Vec3d fromPtr(const F64 *ptr)
Definition: Math.hpp:416
FW_CUDA_FUNC T det(void) const
Definition: Math.hpp:946
FW_CUDA_FUNC F32 atan2(F32 y, F32 x)
Definition: Math.hpp:58
FW_CUDA_FUNC Vector< T, L > & col(int c)
Definition: Math.hpp:527
FW_CUDA_FUNC void transpose(void)
Definition: Math.hpp:543
FW_CUDA_FUNC Vector(T a)
Definition: Math.hpp:223
FW_CUDA_FUNC S operator>>(const T &a) const
Definition: Math.hpp:574
FW_CUDA_FUNC Vec2f perpendicular(const Vec2f &v)
Definition: Math.hpp:479
FW_CUDA_FUNC Vec2d(F64 a)
Definition: Math.hpp:383
FW_CUDA_FUNC void invert(void)
Definition: Math.hpp:544
FW_CUDA_FUNC F64 pow(F64 a, F64 b)
Definition: Math.hpp:45
FW_CUDA_FUNC Mat2d(const Mat2f &a)
Definition: Math.hpp:708
FW_CUDA_FUNC S & operator>>=(const T &a)
Definition: Math.hpp:167
FW_CUDA_FUNC bool operator==(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:213
FW_CUDA_FUNC S & operator^=(const T &a)
Definition: Math.hpp:557
FW_CUDA_FUNC T sqr(const T &a)
Definition: Math.hpp:113
FW_CUDA_FUNC const T * getPtr(void) const
Definition: Math.hpp:225
FW_CUDA_FUNC Mat2f(const MatrixBase< F32, 2, V > &v)
Definition: Math.hpp:641
unsigned __int64 U64
Definition: Defs.hpp:97
FW_CUDA_FUNC VectorBase(void)
Definition: Math.hpp:124
F32 m30
Definition: Math.hpp:696
int L
Definition: Math.hpp:509
double F64
Definition: Defs.hpp:90
U32 toABGR(void) const
Definition: Math.cpp:45
F32 m01
Definition: Math.hpp:646
FW_CUDA_FUNC Vec2d & operator=(const VectorBase< F64, 2, V > &v)
Definition: Math.hpp:399
F64 m30
Definition: Math.hpp:772
FW_CUDA_FUNC Vector< T, L-1 > toCartesian(void) const
Definition: Math.hpp:152
FW_CUDA_FUNC S & operator|=(const T &a)
Definition: Math.hpp:164
F32 m10
Definition: Math.hpp:696
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:735
FW_CUDA_FUNC Vec3f(const Vec3i &v)
Definition: Math.hpp:331
FW_CUDA_FUNC const S32 * getPtr(void) const
Definition: Math.hpp:245
static Mat3f rotation(const Vec3f &axis, F32 angle)
Definition: Math.cpp:96
FW_CUDA_FUNC MatrixBase(void)
Definition: Math.hpp:512
FW_CUDA_FUNC Vector< T, L+1 > toHomogeneous(void) const
Definition: Math.hpp:151
FW_CUDA_FUNC F32 floor(F32 a)
Definition: Math.hpp:59
static FW_CUDA_FUNC S scale(const VectorBase< T, L-1, V > &v)
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:711
FW_CUDA_FUNC F64 tan(F64 a)
Definition: Math.hpp:50
FW_CUDA_FUNC Vec3f getXYZ(void) const
Definition: Math.hpp:365
FW_CUDA_FUNC F32 sqrt(F32 a)
Definition: Math.hpp:39
FW_CUDA_FUNC Mat3d(const MatrixBase< F64, 3, V > &v)
Definition: Math.hpp:744
FW_CUDA_FUNC Mat3f(const MatrixBase< F32, 3, V > &v)
Definition: Math.hpp:661
FW_CUDA_FUNC F32 cross(const Vec2f &v) const
Definition: Math.hpp:316
F32 m10
Definition: Math.hpp:645
static FW_CUDA_FUNC Vec2d fromPtr(const F64 *ptr)
Definition: Math.hpp:390
FW_CUDA_FUNC bool operator==(const MatrixBase< T, L, V > &v) const
Definition: Math.hpp:606
#define FW_CUDA_FUNC
Definition: Defs.hpp:74
void sprint(char *vec, size_t s) const
Definition: Math.hpp:138
FW_CUDA_FUNC Mat2d(void)
Definition: Math.hpp:707
FW_CUDA_FUNC Mat2f & operator=(const MatrixBase< F32, 2, V > &v)
Definition: Math.hpp:642
FW_CUDA_FUNC T * getPtr(void)
Definition: Math.hpp:127
FW_CUDA_FUNC F64 cross(const Vec2d &v) const
Definition: Math.hpp:396
F64 m11
Definition: Math.hpp:749
FW_CUDA_FUNC Vec2f getXY(void) const
Definition: Math.hpp:338
FW_CUDA_FUNC F64 atan(F64 a)
Definition: Math.hpp:56
F64 m00
Definition: Math.hpp:772
F64 m23
Definition: Math.hpp:775
FW_CUDA_FUNC Mat3f & operator=(const MatrixBase< F32, 3, V > &v)
Definition: Math.hpp:662
FW_CUDA_FUNC const S32 * getPtr(void) const
Definition: Math.hpp:287
FW_CUDA_FUNC const T & operator()(int r, int c) const
Definition: Math.hpp:546
FW_CUDA_FUNC T lenSqr(void) const
Definition: Math.hpp:142
FW_CUDA_FUNC S clamp(const VectorBase< T, L, V > &lo, const VectorBase< T, L, W > &hi) const
Definition: Math.hpp:188
FW_CUDA_FUNC bool operator!=(const MatrixBase< T, L, V > &v) const
Definition: Math.hpp:607
FW_CUDA_FUNC Vec3d(F64 a)
Definition: Math.hpp:408
FW_CUDA_FUNC S & operator&=(const T &a)
Definition: Math.hpp:555
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:734
FW_CUDA_FUNC T dot(const VectorBase< T, L, S > &a, const VectorBase< T, L, V > &b)
Definition: Math.hpp:477
F64 m10
Definition: Math.hpp:721
FW_CUDA_FUNC F64 asin(F64 a)
Definition: Math.hpp:52
FW_CUDA_FUNC Vec2f perpendicular(void) const
Definition: Math.hpp:315
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat x
Definition: DLLImports.inl:363
FW_CUDA_FUNC void set(const MatrixBase< T, L, V > &v)
Definition: Math.hpp:578
FW_CUDA_FUNC Mat3d(void)
Definition: Math.hpp:730
FW_CUDA_FUNC Vec2i getXY(void) const
Definition: Math.hpp:269
F32 m22
Definition: Math.hpp:671
F32 m02
Definition: Math.hpp:698
void print(void) const
Definition: Math.hpp:892
FW_CUDA_FUNC Vec4i(const Vec2i &xy, S32 zz, S32 ww)
Definition: Math.hpp:283
FW_CUDA_FUNC Vec2d(F64 xx, F64 yy)
Definition: Math.hpp:384
F64 m22
Definition: Math.hpp:774
F64 m11
Definition: Math.hpp:722
FW_CUDA_FUNC Vec4d(void)
Definition: Math.hpp:433
FW_CUDA_FUNC S operator+(void) const
Definition: Math.hpp:169
FW_CUDA_FUNC void set(const T &a)
Definition: Math.hpp:531
FW_CUDA_FUNC Mat4d(F64 a)
Definition: Math.hpp:760
FW_CUDA_FUNC Vec2d getXY(void) const
Definition: Math.hpp:420
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:682
FW_CUDA_FUNC S abs(void) const
Definition: Math.hpp:149
F64 m22
Definition: Math.hpp:750
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z
Definition: DLLImports.inl:363
FW_CUDA_FUNC bool isZero(void) const
Definition: Math.hpp:141
FW_CUDA_FUNC const T & get(int idx) const
Definition: Math.hpp:128
FW_CUDA_FUNC Vec4f(const VectorBase< F32, 4, V > &v)
Definition: Math.hpp:373
FW_CUDA_FUNC S & operator*=(const T &a)
Definition: Math.hpp:160
F64 m12
Definition: Math.hpp:750
F32 sin(F32 a)
Definition: Math.hpp:92
FW_CUDA_FUNC Vec3i(S32 xx, S32 yy, S32 zz)
Definition: Math.hpp:262
F32 m23
Definition: Math.hpp:699
FW_CUDA_FUNC S operator%(const T &a) const
Definition: Math.hpp:177
FW_CUDA_FUNC S32 * getPtr(void)
Definition: Math.hpp:266
FW_CUDA_FUNC S operator~(void) const
Definition: Math.hpp:563
FW_CUDA_FUNC T dot(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:185
FW_CUDA_FUNC Mat3d(const Mat3f &a)
Definition: Math.hpp:731
FW_CUDA_FUNC T sum(const VectorBase< T, L, S > &v)
Definition: Math.hpp:463
FW_CUDA_FUNC int popc16(U32 mask)
Definition: Math.hpp:824
FW_CUDA_FUNC S operator/(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:469
float F32
Definition: Defs.hpp:89
FW_CUDA_FUNC Vector(const VectorBase< T, L, V > &v)
Definition: Math.hpp:229
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat y
Definition: DLLImports.inl:363
FW_CUDA_FUNC Vec3f(const Vec2f &xy, F32 zz)
Definition: Math.hpp:330
F32 m12
Definition: Math.hpp:698
FW_CUDA_FUNC S operator>>(const T &a) const
Definition: Math.hpp:182
FW_CUDA_FUNC S operator^(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:473
FW_CUDA_FUNC S max(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:187
FW_CUDA_FUNC Mat4d(void)
Definition: Math.hpp:758
FW_CUDA_FUNC Vec3i(S32 a)
Definition: Math.hpp:261
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:388
FW_CUDA_FUNC Mat4f & operator=(const MatrixBase< F32, 4, V > &v)
Definition: Math.hpp:693
static FW_CUDA_FUNC Mat3d fromPtr(const F64 *ptr)
Definition: Math.hpp:736
FW_CUDA_FUNC S operator^(const T &a) const
Definition: Math.hpp:572
static FW_CUDA_FUNC S translate(const VectorBase< T, L-1, V > &v)
FW_CUDA_FUNC Vec3f(const VectorBase< F32, 3, V > &v)
Definition: Math.hpp:342
FW_CUDA_FUNC S invert(const MatrixBase< T, L, S > &v)
Definition: Math.hpp:784
FW_CUDA_FUNC S min(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:186
F32 log2(F32 a)
Definition: Math.hpp:90
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
Definition: DLLImports.inl:329
F32 pow(F32 a, F32 b)
Definition: Math.hpp:85
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:763
FW_CUDA_FUNC Vec2i(const VectorBase< S32, 2, V > &v)
Definition: Math.hpp:251
FW_CUDA_FUNC Vec3f(F32 xx, F32 yy, F32 zz)
Definition: Math.hpp:329
F32 m02
Definition: Math.hpp:671
FW_CUDA_FUNC Vec4i(S32 a)
Definition: Math.hpp:281
FW_CUDA_FUNC Vec3d & operator=(const VectorBase< F64, 3, V > &v)
Definition: Math.hpp:425
FW_CUDA_FUNC S & operator=(const T &a)
Definition: Math.hpp:549
FW_CUDA_FUNC F64 bitsToDouble(U64 a)
Definition: Math.hpp:64
static FW_CUDA_FUNC Mat2f fromPtr(const F32 *ptr)
Definition: Math.hpp:639
FW_CUDA_FUNC const T * getPtr(void) const
Definition: Math.hpp:126
FW_CUDA_FUNC S operator/(const T &a) const
Definition: Math.hpp:176
FW_CUDA_FUNC S & operator<<=(const T &a)
Definition: Math.hpp:166
FW_CUDA_FUNC S32 * getPtr(void)
Definition: Math.hpp:288
static Mat4f perspective(F32 fov, F32 nearDist, F32 farDist)
Definition: Math.cpp:79
FW_CUDA_FUNC Vec4f(F32 xx, F32 yy, F32 zz, F32 ww)
Definition: Math.hpp:353
FW_CUDA_FUNC Vec3d(const Vec3f &v)
Definition: Math.hpp:412
F32 m22
Definition: Math.hpp:698
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Definition: Math.hpp:461
F64 m01
Definition: Math.hpp:773
FW_CUDA_FUNC S transposed(void) const
Definition: Math.hpp:953
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Definition: Math.hpp:462
FW_CUDA_FUNC Vec3d cross(const Vec3d &v) const
Definition: Math.hpp:422
FW_CUDA_FUNC Vec4f(F32 a)
Definition: Math.hpp:352
FW_CUDA_FUNC S & operator&=(const T &a)
Definition: Math.hpp:163
FW_CUDA_FUNC const T & get(int idx) const
Definition: Math.hpp:520
F64 m33
Definition: Math.hpp:775
FW_CUDA_FUNC S32 abs(S32 a)
Definition: Math.hpp:41
FW_CUDA_FUNC S operator*(const T &a) const
Definition: Math.hpp:567
FW_CUDA_FUNC S & operator<<=(const T &a)
Definition: Math.hpp:558
FW_CUDA_FUNC T set(int r, int c, const T &a)
Definition: Math.hpp:525
#define FW_ASSERT(X)
Definition: Defs.hpp:67
FW_CUDA_FUNC S & operator%=(const T &a)
Definition: Math.hpp:162
FW_CUDA_FUNC T * getPtr(void)
Definition: Math.hpp:226
FW_CUDA_FUNC F32 fastClamp(F32 v, F32 lo, F32 hi)
Definition: Math.hpp:110
FW_CUDA_FUNC Vec3f cross(const Vec3f &v) const
Definition: Math.hpp:340
signed int S32
Definition: Defs.hpp:88
static FW_CUDA_FUNC Vec4f fromPtr(const F32 *ptr)
Definition: Math.hpp:361
FW_CUDA_FUNC S & operator^=(const T &a)
Definition: Math.hpp:165
FW_CUDA_FUNC T set(int idx, const T &a)
Definition: Math.hpp:130
FW_CUDA_FUNC F32 asin(F32 a)
Definition: Math.hpp:51
MINMAX(Vec2i) MINMAX(Vec3i) MINMAX(Vec4i) MINMAX(Vec2f) MINMAX(Vec3f) MINMAX(Vec4f) MINMAX(Vec2d) MINMAX(Vec3d) MINMAX(Vec4d) template< class T
FW_CUDA_FUNC Vec4i(S32 xx, S32 yy, S32 zz, S32 ww)
Definition: Math.hpp:282
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:414
FW_CUDA_FUNC const S32 * getPtr(void) const
Definition: Math.hpp:265
FW_CUDA_FUNC Vec2i getXY(void) const
Definition: Math.hpp:291
FW_CUDA_FUNC S operator^(const T &a) const
Definition: Math.hpp:180
#define FW_CUDA_CONST
Definition: Defs.hpp:75
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:334
F64 m10
Definition: Math.hpp:748
FW_CUDA_FUNC void setZero(void)
Definition: Math.hpp:134
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:360
FW_CUDA_FUNC Vec4d(F64 xx, F64 yy, F64 zz, F64 ww)
Definition: Math.hpp:435
FW_CUDA_FUNC T * getPtr(void)
Definition: Math.hpp:619
F64 m03
Definition: Math.hpp:775
FW_CUDA_FUNC F64 acos(F64 a)
Definition: Math.hpp:54
FW_CUDA_FUNC Vec2f(const VectorBase< F32, 2, V > &v)
Definition: Math.hpp:318
F32 m03
Definition: Math.hpp:699
FW_CUDA_FUNC S inverted(void) const
Definition: Math.hpp:964
FW_CUDA_FUNC F32 ceil(F32 a)
Definition: Math.hpp:61
FW_CUDA_FUNC T rcp(const T &a)
Definition: Math.hpp:114
FW_CUDA_FUNC Vec2d(const Vec2f &v)
Definition: Math.hpp:386
static FW_CUDA_FUNC Mat4d fromPtr(const F64 *ptr)
Definition: Math.hpp:764
F64 m21
Definition: Math.hpp:749
FW_CUDA_FUNC const Vector< T, L > & col(int c) const
Definition: Math.hpp:526
CUdevice int ordinal char int len
Definition: DLLImports.inl:48
FW_CUDA_FUNC S32 * getPtr(void)
Definition: Math.hpp:246
static Mat4f fitToView(const Vec2f &pos, const Vec2f &size, const Vec2f &viewSize)
Definition: Math.cpp:66
FW_CUDA_FUNC Vec2f(void)
Definition: Math.hpp:304
F32 m31
Definition: Math.hpp:697
FW_CUDA_FUNC S & operator-=(const T &a)
Definition: Math.hpp:159
static FW_CUDA_FUNC Vec2i fromPtr(const S32 *ptr)
Definition: Math.hpp:247
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:333
FW_CUDA_FUNC S & operator+=(const T &a)
Definition: Math.hpp:158
FW_CUDA_FUNC Vec4f(const Vec4i &v)
Definition: Math.hpp:357
static FW_CUDA_FUNC Vec3f fromPtr(const F32 *ptr)
Definition: Math.hpp:335
FW_CUDA_FUNC U64 doubleToBits(F64 a)
Definition: Math.hpp:63
F32 m01
Definition: Math.hpp:670
F32 m11
Definition: Math.hpp:697
signed __int64 S64
Definition: Defs.hpp:98
FW_CUDA_FUNC int popc8(U32 mask)
Definition: Math.hpp:819
F32 exp2(F32 a)
Definition: Math.hpp:87
FW_CUDA_FUNC S & operator-=(const T &a)
Definition: Math.hpp:551
FW_CUDA_FUNC S operator<<(const T &a) const
Definition: Math.hpp:181
FW_CUDA_FUNC Vec4f(const Vec2f &xy, F32 zz, F32 ww)
Definition: Math.hpp:354
FW_CUDA_FUNC S & operator*=(const T &a)
Definition: Math.hpp:552
F32 exp(F32 a)
Definition: Math.hpp:86
FW_CUDA_FUNC const F32 * getPtr(void) const
Definition: Math.hpp:657
unsigned int U32
Definition: Defs.hpp:85
FW_CUDA_FUNC Vec4f(void)
Definition: Math.hpp:351
FW_CUDA_FUNC Mat4f(const MatrixBase< F32, 4, V > &v)
Definition: Math.hpp:692
FW_CUDA_FUNC Matrix(const MatrixBase< T, L, V > &v)
Definition: Math.hpp:622
F32 cos(F32 a)
Definition: Math.hpp:93
FW_CUDA_FUNC Matrix & operator=(const MatrixBase< T, L, V > &v)
Definition: Math.hpp:623
FW_CUDA_FUNC Vec4d(const Vec2d &xy, const Vec2d &zw)
Definition: Math.hpp:438
FW_CUDA_FUNC Vec2f(const Vec2i &v)
Definition: Math.hpp:307
F32 m20
Definition: Math.hpp:669
static FW_CUDA_FUNC Mat4f fromPtr(const F32 *ptr)
Definition: Math.hpp:684
FW_CUDA_FUNC S operator>>(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:475
FW_CUDA_FUNC S operator|(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:472
FW_CUDA_FUNC Vector< T, L > getRow(int r) const
Definition: Math.hpp:881
FW_CUDA_FUNC void setIdentity(void)
Definition: Math.hpp:534
FW_CUDA_FUNC int popc32(U32 mask)
Definition: Math.hpp:829
F64 m01
Definition: Math.hpp:749
FW_CUDA_FUNC Vec4i(void)
Definition: Math.hpp:280
FW_CUDA_FUNC S & operator+=(const T &a)
Definition: Math.hpp:550
FW_CUDA_FUNC void normalize(T len=(T) 1)
Definition: Math.hpp:145
FW_CUDA_FUNC S operator-(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:467
F64 m10
Definition: Math.hpp:772
F32 bitsToFloat(U32 a)
Definition: Math.hpp:96
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:389
F64 m20
Definition: Math.hpp:772
FW_CUDA_FUNC F32 cross(const Vec2f &a, const Vec2f &b)
Definition: Math.hpp:481
FW_CUDA_FUNC Vec2d getXY(void) const
Definition: Math.hpp:448
static FW_CUDA_FUNC Mat2d fromPtr(const F64 *ptr)
Definition: Math.hpp:713
FW_CUDA_FUNC Mat3d(F64 a)
Definition: Math.hpp:732
FW_CUDA_FUNC F64 sqrt(F64 a)
Definition: Math.hpp:40
F32 m21
Definition: Math.hpp:670
FW_CUDA_FUNC Mat2d & operator=(const MatrixBase< F64, 2, V > &v)
Definition: Math.hpp:718
FW_CUDA_FUNC Vec4f & operator=(const VectorBase< F32, 4, V > &v)
Definition: Math.hpp:374
FW_CUDA_FUNC Mat4d(const MatrixBase< F64, 4, V > &v)
Definition: Math.hpp:768
FW_CUDA_FUNC Vec2d(void)
Definition: Math.hpp:382
FW_CUDA_FUNC F64 floor(F64 a)
Definition: Math.hpp:60
FW_CUDA_FUNC Vec3d getXYZ(void) const
Definition: Math.hpp:449
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:415
void printf(const char *fmt,...)
Definition: Defs.cpp:225
F64 m32
Definition: Math.hpp:774
FW_CUDA_FUNC Vec2i(S32 a)
Definition: Math.hpp:242
FW_CUDA_FUNC S operator-(void) const
Definition: Math.hpp:170
FW_CUDA_FUNC S normalize(const VectorBase< T, L, S > &v, T len=(T) 1)
Definition: Math.hpp:460
F32 fastMin(F32 a, F32 b)
Definition: Math.hpp:98
FW_CUDA_FUNC F64 ceil(F64 a)
Definition: Math.hpp:62
FW_CUDA_FUNC const T * getPtr(void) const
Definition: Math.hpp:618
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:638
FW_CUDA_FUNC bool operator!=(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:214
FW_CUDA_FUNC T sum(void) const
Definition: Math.hpp:148
FW_CUDA_FUNC Mat2d(F64 a)
Definition: Math.hpp:709
FW_CUDA_FUNC F64 log(F64 a)
Definition: Math.hpp:47
FW_CUDA_FUNC const T & operator[](int idx) const
Definition: Math.hpp:154
FW_CUDA_FUNC const Vector< T, L > & getCol(int c) const
Definition: Math.hpp:528
FW_CUDA_FUNC S & operator/=(const T &a)
Definition: Math.hpp:161
FW_CUDA_FUNC Matrix< T, L > outerProduct(const VectorBase< T, L, S > &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:1051
static FW_CUDA_FUNC Vector fromPtr(const T *ptr)
Definition: Math.hpp:227
static Mat3d rotation(const Vec3d &axis, F64 angle)
Definition: Math.cpp:107
FW_CUDA_FUNC Vec2f(F32 xx, F32 yy)
Definition: Math.hpp:306
F32 m00
Definition: Math.hpp:645
FW_CUDA_FUNC Vec2i perpendicular(void) const
Definition: Math.hpp:249
FW_CUDA_FUNC Vec3f getXYW(void) const
Definition: Math.hpp:366
FW_CUDA_FUNC S normalized(T len=(T) 1) const
Definition: Math.hpp:144
FW_CUDA_FUNC Vec4i(const VectorBase< S32, 4, V > &v)
Definition: Math.hpp:295
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:310
F32 m13
Definition: Math.hpp:699
FW_CUDA_FUNC Vec3i(void)
Definition: Math.hpp:260
FW_CUDA_FUNC F32 atan(F32 a)
Definition: Math.hpp:55
FW_CUDA_FUNC void setZero(void)
Definition: Math.hpp:533
FW_CUDA_FUNC S operator&(const T &a) const
Definition: Math.hpp:178
static Vec4f fromABGR(U32 abgr)
Definition: Math.cpp:34
FW_CUDA_FUNC Mat2f(F32 a)
Definition: Math.hpp:635
FW_CUDA_FUNC F64 sin(F64 a)
Definition: Math.hpp:48
FW_CUDA_FUNC Vec3i(const VectorBase< S32, 3, V > &v)
Definition: Math.hpp:271
F32 exp2(int a)
Definition: Math.hpp:97
FW_CUDA_FUNC const F64 * getPtr(void) const
Definition: Math.hpp:762
FW_CUDA_FUNC S & operator/=(const T &a)
Definition: Math.hpp:553
FW_CUDA_FUNC Vec4f(const Vec2f &xy, const Vec2f &zw)
Definition: Math.hpp:356
FW_CUDA_FUNC Vec4f(const Vec3f &xyz, F32 ww)
Definition: Math.hpp:355
FW_CUDA_FUNC Vec3d(const Vec2d &xy, F64 zz)
Definition: Math.hpp:410
FW_CUDA_FUNC T det(const MatrixBase< T, L, S > &v)
Definition: Math.hpp:782
FW_CUDA_FUNC S transpose(const MatrixBase< T, L, S > &v)
Definition: Math.hpp:783
FW_CUDA_FUNC Vec3d(F64 xx, F64 yy, F64 zz)
Definition: Math.hpp:409
FW_CUDA_FUNC Vec4d & operator=(const VectorBase< F64, 4, V > &v)
Definition: Math.hpp:453
FW_CUDA_FUNC S operator%(const T &a) const
Definition: Math.hpp:569
void print(void) const
Definition: Math.hpp:137
FW_CUDA_FUNC Vec4i(const Vec3i &xyz, S32 ww)
Definition: Math.hpp:284
FW_CUDA_FUNC S operator~(void) const
Definition: Math.hpp:171
FW_CUDA_FUNC Vec3d(const Vec3i &v)
Definition: Math.hpp:411
FW_CUDA_FUNC Vec3f(void)
Definition: Math.hpp:327
FW_CUDA_FUNC S & operator|=(const T &a)
Definition: Math.hpp:556
F64 m21
Definition: Math.hpp:773
FW_CUDA_FUNC T detImpl(const MatrixBase< T, L, S > &v)
Definition: Math.hpp:905
FW_CUDA_FUNC S & operator%=(const T &a)
Definition: Math.hpp:554
FW_CUDA_FUNC Vector & operator=(const VectorBase< T, L, V > &v)
Definition: Math.hpp:230
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:683
FW_CUDA_FUNC S operator|(const T &a) const
Definition: Math.hpp:571
static FW_CUDA_FUNC Vec4i fromPtr(const S32 *ptr)
Definition: Math.hpp:289
FW_CUDA_FUNC void set(const T &a)
Definition: Math.hpp:132
FW_CUDA_FUNC void setCol(int c, const VectorBase< T, L, V > &v)
Definition: Math.hpp:576
FW_CUDA_CONST int c_popc8LUT[]
Definition: Math.hpp:799
F32 log(F32 a)
Definition: Math.hpp:89
F32 m00
Definition: Math.hpp:696
F32 m11
Definition: Math.hpp:646
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
Definition: DLLImports.inl:319
F32 m12
Definition: Math.hpp:671
F32 m00
Definition: Math.hpp:669
FW_CUDA_FUNC S operator&(const T &a) const
Definition: Math.hpp:570
F32 m33
Definition: Math.hpp:699
FW_CUDA_FUNC S operator|(const T &a) const
Definition: Math.hpp:179
F64 m31
Definition: Math.hpp:773
Mat3f getXYZ(void) const
Definition: Math.cpp:56
FW_CUDA_FUNC T min(void) const
Definition: Math.hpp:146
FW_CUDA_FUNC F32 * getPtr(void)
Definition: Math.hpp:658
FW_CUDA_FUNC S operator-(void) const
Definition: Math.hpp:562
FW_CUDA_FUNC S operator%(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:470
static FW_CUDA_FUNC Vec4d fromPtr(const F64 *ptr)
Definition: Math.hpp:444
F64 m11
Definition: Math.hpp:773
FW_CUDA_FUNC A lerp(const A &a, const A &b, const B &t)
Definition: Math.hpp:115
F64 m12
Definition: Math.hpp:774
FW_CUDA_FUNC Vec2i & operator=(const VectorBase< S32, 2, V > &v)
Definition: Math.hpp:252
FW_CUDA_FUNC Matrix(T a)
Definition: Math.hpp:616
F32 m10
Definition: Math.hpp:669
FW_CUDA_FUNC Vec3i & operator=(const VectorBase< S32, 3, V > &v)
Definition: Math.hpp:272
FW_CUDA_FUNC S operator/(const T &a) const
Definition: Math.hpp:568
FW_CUDA_FUNC S operator*(const T &a) const
Definition: Math.hpp:175
FW_CUDA_FUNC T length(void) const
Definition: Math.hpp:143
FW_CUDA_FUNC F64 * getPtr(void)
Definition: Math.hpp:712
static FW_CUDA_FUNC Matrix fromPtr(const T *ptr)
Definition: Math.hpp:620
FW_CUDA_FUNC S operator*(const T &a, const VectorBase< T, L, S > &b)
Definition: Math.hpp:468
FW_CUDA_FUNC Vec4d(F64 a)
Definition: Math.hpp:434