4 #ifndef __UTIL_MATH_MATRIX_H__
5 #define __UTIL_MATH_MATRIX_H__
9 #define MAT(A, size, row, col) A[(row) * (size) + (col)]
13 # define MATS(A, n, r, c, s) A[((r) * (n) + (c)) * (s)]
15 # define MATHS(A, r, c, s) A[((r) * ((r) + 1) / 2 + (c)) * (s)]
16 # define VECS(V, i, s) V[(i) * (s)]
18 # define MATS(A, n, r, c, s) MAT(A, n, r, c)
19 # define MATHS(A, r, c, s) A[(r) * ((r) + 1) / 2 + (c)]
20 # define VECS(V, i, s) V[i]
27 for (
int i = 0; i < n; i++) {
34 for (
int row = 0; row < n; row++) {
47 for (
int i = 0; i < n; i++) {
56 for (
int i = 0; i < n; i++) {
66 for (
int i = 0; i < n; i++) {
67 a[i * astride] *=
b[i];
73 for (
int i = 0; i < n; i++) {
82 for (
int i = 0; i < n; i++) {
89 for (
int i = 0; i < n; i++) {
97 for (
int i = 0; i < n; i++) {
114 for (
int row = 0; row < n; row++) {
126 for (
int row = 0; row < n; row++) {
138 for (
int row = 0; row < n; row++) {
150 for (
int row = 0; row < n; row++) {
160 for (
int i = 0; i < n; i++) {
161 for (
int j = 0; j < i; j++) {
176 for (
int row = 0; row < n; row++) {
179 for (
int k = 0; k <
col; k++) {
183 sum_col =
sqrtf(
max(sum_col, 0.0f));
216 for (
int row = 0; row < n; row++) {
224 for (
int row = n - 1; row >= 0; row--) {
245 const float singular_epsilon = 1e-9f;
247 for (
int row = 0; row < n; row++) {
249 MATS(
V, n, row,
col, v_stride) = (
col == row) ? 1.0f : 0.0f;
253 for (
int sweep = 0; sweep < 8; sweep++) {
254 float off_diagonal = 0.0f;
255 for (
int row = 1; row < n; row++) {
260 if (off_diagonal < 1e-7f) {
269 float threshold = 0.2f * off_diagonal / (n * n);
271 for (
int row = 1; row < n; row++) {
279 if (sweep > 3 && abs_element <= singular_epsilon *
fabsf(
MAT(
A, n, row, row)) &&
291 if (sweep < 3 && (abs_element <
threshold)) {
302 if (abs_element > singular_epsilon *
fabsf(singular_diff)) {
303 float cot_2phi = 0.5f * singular_diff /
element;
304 ratio = 1.0f / (
fabsf(cot_2phi) +
sqrtf(1.0f + cot_2phi * cot_2phi));
309 ratio =
element / singular_diff;
312 float c = 1.0f /
sqrtf(1.0f + ratio * ratio);
316 float tan_phi_2 = s / (1.0f +
c);
319 float singular_delta = ratio *
element;
320 MAT(
A, n, row, row) += singular_delta;
327 #define ROT(M, r1, c1, r2, c2, stride) \
329 float M1 = MATS(M, n, r1, c1, stride); \
330 float M2 = MATS(M, n, r2, c2, stride); \
331 MATS(M, n, r1, c1, stride) -= s * (M2 + tan_phi_2 * M1); \
332 MATS(M, n, r2, c2, stride) += s * (M1 - tan_phi_2 * M2); \
337 for (
int i = 0; i <
col; i++)
339 for (
int i =
col + 1; i < row; i++)
341 for (
int i = row + 1; i < n; i++)
344 for (
int i = 0; i < n; i++)
345 ROT(
V,
col, i, row, i, v_stride);
352 for (
int i = 0; i < n - 1; i++) {
353 float v =
MAT(
A, n, i, i);
355 for (
int j = i; j < n; j++) {
356 if (
MAT(
A, n, j, j) >=
v) {
366 for (
int j = 0; j < n; j++) {
367 float v =
MATS(
V, n, i, j, v_stride);
368 MATS(
V, n, i, j, v_stride) =
MATS(
V, n, k, j, v_stride);
369 MATS(
V, n, k, j, v_stride) =
v;
375 #ifdef __KERNEL_SSE3__
378 for (
int i = 0; i < n; i++) {
385 for (
int row = 0; row < n; row++) {
399 for (
int row = 0; row < n; row++) {
408 for (
int i = 0; i < n; i++) {
415 for (
int i = 0; i < n; i++) {
422 for (
int i = 0; i < n; i++) {
429 for (
int row = 0; row < n; row++) {
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
#define atomic_add_and_fetch_float(p, x)
__forceinline int reduce_add(const avxi &v)
ATTR_WARN_UNUSED_RESULT const void * element
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static T sum(const btAlignedObjectArray< T > &items)
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
ccl_device_inline float4 zero_float4()
#define MAT(A, size, row, col)
ccl_device_inline void math_vec3_add(ccl_private float3 *v, int n, ccl_private float *x, float3 w)
ccl_device void math_trimatrix_cholesky(ccl_global float *A, int n, int stride)
ccl_device_inline void math_matrix_transpose(ccl_global float *A, int n, int stride)
ccl_device_inline void math_vector_add(ccl_private float *a, ccl_private const float *ccl_restrict b, int n)
ccl_device_inline void math_vec3_add_strided(ccl_global float3 *v, int n, ccl_private float *x, float3 w, int stride)
ccl_device_inline void math_trimatrix_add_diagonal(ccl_global float *A, int n, float val, int stride)
ccl_device_inline void math_matrix_zero(ccl_private float *A, int n)
ccl_device_inline void math_vector_mul(ccl_private float *a, ccl_private const float *ccl_restrict b, int n)
#define MATHS(A, r, c, s)
ccl_device_inline void math_trimatrix_add_gramian_strided(ccl_global float *A, int n, ccl_private const float *ccl_restrict v, float weight, int stride)
#define ROT(M, r1, c1, r2, c2, stride)
ccl_device_inline void math_vector_max(ccl_private float *a, ccl_private const float *ccl_restrict b, int n)
ccl_device_inline void math_vector_scale(ccl_private float *a, float b, int n)
ccl_device_inline void math_trimatrix_vec3_solve(ccl_global float *A, ccl_global float3 *y, int n, int stride)
#define MATS(A, n, r, c, s)
ccl_device void math_matrix_jacobi_eigendecomposition(ccl_private float *A, ccl_global float *V, int n, int v_stride)
ccl_device_inline void math_vector_mul_strided(ccl_global float *a, ccl_private const float *ccl_restrict b, int astride, int n)
ccl_device_inline void math_matrix_add_gramian(ccl_private float *A, int n, ccl_private const float *ccl_restrict v, float weight)
ccl_device_inline void math_trimatrix_add_gramian(ccl_global float *A, int n, ccl_private const float *ccl_restrict v, float weight)
ccl_device_inline void math_vector_zero(ccl_private float *v, int n)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
CCL_NAMESPACE_BEGIN struct Window V