Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
matrix.h
Vai alla documentazione di questo file.
1 
5 #ifndef RADARELAB_MATRIX_H
6 #define RADARELAB_MATRIX_H
7 
8 #include <stdexcept>
9 #include <cmath>
10 #include <Eigen/Dense>
11 
12 #include <iostream>
13 
14 namespace radarelab {
15 
16 template<typename Scalar> struct Exponential {
17 EIGEN_EMPTY_STRUCT_CTOR(Exponential)
18 //typedef Scalar result_type;
19 Scalar operator()(const Scalar& base, const Scalar& exponent) const { return std::pow(base,exponent); }
20 };
21 
22 template<typename Scalar> struct Logarithm {
23 EIGEN_EMPTY_STRUCT_CTOR(Logarithm)
24 //typedef Scalar result_type;
25 Scalar operator()(const Scalar& base, const Scalar& argument) const { return std::log(argument)/std::log(base); }
26 };
27 
28 template<typename Scalar> struct Log10 {
29 EIGEN_EMPTY_STRUCT_CTOR(Log10)
30 //typedef Scalar result_type;
31 Scalar operator()(const Scalar& argument) const { return std::log10(argument); }
32 };
33 
35 template<class T>
36 struct Matrix2D : public Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
37 {
38  using Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>::Matrix;
39 
40  T* row_ptr(unsigned y) { return this->data() + y * this->cols(); }
41 
42  Matrix2D<T> log10()
43  {
44  return this->unaryExpr(Log10<T>());
45  }
46  Matrix2D<T> exp10()
47  {
48  Matrix2D<T> base(Matrix2D<T>::Constant(this->rows(),this->cols(),10.));
49  return base.binaryExpr(*this,Exponential<T>());
50  }
51 
52 
53 };
54 
55 template<typename T>
56 struct Image : public Matrix2D<T>
57 {
58  Image(unsigned sx, unsigned sy=0)
59  : Matrix2D<T>(Matrix2D<T>::Zero(sy ? sy : sx, sx)) {}
60 
61 };
62 
63 }
64 
65 #endif
Base for all matrices we use, since we rely on row-major data.
Definition: matrix.h:36