Commit 266129c16022c192b7733e096ccfb72ed5d445ad
1 parent
f0265fbb
Remove compile option for untransposed matrix in likelihood computation (#3501)
Showing
1 changed file
with
3 additions
and
22 deletions
src/obs/GObservation.cpp
| ... | ... | @@ -62,7 +62,6 @@ const double minerr = 1.0e-100; //!< Minimum statistical error |
| 62 | 62 | |
| 63 | 63 | /* __ Coding definitions _________________________________________________ */ |
| 64 | 64 | #define G_LN_ENERGY_INT //!< ln(E) variable substitution for integration |
| 65 | -#define G_TRANSPOSE_MATRIX //!< Transpose matrix in likelihood methods | |
| 66 | 65 | |
| 67 | 66 | /* __ Debug definitions __________________________________________________ */ |
| 68 | 67 | //#define G_OPT_DEBUG //!< Debug likelihood computation |
| ... | ... | @@ -1395,10 +1394,8 @@ double GObservation::likelihood_poisson_unbinned(const GModels& models, |
| 1395 | 1394 | // Compute model and derivative |
| 1396 | 1395 | GVector model_vector = this->model(models, &wrk_matrix); |
| 1397 | 1396 | |
| 1398 | - // Compile option: transpose matrix | |
| 1399 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1397 | + // Transpose matrix | |
| 1400 | 1398 | wrk_matrix = wrk_matrix.transpose(); |
| 1401 | - #endif | |
| 1402 | 1399 | |
| 1403 | 1400 | // Iterate over all events |
| 1404 | 1401 | for (int i = 0; i < nevents; ++i) { |
| ... | ... | @@ -1415,11 +1412,7 @@ double GObservation::likelihood_poisson_unbinned(const GModels& models, |
| 1415 | 1412 | } |
| 1416 | 1413 | |
| 1417 | 1414 | // Extract working gradient multiplied by bin size |
| 1418 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1419 | 1415 | GVector wrk_grad = wrk_matrix.column(i); |
| 1420 | - #else | |
| 1421 | - GVector wrk_grad = wrk_matrix.row(i); | |
| 1422 | - #endif | |
| 1423 | 1416 | |
| 1424 | 1417 | // Create index array of non-zero derivatives and initialise working |
| 1425 | 1418 | // array |
| ... | ... | @@ -1535,10 +1528,8 @@ double GObservation::likelihood_poisson_binned(const GModels& models, |
| 1535 | 1528 | // Compute model and derivative |
| 1536 | 1529 | GVector model_vector = this->model(models, &wrk_matrix); |
| 1537 | 1530 | |
| 1538 | - // Compile option: transpose matrix | |
| 1539 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1531 | + // Transpose matrix | |
| 1540 | 1532 | wrk_matrix = wrk_matrix.transpose(); |
| 1541 | - #endif | |
| 1542 | 1533 | |
| 1543 | 1534 | // Iterate over all bins |
| 1544 | 1535 | for (int i = 0; i < nevents; ++i) { |
| ... | ... | @@ -1585,11 +1576,7 @@ double GObservation::likelihood_poisson_binned(const GModels& models, |
| 1585 | 1576 | *npred += model; |
| 1586 | 1577 | |
| 1587 | 1578 | // Extract working gradient multiplied by bin size |
| 1588 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1589 | 1579 | GVector wrk_grad = wrk_matrix.column(i) * bin->size(); |
| 1590 | - #else | |
| 1591 | - GVector wrk_grad = wrk_matrix.row(i) * bin->size(); | |
| 1592 | - #endif | |
| 1593 | 1580 | |
| 1594 | 1581 | // Create index array of non-zero derivatives and initialise working |
| 1595 | 1582 | // array |
| ... | ... | @@ -1743,10 +1730,8 @@ double GObservation::likelihood_gaussian_binned(const GModels& models, |
| 1743 | 1730 | // Compute model and derivative |
| 1744 | 1731 | GVector model_vector = this->model(models, &wrk_matrix); |
| 1745 | 1732 | |
| 1746 | - // Compile option: transpose matrix | |
| 1747 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1733 | + // Transpose matrix | |
| 1748 | 1734 | wrk_matrix = wrk_matrix.transpose(); |
| 1749 | - #endif | |
| 1750 | 1735 | |
| 1751 | 1736 | // Iterate over all bins |
| 1752 | 1737 | for (int i = 0; i < nevents; ++i) { |
| ... | ... | @@ -1783,11 +1768,7 @@ double GObservation::likelihood_gaussian_binned(const GModels& models, |
| 1783 | 1768 | *npred += model; |
| 1784 | 1769 | |
| 1785 | 1770 | // Extract working gradient multiplied by bin size |
| 1786 | - #if defined(G_TRANSPOSE_MATRIX) | |
| 1787 | 1771 | GVector wrk_grad = wrk_matrix.column(i) * bin->size(); |
| 1788 | - #else | |
| 1789 | - GVector wrk_grad = wrk_matrix.row(i) * bin->size(); | |
| 1790 | - #endif | |
| 1791 | 1772 | |
| 1792 | 1773 | // Create index array of non-zero derivatives and initialise working |
| 1793 | 1774 | // array | ... | ... |