Blender  V2.93
eigenvalues.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2015 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #ifndef __EIGEN3_EIGENVALUES_C_API_CC__
21 #define __EIGEN3_EIGENVALUES_C_API_CC__
22 
23 /* Eigen gives annoying huge amount of warnings here, silence them! */
24 #if defined(__GNUC__) && !defined(__clang__)
25 # pragma GCC diagnostic ignored "-Wlogical-op"
26 #endif
27 
28 #include <Eigen/Core>
29 #include <Eigen/Eigenvalues>
30 
31 #include "eigenvalues.h"
32 
33 using Eigen::SelfAdjointEigenSolver;
34 
35 using Eigen::Map;
36 using Eigen::MatrixXf;
37 using Eigen::VectorXf;
38 
39 using Eigen::Success;
40 
42  const float *matrix,
43  float *r_eigen_values,
44  float *r_eigen_vectors)
45 {
46  SelfAdjointEigenSolver<MatrixXf> eigen_solver;
47 
48  /* Blender and Eigen matrices are both column-major. */
49  eigen_solver.compute(Map<MatrixXf>((float *)matrix, size, size));
50 
51  if (eigen_solver.info() != Success) {
52  return false;
53  }
54 
55  if (r_eigen_values) {
56  Map<VectorXf>(r_eigen_values, size) = eigen_solver.eigenvalues().transpose();
57  }
58 
59  if (r_eigen_vectors) {
60  Map<MatrixXf>(r_eigen_vectors, size, size) = eigen_solver.eigenvectors();
61  }
62 
63  return true;
64 }
65 
66 #endif /* __EIGEN3_EIGENVALUES_C_API_CC__ */
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
bool EIG_self_adjoint_eigen_solve(const int size, const float *matrix, float *r_eigen_values, float *r_eigen_vectors)
Definition: eigenvalues.cc:41