32 #include <Eigen/Eigen> 66 template<
typename Der1,
typename Der2>
69 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
72 tomographer_assert(cart.cols() == 1 && rtheta.cols() == 1);
73 tomographer_assert(cart.rows() == rtheta.rows());
75 const size_t ds = cart.rows()-1;
94 rtheta.
block(1,0,ds-1,1).setZero();
98 Scalar val = pow(cart(ds),2);
99 for (i = ds-1; i >= 1; --i) {
100 val = val + pow(cart(i),2);
104 for (i = 1; i < ds; i++) {
105 rtheta(i) = atan2(sqrt(rtheta(i)), cart(i-1));
109 val = sqrt(pow(cart(ds), 2) + pow(cart(ds-1), 2)) + cart(ds-1);
111 rtheta(ds) = 2.0 * atan2(cart(ds), val);
136 template<
typename Der1,
typename Der2>
140 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
146 tomographer_assert(cart.cols() == 1 && theta.cols() == 1);
147 tomographer_assert(cart.rows() == theta.rows() + 1);
149 const size_t ds = theta.rows();
156 for (i = 0; i < ds; ++i) {
157 cart(i) *= cos(theta(i));
158 cart.
block(i+1, 0, ds+1 - (i+1), 1) *= sin(theta(i));
176 template<
typename Der1,
typename Der2>
179 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der2); }
182 tomographer_assert(cart.cols() == 1 && rtheta.cols() == 1);
183 tomographer_assert(cart.rows() == rtheta.rows());
185 const size_t ds = rtheta.rows()-1;
211 template<
typename Der1>
214 const size_t ds = rtheta.rows()-1;
218 for (i = 0; i < ds-1; ++i) {
219 jac *= pow(sin(rtheta(1+i)), (
int)(ds-1-i));
246 template<
typename Der1>
249 const size_t ds = theta.rows();
254 for (i = 0; i < ds-1; ++i) {
255 jac *= pow(sin(theta(i)), (
int)(ds-1-i));
278 template<
typename Der1,
typename Der2>
286 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der1); }
289 const size_t ds = theta.rows();
290 const size_t n = ds + 1;
292 tomographer_assert(theta.cols() == 1);
293 tomographer_assert(dxdtheta.rows() == (int)n);
294 tomographer_assert(dxdtheta.cols() == (int)ds);
297 sintheta = theta.
array().sin();
299 costheta = theta.
array().cos();
302 for (i = 0; i < ds; ++i) {
303 for (k = 0; k < n; ++k) {
310 }
else if (i == k && k < n - 1) {
313 for (mm = 0; mm <= i; ++mm) {
316 }
else if (i == k && k == n-1) {
319 for (mm = 0; mm < i; ++mm) {
322 }
else if (i < k && k < n-1) {
324 val = costheta(i) * costheta(k);
325 for (mm = 0; mm < k; ++mm) {
334 for (mm = 0; mm < n-1; ++mm) {
362 template<
typename Der1,
typename Der2>
370 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Der1); }
373 const size_t ds = theta.rows();
374 const size_t n = ds + 1;
376 tomographer_assert(theta.cols() == 1);
377 tomographer_assert(ddxddtheta.rows() == (int)n);
378 tomographer_assert(ddxddtheta.cols() == (int)(ds*ds));
381 sintheta = theta.
array().sin();
383 costheta = theta.
array().cos();
386 for (k = 0; k < n; ++k) {
387 for (i = 0; i < ds; ++i) {
388 for (j = 0; j <= i; ++j) {
393 }
else if (i == k && k < n-1) {
395 for (mm = 0; mm <= i; ++mm) {
401 }
else if (i == k && k == n-1) {
404 for (mm = 0; mm <= i; ++mm) {
408 val = costheta(i)*costheta(j);
409 for (mm = 0; mm < i; ++mm) {
416 }
else if (i < k && k < n-1) {
419 for (mm = 0; mm < k; ++mm) {
423 val = costheta(j)*costheta(i)*costheta(k);
424 for (mm = 0; mm < k; ++mm) {
425 if (mm == j || mm == i) {
434 for (mm = 0; mm < n-1; ++mm) {
438 val = costheta(i)*costheta(j);
439 for (mm = 0; mm < n-1; ++mm) {
440 if (mm == i || mm == j) {
448 ddxddtheta(k, i+ds*j) = val;
449 ddxddtheta(k, j+ds*i) = val;
Base namespace for the Tomographer project.
Derived & setConstant(const Scalar &value)
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
Some C++ utilities, with a tad of C++11 tricks.
ArrayWrapper< Derived > array()
Eigen::Transpose< Derived > transpose()