1#ifndef TATAMI_MATH_HELPERS_H
2#define TATAMI_MATH_HELPERS_H
23template<
typename InputValue_ =
double>
29 static constexpr bool is_basic =
false;
31 bool is_sparse()
const {
40 template<
typename Index_,
typename OutputValue_>
43 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
56 template<
typename Index_,
typename OutputValue_>
61 template<
typename Index_,
typename OutputValue_>
66 template<
typename Index_,
typename OutputValue_>
71 template<
typename OutputValue_,
typename Index_>
91template<
typename InputValue_ =
double>
97 static constexpr bool is_basic =
false;
99 bool is_sparse()
const {
107 template<
typename Index_,
typename OutputValue_>
110 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
112 if (!std::isnan(
val)) {
117 if (!std::isnan(
val)) {
119 }
else if constexpr(std::numeric_limits<OutputValue_>::has_quiet_NaN) {
120 output[
i] = std::numeric_limits<OutputValue_>::quiet_NaN();
132 template<
typename Index_,
typename OutputValue_>
137 template<
typename Index_,
typename OutputValue_>
142 template<
typename Index_,
typename OutputValue_>
147 template<
typename OutputValue_,
typename Index_>
166template<
typename InputValue_ =
double,
typename Base_ = InputValue_>
183 static constexpr bool is_basic =
false;
185 bool is_sparse()
const {
195 template<
typename Index_,
typename OutputValue_>
198 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
200 val = std::log(
val) / my_base;
211 template<
typename Index_,
typename OutputValue_>
216 template<
typename Index_,
typename OutputValue_>
221 template<
typename Index_,
typename OutputValue_>
226 template<
typename OutputValue_,
typename Index_>
245template<
typename InputValue_ =
double>
251 static constexpr bool is_basic =
false;
253 bool is_sparse()
const {
261 template<
typename Index_,
typename OutputValue_>
264 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
277 template<
typename Index_,
typename OutputValue_>
282 template<
typename Index_,
typename OutputValue_>
287 template<
typename Index_,
typename OutputValue_>
292 template<
typename OutputValue_,
typename Index_>
310template<
typename InputValue_ =
double>
316 static constexpr bool is_basic =
false;
318 bool is_sparse()
const {
326 template<
typename Index_,
typename OutputValue_>
329 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
342 template<
typename Index_,
typename OutputValue_>
347 template<
typename Index_,
typename OutputValue_>
352 template<
typename Index_,
typename OutputValue_>
357 template<
typename OutputValue_,
typename Index_>
375template<
typename InputValue_ =
double>
381 static constexpr bool is_basic =
false;
383 bool is_sparse()
const {
391 template<
typename Index_,
typename OutputValue_>
394 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
407 template<
typename Index_,
typename OutputValue_>
412 template<
typename Index_,
typename OutputValue_>
417 template<
typename Index_,
typename OutputValue_>
422 template<
typename OutputValue_,
typename Index_>
440template<
typename InputValue_ =
double>
446 static constexpr bool is_basic =
false;
448 bool is_sparse()
const {
456 template<
typename Index_,
typename OutputValue_>
459 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
472 template<
typename Index_,
typename OutputValue_>
477 template<
typename Index_,
typename OutputValue_>
482 template<
typename Index_,
typename OutputValue_>
487 template<
typename OutputValue_,
typename Index_>
506template<
typename InputValue_ =
double,
typename Base_ = InputValue_>
523 static constexpr bool is_basic =
false;
525 bool is_sparse()
const {
533 template<
typename Index_,
typename OutputValue_>
536 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
538 val = std::log1p(
val) / my_base;
551 template<
typename Index_,
typename OutputValue_>
556 template<
typename Index_,
typename OutputValue_>
561 template<
typename Index_,
typename OutputValue_>
566 template<
typename OutputValue_,
typename Index_>
584template<
typename InputValue_ =
double>
590 static constexpr bool is_basic =
false;
592 bool is_sparse()
const {
600 template<
typename Index_,
typename OutputValue_>
603 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
616 template<
typename Index_,
typename OutputValue_>
621 template<
typename Index_,
typename OutputValue_>
626 template<
typename Index_,
typename OutputValue_>
631 template<
typename OutputValue_,
typename Index_>
649template<
typename InputValue_ =
double>
655 static constexpr bool is_basic =
false;
657 bool is_sparse()
const {
665 template<
typename Index_,
typename OutputValue_>
668 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
681 template<
typename Index_,
typename OutputValue_>
686 template<
typename Index_,
typename OutputValue_>
691 template<
typename Index_,
typename OutputValue_>
696 template<
typename OutputValue_,
typename Index_>
714template<
typename InputValue_ =
double>
720 static constexpr bool is_basic =
false;
722 bool is_sparse()
const {
730 template<
typename Index_,
typename OutputValue_>
733 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
746 template<
typename Index_,
typename OutputValue_>
751 template<
typename Index_,
typename OutputValue_>
756 template<
typename Index_,
typename OutputValue_>
761 template<
typename OutputValue_,
typename Index_>
779template<
typename InputValue_ =
double>
785 static constexpr bool is_basic =
false;
787 bool is_sparse()
const {
795 template<
typename Index_,
typename OutputValue_>
798 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
811 template<
typename Index_,
typename OutputValue_>
816 template<
typename Index_,
typename OutputValue_>
821 template<
typename Index_,
typename OutputValue_>
826 template<
typename OutputValue_,
typename Index_>
845template<
typename InputValue_ =
double>
851 static constexpr bool is_basic =
false;
853 bool is_sparse()
const {
861 template<
typename Index_,
typename OutputValue_>
864 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
877 template<
typename Index_,
typename OutputValue_>
882 template<
typename Index_,
typename OutputValue_>
887 template<
typename Index_,
typename OutputValue_>
892 template<
typename OutputValue_,
typename Index_>
911template<
typename InputValue_ =
double>
917 static constexpr bool is_basic =
false;
919 bool is_sparse()
const {
927 template<
typename Index_,
typename OutputValue_>
930 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
943 template<
typename Index_,
typename OutputValue_>
948 template<
typename Index_,
typename OutputValue_>
953 template<
typename Index_,
typename OutputValue_>
958 template<
typename OutputValue_,
typename Index_>
976template<
typename InputValue_ =
double>
982 static constexpr bool is_basic =
false;
984 bool is_sparse()
const {
992 template<
typename Index_,
typename OutputValue_>
995 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1008 template<
typename Index_,
typename OutputValue_>
1013 template<
typename Index_,
typename OutputValue_>
1018 template<
typename Index_,
typename OutputValue_>
1023 template<
typename OutputValue_,
typename Index_>
1041template<
typename InputValue_ =
double>
1047 static constexpr bool is_basic =
false;
1049 bool is_sparse()
const {
1057 template<
typename Index_,
typename OutputValue_>
1060 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1073 template<
typename Index_,
typename OutputValue_>
1078 template<
typename Index_,
typename OutputValue_>
1083 template<
typename Index_,
typename OutputValue_>
1088 template<
typename OutputValue_,
typename Index_>
1106template<
typename InputValue_ =
double>
1112 static constexpr bool is_basic =
false;
1114 bool is_sparse()
const {
1122 template<
typename Index_,
typename OutputValue_>
1125 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1138 template<
typename Index_,
typename OutputValue_>
1143 template<
typename Index_,
typename OutputValue_>
1148 template<
typename Index_,
typename OutputValue_>
1153 template<
typename OutputValue_,
typename Index_>
1171template<
typename InputValue_ =
double>
1177 static constexpr bool is_basic =
false;
1179 bool is_sparse()
const {
1187 template<
typename Index_,
typename OutputValue_>
1190 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1203 template<
typename Index_,
typename OutputValue_>
1208 template<
typename Index_,
typename OutputValue_>
1213 template<
typename Index_,
typename OutputValue_>
1218 template<
typename OutputValue_,
typename Index_>
1236template<
typename InputValue_ =
double>
1242 static constexpr bool is_basic =
false;
1244 bool is_sparse()
const {
1252 template<
typename Index_,
typename OutputValue_>
1255 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1268 template<
typename Index_,
typename OutputValue_>
1273 template<
typename Index_,
typename OutputValue_>
1278 template<
typename Index_,
typename OutputValue_>
1283 template<
typename OutputValue_,
typename Index_>
1301template<
typename InputValue_ =
double>
1307 static constexpr bool is_basic =
false;
1309 bool is_sparse()
const {
1317 template<
typename Index_,
typename OutputValue_>
1320 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1333 template<
typename Index_,
typename OutputValue_>
1338 template<
typename Index_,
typename OutputValue_>
1343 template<
typename Index_,
typename OutputValue_>
1348 template<
typename OutputValue_,
typename Index_>
1366template<
typename InputValue_ =
double>
1372 static constexpr bool is_basic =
false;
1374 bool is_sparse()
const {
1382 template<
typename Index_,
typename OutputValue_>
1385 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1398 template<
typename Index_,
typename OutputValue_>
1403 template<
typename Index_,
typename OutputValue_>
1408 template<
typename Index_,
typename OutputValue_>
1413 template<
typename OutputValue_,
typename Index_>
1431template<
typename InputValue_ =
double>
1437 static constexpr bool is_basic =
false;
1439 bool is_sparse()
const {
1447 template<
typename Index_,
typename OutputValue_>
1450 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1463 template<
typename Index_,
typename OutputValue_>
1468 template<
typename Index_,
typename OutputValue_>
1473 template<
typename Index_,
typename OutputValue_>
1478 template<
typename OutputValue_,
typename Index_>
1496template<
typename InputValue_ =
double>
1502 static constexpr bool is_basic =
false;
1504 bool is_sparse()
const {
1512 template<
typename Index_,
typename OutputValue_>
1515 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1528 template<
typename Index_,
typename OutputValue_>
1533 template<
typename Index_,
typename OutputValue_>
1538 template<
typename Index_,
typename OutputValue_>
1543 template<
typename OutputValue_,
typename Index_>
1561template<
typename InputValue_ =
double>
1567 static constexpr bool is_basic =
false;
1569 bool is_sparse()
const {
1577 template<
typename Index_,
typename OutputValue_>
1580 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1593 template<
typename Index_,
typename OutputValue_>
1598 template<
typename Index_,
typename OutputValue_>
1603 template<
typename Index_,
typename OutputValue_>
1608 template<
typename OutputValue_,
typename Index_>
1627template<
typename InputValue_ =
double>
1633 static constexpr bool is_basic =
false;
1635 bool is_sparse()
const {
1643 template<
typename Index_,
typename OutputValue_>
1646 if constexpr(std::is_same<InputValue_, OutputValue_>::value) {
1659 template<
typename Index_,
typename OutputValue_>
1664 template<
typename Index_,
typename OutputValue_>
1669 template<
typename Index_,
typename OutputValue_>
1674 template<
typename OutputValue_,
typename Index_>
Take the absolute value of a matrix entry.
Definition math_helpers.hpp:24
Take the inverse cosine of a matrix entry.
Definition math_helpers.hpp:780
Take the inverse hyperbolic cosine of a matrix entry.
Definition math_helpers.hpp:846
Take the inverse sine of a matrix entry.
Definition math_helpers.hpp:912
Take the inverse hyperbolic sine of a matrix entry.
Definition math_helpers.hpp:977
Take the inverse tangent of a matrix entry.
Definition math_helpers.hpp:1042
Take the inverse hyperbolic tangent of a matrix entry.
Definition math_helpers.hpp:1107
Take the ceiling of a matrix entry.
Definition math_helpers.hpp:311
Take the cosine of a matrix entry.
Definition math_helpers.hpp:1172
Take the hyperbolic cosine of a matrix entry.
Definition math_helpers.hpp:1237
Use a matrix entry as an exponent.
Definition math_helpers.hpp:650
Use a matrix entry as an exponent minus 1.
Definition math_helpers.hpp:715
Take the floor of a matrix entry.
Definition math_helpers.hpp:376
Apply the gamma function to a matrix entry.
Definition math_helpers.hpp:1562
Apply the log-gamma function to a matrix entry.
Definition math_helpers.hpp:1628
Take the logarithm of a matrix entry plus 1.
Definition math_helpers.hpp:507
DelayedUnaryIsometricLog1p(Base_ base)
Definition math_helpers.hpp:517
DelayedUnaryIsometricLog1p()
Definition math_helpers.hpp:512
Take the logarithm of a matrix entry.
Definition math_helpers.hpp:167
DelayedUnaryIsometricLog()
Definition math_helpers.hpp:172
DelayedUnaryIsometricLog(Base_ base)
Definition math_helpers.hpp:177
Round a matrix entry to the nearest integer.
Definition math_helpers.hpp:585
Take the sign of a matrix entry.
Definition math_helpers.hpp:92
Take the sine of a matrix entry.
Definition math_helpers.hpp:1302
Take the hyperbolic sine of a matrix entry.
Definition math_helpers.hpp:1367
Take the square root of a matrix entry.
Definition math_helpers.hpp:246
Take the tangent of a matrix entry.
Definition math_helpers.hpp:1432
Take the hyperbolic tangent of a matrix entry.
Definition math_helpers.hpp:1497
Integer truncation of a matrix entry.
Definition math_helpers.hpp:441
Flexible representations for matrix data.
Definition Extractor.hpp:15
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35