sparseGaussianTest< Scalar > Struct Template Reference
+ Inheritance diagram for sparseGaussianTest< Scalar >:

Public Types

typedef Matrix< Scalar, Dynamic, 1 > VectorType
 
typedef SparseFunctor< Scalar, intBase
 
typedef Base::JacobianType JacobianType
 
- Public Types inherited from Eigen::SparseFunctor< Scalar, int >
enum  
 
typedef Scalar Scalar
 
typedef int Index
 
typedef Matrix< Scalar, Dynamic, 1 > InputType
 
typedef Matrix< Scalar, Dynamic, 1 > ValueType
 
typedef SparseMatrix< Scalar, ColMajor, IndexJacobianType
 
typedef SparseQR< JacobianType, COLAMDOrdering< int > > QRSolver
 

Public Member Functions

 sparseGaussianTest (int inputs, int values)
 
VectorType model (const VectorType &uv, VectorType &x)
 
void initPoints (VectorType &uv_ref, VectorType &x)
 
int operator() (const VectorType &uv, VectorType &fvec)
 
int df (const VectorType &uv, JacobianType &fjac)
 
- Public Member Functions inherited from Eigen::SparseFunctor< Scalar, int >
 SparseFunctor (int inputs, int values)
 
int inputs () const
 
int values () const
 

Public Attributes

VectorType m_x
 
VectorType m_y
 
- Public Attributes inherited from Eigen::SparseFunctor< Scalar, int >
const int m_inputs
 
const int m_values
 

Member Typedef Documentation

◆ Base

template<typename Scalar >
typedef SparseFunctor<Scalar, int> sparseGaussianTest< Scalar >::Base

◆ JacobianType

template<typename Scalar >
typedef Base::JacobianType sparseGaussianTest< Scalar >::JacobianType

◆ VectorType

template<typename Scalar >
typedef Matrix<Scalar, Dynamic, 1> sparseGaussianTest< Scalar >::VectorType

Constructor & Destructor Documentation

◆ sparseGaussianTest()

template<typename Scalar >
sparseGaussianTest< Scalar >::sparseGaussianTest ( int  inputs,
int  values 
)
inline
int inputs() const
Definition: LevenbergMarquardt/LevenbergMarquardt.h:78
int values() const
Definition: LevenbergMarquardt/LevenbergMarquardt.h:79

Member Function Documentation

◆ df()

template<typename Scalar >
int sparseGaussianTest< Scalar >::df ( const VectorType uv,
JacobianType fjac 
)
inline
72  {
73  int m = Base::values();
74  int n = Base::inputs();
75  eigen_assert(n == uv.size());
76  eigen_assert(fjac.rows() == m);
77  eigen_assert(fjac.cols() == n);
78  int half = n / 2;
81  Scalar coeff;
82 
83  // Derivatives with respect to u
84  for (int col = 0; col < half; col++) {
85  for (int row = 0; row < m; row++) {
86  coeff = (m_x(row) - col) / v(col);
87  coeff = coeff * coeff;
88  if (coeff < 1. && coeff > 0.) {
89  fjac.coeffRef(row, col) = -(1 - coeff) * (1 - coeff);
90  }
91  }
92  }
93  // Derivatives with respect to v
94  for (int col = 0; col < half; col++) {
95  for (int row = 0; row < m; row++) {
96  coeff = (m_x(row) - col) / v(col);
97  coeff = coeff * coeff;
98  if (coeff < 1. && coeff > 0.) {
99  fjac.coeffRef(row, col + half) = -4 * (u(col) / v(col)) * coeff * (1 - coeff);
100  }
101  }
102  }
103  return 0;
104  }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define eigen_assert(x)
Definition: Macros.h:910
m col(1)
m row(1)
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:58
int * m
Definition: level2_cplx_impl.h:294
Scalar Scalar
Definition: LevenbergMarquardt/LevenbergMarquardt.h:68
Definition: Half.h:139
VectorType m_x
Definition: sparseLM.cpp:106

References Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::coeffRef(), col(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::cols(), eigen_assert, m, n, row(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::rows(), and v.

◆ initPoints()

template<typename Scalar >
void sparseGaussianTest< Scalar >::initPoints ( VectorType uv_ref,
VectorType x 
)
inline
48  {
49  m_x = x;
50  m_y = this->model(uv_ref, x);
51  }
list x
Definition: plotDoE.py:28
VectorType m_y
Definition: sparseLM.cpp:106
VectorType model(const VectorType &uv, VectorType &x)
Definition: sparseLM.cpp:27

References plotDoE::x.

Referenced by test_sparseLM_T().

◆ model()

template<typename Scalar >
VectorType sparseGaussianTest< Scalar >::model ( const VectorType uv,
VectorType x 
)
inline
27  {
28  VectorType y; // Change this to use expression template
29  int m = Base::values();
30  int n = Base::inputs();
31  eigen_assert(uv.size() % 2 == 0);
32  eigen_assert(uv.size() == n);
33  eigen_assert(x.size() == m);
34  y.setZero(m);
35  int half = n / 2;
38  Scalar coeff;
39  for (int j = 0; j < m; j++) {
40  for (int i = 0; i < half; i++) {
41  coeff = (x(j) - i) / v(i);
42  coeff *= coeff;
43  if (coeff < 1. && coeff > 0.) y(j) += u(i) * std::pow((1 - coeff), 2);
44  }
45  }
46  return y;
47  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * y
Definition: level1_cplx_impl.h:128
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
Definition: fft_test_shared.h:66
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References eigen_assert, i, j, m, n, Eigen::bfloat16_impl::pow(), v, plotDoE::x, and y.

◆ operator()()

template<typename Scalar >
int sparseGaussianTest< Scalar >::operator() ( const VectorType uv,
VectorType fvec 
)
inline
52  {
53  int m = Base::values();
54  int n = Base::inputs();
55  eigen_assert(uv.size() % 2 == 0);
56  eigen_assert(uv.size() == n);
57  int half = n / 2;
60  fvec = m_y;
61  Scalar coeff;
62  for (int j = 0; j < m; j++) {
63  for (int i = 0; i < half; i++) {
64  coeff = (m_x(j) - i) / v(i);
65  coeff *= coeff;
66  if (coeff < 1. && coeff > 0.) fvec(j) -= u(i) * std::pow((1 - coeff), 2);
67  }
68  }
69  return 0;
70  }

References eigen_assert, i, j, m, n, Eigen::bfloat16_impl::pow(), and v.

Member Data Documentation

◆ m_x

template<typename Scalar >
VectorType sparseGaussianTest< Scalar >::m_x

◆ m_y

template<typename Scalar >
VectorType sparseGaussianTest< Scalar >::m_y

The documentation for this struct was generated from the following file: