33 #include <Eigen/Eigen> 67 template<
typename Der1,
typename Der2>
70 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
76 const Eigen::Index ds = cart.rows()-1;
96 rtheta.
segment(1,ds-1).setZero();
100 Scalar val = pow(cart(ds),2);
101 for (i = ds-1; i >= 1; --i) {
102 val = val + pow(cart(i),2);
106 for (i = 1; i < ds; i++) {
107 rtheta(i) = atan2(sqrt(rtheta(i)), cart(i-1));
111 val = sqrt(pow(cart(ds), 2) + pow(cart(ds-1), 2)) + cart(ds-1);
113 rtheta(ds) = 2.0 * atan2(cart(ds), val);
138 template<
typename Der1,
typename Der2>
142 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
151 const Eigen::Index ds = theta.rows();
158 for (i = 0; i < ds; ++i) {
159 cart(i) *= cos(theta(i));
160 cart.
segment(i+1, ds+1 - (i+1)) *= sin(theta(i));
178 template<
typename Der1,
typename Der2>
181 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
187 const Eigen::Index ds = rtheta.rows()-1;
213 template<
typename Der1>
216 const Eigen::Index ds = rtheta.rows()-1;
220 for (i = 0; i < ds-1; ++i) {
221 jac *= pow(sin(rtheta(1+i)), (
int)(ds-1-i));
248 template<
typename Der1>
251 const Eigen::Index ds = theta.rows();
256 for (i = 0; i < ds-1; ++i) {
257 jac *= pow(sin(theta(i)), (
int)(ds-1-i));
280 template<
typename Der1,
typename Der2>
288 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der1); }
291 const Eigen::Index ds = theta.rows();
292 const Eigen::Index n = ds + 1;
299 sintheta = theta.
array().sin();
301 costheta = theta.
array().cos();
303 Eigen::Index i, k, mm;
304 for (i = 0; i < ds; ++i) {
305 for (k = 0; k < n; ++k) {
312 }
else if (i == k && k < n - 1) {
315 for (mm = 0; mm <= i; ++mm) {
318 }
else if (i == k && k == n-1) {
321 for (mm = 0; mm < i; ++mm) {
324 }
else if (i < k && k < n-1) {
326 val = costheta(i) * costheta(k);
327 for (mm = 0; mm < k; ++mm) {
336 for (mm = 0; mm < n-1; ++mm) {
364 template<
typename Der1,
typename Der2>
372 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der1); }
375 const Eigen::Index ds = theta.rows();
376 const Eigen::Index n = ds + 1;
383 sintheta = theta.
array().sin();
385 costheta = theta.
array().cos();
387 Eigen::Index i, j, k, mm;
388 for (k = 0; k < n; ++k) {
389 for (i = 0; i < ds; ++i) {
390 for (j = 0; j <= i; ++j) {
395 }
else if (i == k && k < n-1) {
397 for (mm = 0; mm <= i; ++mm) {
403 }
else if (i == k && k == n-1) {
406 for (mm = 0; mm <= i; ++mm) {
410 val = costheta(i)*costheta(j);
411 for (mm = 0; mm < i; ++mm) {
418 }
else if (i < k && k < n-1) {
421 for (mm = 0; mm < k; ++mm) {
425 val = costheta(j)*costheta(i)*costheta(k);
426 for (mm = 0; mm < k; ++mm) {
427 if (mm == j || mm == i) {
436 for (mm = 0; mm < n-1; ++mm) {
440 val = costheta(i)*costheta(j);
441 for (mm = 0; mm < n-1; ++mm) {
442 if (mm == i || mm == j) {
450 ddxddtheta(k, i+ds*j) = val;
451 ddxddtheta(k, j+ds*i) = val;
Base namespace for the Tomographer project.
SegmentReturnType segment(Index start, Index n)
Derived & setConstant(const Scalar &value)
Some C++ utilities, with a tad of C++11 tricks.
ArrayWrapper< Derived > array()
Eigen::Transpose< Derived > transpose()
#define tomographer_assert(...)
Assertion test macro.