forked from Dekai21/Stereo_Reconstruction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEigen.h
89 lines (71 loc) · 2.36 KB
/
Eigen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#ifndef VERBOSE
//#define VERBOSE(msg) {std::cout << msg << std::endl;}
#define VERBOSE(msg)
#endif
#ifndef ASSERT
#define ASSERT(a) {if (!a) { std::cerr << "Error:\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\nFunction: " << __FUNCTION__ << std::endl; while(1); }}
#endif
#ifndef SAFE_DELETE
#define SAFE_DELETE(ptr) {if(ptr!=nullptr) {delete ptr; ptr = nullptr;}}
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(ptr) {if(ptr!=nullptr) {delete[] ptr; ptr = nullptr;}}
#endif
#ifndef MINF
#define MINF -std::numeric_limits<float>::infinity()
#endif
#ifndef M_PI
#define M_PI 3.14159265359
#endif
#include "/usr/include/eigen3/Eigen/Dense"
#include <Eigen/Dense>
#include <Eigen/StdVector>
#include <Eigen/Eigenvalues>
#include <unsupported/Eigen/NonLinearOptimization>
#include <Eigen/Sparse>
#include <Eigen/SparseCholesky>
typedef Eigen::Matrix<unsigned char, 4, 1> Vector4uc;
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2f)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3f)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector4f)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Vector4uc)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::VectorXf)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix4f)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::MatrixXf)
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Quaternionf)
using namespace Eigen;
template<typename T,unsigned int n,unsigned m>
std::istream &operator>>(std::istream &in, Matrix<T,n,m> &other)
{
for(unsigned int i=0; i<other.rows(); i++)
for(unsigned int j=0; j<other.cols(); j++)
in >> other(i,j);
return in;
}
template<typename T,unsigned int n,unsigned m>
std::ostream &operator<<(std::ostream &out, const Matrix<T,n,m> &other)
{
std::fixed(out);
for(int i=0; i<other.rows(); i++) {
out << other(i,0);
for(int j=1; j<other.cols(); j++) {
out << "\t" << other(i,j);
}
out << std::endl;
}
return out;
}
template<typename T>
std::istream &operator>>(std::istream &in, Eigen::Quaternion<T> &other)
{
in >> other.x() >> other.y() >> other.z() >> other.w();
return in;
}
template<typename T>
std::ostream &operator<<(std::ostream &out, const Eigen::Quaternion<T> &other)
{
std::fixed(out);
out << other.x() << "\t" << other.y() << "\t" << other.z() << "\t" << other.w();
return out;
}