Cheetah Software  1.0
MathUtilities.h File Reference

Utility functions for math. More...

#include <eigen3/Eigen/Dense>
+ Include dependency graph for MathUtilities.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
square (T a)
 
template<typename T , typename T2 >
bool almostEqual (const Eigen::MatrixBase< T > &a, const Eigen::MatrixBase< T > &b, T2 tol)
 

Detailed Description

Utility functions for math.

Definition in file MathUtilities.h.

Function Documentation

template<typename T , typename T2 >
bool almostEqual ( const Eigen::MatrixBase< T > &  a,
const Eigen::MatrixBase< T > &  b,
T2  tol 
)

Are two eigen matrices almost equal?

Definition at line 23 of file MathUtilities.h.

24  {
25  long x = T::RowsAtCompileTime;
26  long y = T::ColsAtCompileTime;
27 
28  if (T::RowsAtCompileTime == Eigen::Dynamic ||
29  T::ColsAtCompileTime == Eigen::Dynamic) {
30  assert(a.rows() == b.rows());
31  assert(a.cols() == b.cols());
32  x = a.rows();
33  y = a.cols();
34  }
35 
36  for (long i = 0; i < x; i++) {
37  for (long j = 0; j < y; j++) {
38  T2 error = std::abs(a(i, j) - b(i, j));
39  if (error >= tol) return false;
40  }
41  }
42  return true;
43 }

+ Here is the caller graph for this function:

template<typename T >
T square ( a)

Square a number

Definition at line 15 of file MathUtilities.h.

15  {
16  return a * a;
17 }

+ Here is the caller graph for this function: