Blender V5.0
svd.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#ifndef __EIGEN3_SVD_C_API_CC__
10#define __EIGEN3_SVD_C_API_CC__
11
12/* Eigen gives annoying huge amount of warnings here, silence them! */
13#if defined(__GNUC__) && !defined(__clang__)
14# pragma GCC diagnostic ignored "-Wlogical-op"
15#endif
16
17#ifdef __EIGEN3_SVD_C_API_CC__
18/* Quiet warning. */
19#endif
20
21#include <Eigen/Core>
22#include <Eigen/Dense>
23#include <Eigen/SVD>
24
25#include "svd.h"
26
27using Eigen::JacobiSVD;
28
29using Eigen::NoQRPreconditioner;
30
31using Eigen::ComputeThinU;
32using Eigen::ComputeThinV;
33
34using Eigen::Map;
35using Eigen::MatrixXf;
36using Eigen::VectorXf;
37
38using Eigen::Matrix4f;
39
40void EIG_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
41{
42 /* Since our matrix is squared, we can use thinU/V. */
43 unsigned int flags = (r_U ? ComputeThinU : 0) | (r_V ? ComputeThinV : 0);
44
45 /* Blender and Eigen matrices are both column-major. */
46 JacobiSVD<MatrixXf, NoQRPreconditioner> svd(Map<MatrixXf>((float *)matrix, size, size), flags);
47
48 if (r_U) {
49 Map<MatrixXf>(r_U, size, size) = svd.matrixU();
50 }
51
52 if (r_S) {
53 Map<VectorXf>(r_S, size) = svd.singularValues();
54 }
55
56 if (r_V) {
57 Map<MatrixXf>(r_V, size, size) = svd.matrixV();
58 }
59}
60
61#endif /* __EIGEN3_SVD_C_API_CC__ */
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
void EIG_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
Definition svd.cc:40