mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -20,166 +20,84 @@ using namespace Eigen;
|
||||
|
||||
////// class MatrixXd //////
|
||||
|
||||
inline MatrixXd& c_to_eigen(C_MatrixXd* ptr)
|
||||
{
|
||||
return *reinterpret_cast<MatrixXd*>(ptr);
|
||||
}
|
||||
inline MatrixXd &c_to_eigen(C_MatrixXd *ptr) { return *reinterpret_cast<MatrixXd *>(ptr); }
|
||||
|
||||
inline const MatrixXd& c_to_eigen(const C_MatrixXd* ptr)
|
||||
{
|
||||
return *reinterpret_cast<const MatrixXd*>(ptr);
|
||||
}
|
||||
inline const MatrixXd &c_to_eigen(const C_MatrixXd *ptr) { return *reinterpret_cast<const MatrixXd *>(ptr); }
|
||||
|
||||
inline C_MatrixXd* eigen_to_c(MatrixXd& ref)
|
||||
{
|
||||
return reinterpret_cast<C_MatrixXd*>(&ref);
|
||||
}
|
||||
inline C_MatrixXd *eigen_to_c(MatrixXd &ref) { return reinterpret_cast<C_MatrixXd *>(&ref); }
|
||||
|
||||
inline const C_MatrixXd* eigen_to_c(const MatrixXd& ref)
|
||||
{
|
||||
return reinterpret_cast<const C_MatrixXd*>(&ref);
|
||||
}
|
||||
inline const C_MatrixXd *eigen_to_c(const MatrixXd &ref) { return reinterpret_cast<const C_MatrixXd *>(&ref); }
|
||||
|
||||
////// class Map<MatrixXd> //////
|
||||
|
||||
inline Map<MatrixXd>& c_to_eigen(C_Map_MatrixXd* ptr)
|
||||
{
|
||||
return *reinterpret_cast<Map<MatrixXd>*>(ptr);
|
||||
inline Map<MatrixXd> &c_to_eigen(C_Map_MatrixXd *ptr) { return *reinterpret_cast<Map<MatrixXd> *>(ptr); }
|
||||
|
||||
inline const Map<MatrixXd> &c_to_eigen(const C_Map_MatrixXd *ptr) {
|
||||
return *reinterpret_cast<const Map<MatrixXd> *>(ptr);
|
||||
}
|
||||
|
||||
inline const Map<MatrixXd>& c_to_eigen(const C_Map_MatrixXd* ptr)
|
||||
{
|
||||
return *reinterpret_cast<const Map<MatrixXd>*>(ptr);
|
||||
}
|
||||
inline C_Map_MatrixXd *eigen_to_c(Map<MatrixXd> &ref) { return reinterpret_cast<C_Map_MatrixXd *>(&ref); }
|
||||
|
||||
inline C_Map_MatrixXd* eigen_to_c(Map<MatrixXd>& ref)
|
||||
{
|
||||
return reinterpret_cast<C_Map_MatrixXd*>(&ref);
|
||||
inline const C_Map_MatrixXd *eigen_to_c(const Map<MatrixXd> &ref) {
|
||||
return reinterpret_cast<const C_Map_MatrixXd *>(&ref);
|
||||
}
|
||||
|
||||
inline const C_Map_MatrixXd* eigen_to_c(const Map<MatrixXd>& ref)
|
||||
{
|
||||
return reinterpret_cast<const C_Map_MatrixXd*>(&ref);
|
||||
}
|
||||
|
||||
|
||||
/************************* implementation of classes **********************************************/
|
||||
|
||||
|
||||
////// class MatrixXd //////
|
||||
|
||||
C_MatrixXd *MatrixXd_new(int rows, int cols) { return eigen_to_c(*new MatrixXd(rows, cols)); }
|
||||
|
||||
C_MatrixXd* MatrixXd_new(int rows, int cols)
|
||||
{
|
||||
return eigen_to_c(*new MatrixXd(rows,cols));
|
||||
}
|
||||
void MatrixXd_delete(C_MatrixXd *m) { delete &c_to_eigen(m); }
|
||||
|
||||
void MatrixXd_delete(C_MatrixXd *m)
|
||||
{
|
||||
delete &c_to_eigen(m);
|
||||
}
|
||||
double *MatrixXd_data(C_MatrixXd *m) { return c_to_eigen(m).data(); }
|
||||
|
||||
double* MatrixXd_data(C_MatrixXd *m)
|
||||
{
|
||||
return c_to_eigen(m).data();
|
||||
}
|
||||
void MatrixXd_set_zero(C_MatrixXd *m) { c_to_eigen(m).setZero(); }
|
||||
|
||||
void MatrixXd_set_zero(C_MatrixXd *m)
|
||||
{
|
||||
c_to_eigen(m).setZero();
|
||||
}
|
||||
void MatrixXd_resize(C_MatrixXd *m, int rows, int cols) { c_to_eigen(m).resize(rows, cols); }
|
||||
|
||||
void MatrixXd_resize(C_MatrixXd *m, int rows, int cols)
|
||||
{
|
||||
c_to_eigen(m).resize(rows,cols);
|
||||
}
|
||||
void MatrixXd_copy(C_MatrixXd *dst, const C_MatrixXd *src) { c_to_eigen(dst) = c_to_eigen(src); }
|
||||
|
||||
void MatrixXd_copy(C_MatrixXd *dst, const C_MatrixXd *src)
|
||||
{
|
||||
c_to_eigen(dst) = c_to_eigen(src);
|
||||
}
|
||||
void MatrixXd_copy_map(C_MatrixXd *dst, const C_Map_MatrixXd *src) { c_to_eigen(dst) = c_to_eigen(src); }
|
||||
|
||||
void MatrixXd_copy_map(C_MatrixXd *dst, const C_Map_MatrixXd *src)
|
||||
{
|
||||
c_to_eigen(dst) = c_to_eigen(src);
|
||||
}
|
||||
void MatrixXd_set_coeff(C_MatrixXd *m, int i, int j, double coeff) { c_to_eigen(m)(i, j) = coeff; }
|
||||
|
||||
void MatrixXd_set_coeff(C_MatrixXd *m, int i, int j, double coeff)
|
||||
{
|
||||
c_to_eigen(m)(i,j) = coeff;
|
||||
}
|
||||
double MatrixXd_get_coeff(const C_MatrixXd *m, int i, int j) { return c_to_eigen(m)(i, j); }
|
||||
|
||||
double MatrixXd_get_coeff(const C_MatrixXd *m, int i, int j)
|
||||
{
|
||||
return c_to_eigen(m)(i,j);
|
||||
}
|
||||
void MatrixXd_print(const C_MatrixXd *m) { std::cout << c_to_eigen(m) << std::endl; }
|
||||
|
||||
void MatrixXd_print(const C_MatrixXd *m)
|
||||
{
|
||||
std::cout << c_to_eigen(m) << std::endl;
|
||||
}
|
||||
|
||||
void MatrixXd_multiply(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result)
|
||||
{
|
||||
void MatrixXd_multiply(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result) {
|
||||
c_to_eigen(result) = c_to_eigen(m1) * c_to_eigen(m2);
|
||||
}
|
||||
|
||||
void MatrixXd_add(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result)
|
||||
{
|
||||
void MatrixXd_add(const C_MatrixXd *m1, const C_MatrixXd *m2, C_MatrixXd *result) {
|
||||
c_to_eigen(result) = c_to_eigen(m1) + c_to_eigen(m2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////// class Map_MatrixXd //////
|
||||
|
||||
|
||||
C_Map_MatrixXd* Map_MatrixXd_new(double *array, int rows, int cols)
|
||||
{
|
||||
return eigen_to_c(*new Map<MatrixXd>(array,rows,cols));
|
||||
C_Map_MatrixXd *Map_MatrixXd_new(double *array, int rows, int cols) {
|
||||
return eigen_to_c(*new Map<MatrixXd>(array, rows, cols));
|
||||
}
|
||||
|
||||
void Map_MatrixXd_delete(C_Map_MatrixXd *m)
|
||||
{
|
||||
delete &c_to_eigen(m);
|
||||
}
|
||||
void Map_MatrixXd_delete(C_Map_MatrixXd *m) { delete &c_to_eigen(m); }
|
||||
|
||||
void Map_MatrixXd_set_zero(C_Map_MatrixXd *m)
|
||||
{
|
||||
c_to_eigen(m).setZero();
|
||||
}
|
||||
void Map_MatrixXd_set_zero(C_Map_MatrixXd *m) { c_to_eigen(m).setZero(); }
|
||||
|
||||
void Map_MatrixXd_copy(C_Map_MatrixXd *dst, const C_Map_MatrixXd *src)
|
||||
{
|
||||
c_to_eigen(dst) = c_to_eigen(src);
|
||||
}
|
||||
void Map_MatrixXd_copy(C_Map_MatrixXd *dst, const C_Map_MatrixXd *src) { c_to_eigen(dst) = c_to_eigen(src); }
|
||||
|
||||
void Map_MatrixXd_copy_matrix(C_Map_MatrixXd *dst, const C_MatrixXd *src)
|
||||
{
|
||||
c_to_eigen(dst) = c_to_eigen(src);
|
||||
}
|
||||
void Map_MatrixXd_copy_matrix(C_Map_MatrixXd *dst, const C_MatrixXd *src) { c_to_eigen(dst) = c_to_eigen(src); }
|
||||
|
||||
void Map_MatrixXd_set_coeff(C_Map_MatrixXd *m, int i, int j, double coeff)
|
||||
{
|
||||
c_to_eigen(m)(i,j) = coeff;
|
||||
}
|
||||
void Map_MatrixXd_set_coeff(C_Map_MatrixXd *m, int i, int j, double coeff) { c_to_eigen(m)(i, j) = coeff; }
|
||||
|
||||
double Map_MatrixXd_get_coeff(const C_Map_MatrixXd *m, int i, int j)
|
||||
{
|
||||
return c_to_eigen(m)(i,j);
|
||||
}
|
||||
double Map_MatrixXd_get_coeff(const C_Map_MatrixXd *m, int i, int j) { return c_to_eigen(m)(i, j); }
|
||||
|
||||
void Map_MatrixXd_print(const C_Map_MatrixXd *m)
|
||||
{
|
||||
std::cout << c_to_eigen(m) << std::endl;
|
||||
}
|
||||
void Map_MatrixXd_print(const C_Map_MatrixXd *m) { std::cout << c_to_eigen(m) << std::endl; }
|
||||
|
||||
void Map_MatrixXd_multiply(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result)
|
||||
{
|
||||
void Map_MatrixXd_multiply(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result) {
|
||||
c_to_eigen(result) = c_to_eigen(m1) * c_to_eigen(m2);
|
||||
}
|
||||
|
||||
void Map_MatrixXd_add(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result)
|
||||
{
|
||||
void Map_MatrixXd_add(const C_Map_MatrixXd *m1, const C_Map_MatrixXd *m2, C_Map_MatrixXd *result) {
|
||||
c_to_eigen(result) = c_to_eigen(m1) + c_to_eigen(m2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user