Elaboradar 0.1
Caricamento in corso...
Ricerca in corso...
Nessun risultato
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
14namespace radarelab {
15
16template<typename Scalar> struct Exponential {
17EIGEN_EMPTY_STRUCT_CTOR(Exponential)
18//typedef Scalar result_type;
19Scalar operator()(const Scalar& base, const Scalar& exponent) const { return std::pow(base,exponent); }
20};
21
22template<typename Scalar> struct Logarithm {
23EIGEN_EMPTY_STRUCT_CTOR(Logarithm)
24//typedef Scalar result_type;
25Scalar operator()(const Scalar& base, const Scalar& argument) const { return std::log(argument)/std::log(base); }
26};
27
28template<typename Scalar> struct Log10 {
29EIGEN_EMPTY_STRUCT_CTOR(Log10)
30//typedef Scalar result_type;
31Scalar operator()(const Scalar& argument) const { return std::log10(argument); }
32};
33
35template<class T>
36struct 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
55template<typename T>
56struct 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
String functions.
Definition: cart.cpp:4
Base for all matrices we use, since we rely on row-major data.
Definition: matrix.h:37