diff --git a/include/tatami/isometric/arith_utils.hpp b/include/tatami/isometric/arithmetic_utils.hpp similarity index 64% rename from include/tatami/isometric/arith_utils.hpp rename to include/tatami/isometric/arithmetic_utils.hpp index 88ae3f24..d0dd6b88 100644 --- a/include/tatami/isometric/arith_utils.hpp +++ b/include/tatami/isometric/arithmetic_utils.hpp @@ -1,10 +1,10 @@ -#ifndef TATAMI_ARITH_UTILS_HPP -#define TATAMI_ARITH_UTILS_HPP +#ifndef TATAMI_ARITHMETIC_UTILS_HPP +#define TATAMI_ARITHMETIC_UTILS_HPP #include /** - * @file arith_utils.hpp + * @file arithmetic_utils.hpp * * @brief Utilities for delayed arithmetic operations. */ @@ -12,9 +12,9 @@ namespace tatami { /** - * Type of the delayed arithmetic operation. + * Type of arithmetic operation. */ -enum class DelayedArithOp : char { +enum class ArithmeticOperation : char { ADD, SUBTRACT, MULTIPLY, @@ -27,19 +27,19 @@ enum class DelayedArithOp : char { /** * @cond */ -template -void delayed_arith_run(Value_& val, Scalar_ scalar) { - if constexpr(op_ == DelayedArithOp::ADD) { +template +void delayed_arithmetic_run(Value_& val, Scalar_ scalar) { + if constexpr(op_ == ArithmeticOperation::ADD) { val += scalar; - } else if constexpr(op_ == DelayedArithOp::MULTIPLY) { + } else if constexpr(op_ == ArithmeticOperation::MULTIPLY) { val *= scalar; - } else if constexpr(op_ == DelayedArithOp::SUBTRACT) { + } else if constexpr(op_ == ArithmeticOperation::SUBTRACT) { if constexpr(right_) { val -= scalar; } else { val = scalar - val; } - } else if constexpr(op_ == DelayedArithOp::DIVIDE) { + } else if constexpr(op_ == ArithmeticOperation::DIVIDE) { // Assume that either Value_ is an IEEE-754 float, or that division by // zero is impossible in this context. We don't apply manual checks // here to avoid performance degradation; we also don't check that the @@ -50,19 +50,19 @@ void delayed_arith_run(Value_& val, Scalar_ scalar) { } else { val = scalar / val; } - } else if constexpr(op_ == DelayedArithOp::POWER) { + } else if constexpr(op_ == ArithmeticOperation::POWER) { if constexpr(right_) { val = std::pow(val, scalar); } else { val = std::pow(scalar, val); } - } else if constexpr(op_ == DelayedArithOp::MODULO) { + } else if constexpr(op_ == ArithmeticOperation::MODULO) { if constexpr(right_) { val = std::fmod(val, scalar); } else { val = std::fmod(scalar, val); } - } else if constexpr(op_ == DelayedArithOp::INTEGER_DIVIDE) { + } else if constexpr(op_ == ArithmeticOperation::INTEGER_DIVIDE) { if constexpr(right_) { val = std::floor(val / scalar); } else { diff --git a/include/tatami/isometric/binary/DelayedBinaryIsometricOp.hpp b/include/tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp similarity index 92% rename from include/tatami/isometric/binary/DelayedBinaryIsometricOp.hpp rename to include/tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp index 0e6544a9..cdbc4ac4 100644 --- a/include/tatami/isometric/binary/DelayedBinaryIsometricOp.hpp +++ b/include/tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OP_H -#define TATAMI_DELAYED_BINARY_ISOMETRIC_OP_H +#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H +#define TATAMI_DELAYED_BINARY_ISOMETRIC_OPERATION_H #include "../../base/Matrix.hpp" #include "../../utils/new_extractor.hpp" @@ -14,8 +14,6 @@ * @file DelayedBinaryIsometricOp.hpp * * @brief Delayed binary isometric operations. - * - * This is equivalent to the class of the same name in the **DelayedArray** package. */ namespace tatami { @@ -23,7 +21,7 @@ namespace tatami { /** * @cond */ -namespace DelayedBinaryIsometricOp_internal { +namespace DelayedBinaryIsometricOperation_internal { template class MaybeOracleDepends { @@ -488,23 +486,25 @@ class Sparse : public SparseExtractor { * * Implements any operation that takes two matrices of the same shape and returns another matrix of that shape. * Each entry of the output matrix is a function of the corresponding values in the two input matrices. - * This operation is "delayed" in that it is only evaluated on request, e.g., with `DenseExtractor::fetch()` or friends. + * This operation is "delayed" in that it is only evaluated during data extraction, e.g., with `MyopicDenseExtractor::fetch()` or friends. + * + * This class is inspired by the `DelayedNaryIsoOp` class in the **DelayedArray** Bioconductor package. * * @tparam Value_ Type of matrix value. * @tparam Index_ Type of index value. - * @tparam Operation_ Class implementing the operation. - * This should implement the same methods as `DelayedBinaryBasicMockHelper` or `DelayedBinaryAdvancedMockHelper`, + * @tparam Operation_ Helper class implementing the operation. + * This should implement the same methods as `DelayedBinaryIsometricMockBasic` or `DelayedBinaryIsometricMockAdvanced`, * depending on whether it can take advantage of matrix sparsity. */ template -class DelayedBinaryIsometricOp : public Matrix { +class DelayedBinaryIsometricOperation : public Matrix { public: /** * @param left Pointer to the left matrix. * @param right Pointer to the right matrix. * @param operation Instance of the functor class. */ - DelayedBinaryIsometricOp(std::shared_ptr > left, std::shared_ptr > right, Operation_ operation) : + DelayedBinaryIsometricOperation(std::shared_ptr > left, std::shared_ptr > right, Operation_ operation) : my_left(std::move(left)), my_right(std::move(right)), my_operation(std::move(operation)) { if (my_left->nrow() != my_right->nrow() || my_left->ncol() != my_right->ncol()) { @@ -572,7 +572,7 @@ class DelayedBinaryIsometricOp : public Matrix { private: template std::unique_ptr > dense_simple_internal(bool row, MaybeOracle oracle, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -584,7 +584,7 @@ class DelayedBinaryIsometricOp : public Matrix { template std::unique_ptr > dense_simple_internal(bool row, MaybeOracle oracle, Index_ block_start, Index_ block_length, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -598,7 +598,7 @@ class DelayedBinaryIsometricOp : public Matrix { template std::unique_ptr > dense_simple_internal(bool row, MaybeOracle oracle, VectorPtr indices_ptr, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -611,7 +611,7 @@ class DelayedBinaryIsometricOp : public Matrix { template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -623,7 +623,7 @@ class DelayedBinaryIsometricOp : public Matrix { template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, Index_ block_start, Index_ block_length, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -637,7 +637,7 @@ class DelayedBinaryIsometricOp : public Matrix { template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, VectorPtr indices_ptr, const Options& opt) const { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -684,7 +684,7 @@ class DelayedBinaryIsometricOp : public Matrix { std::unique_ptr > sparse_internal(bool row, MaybeOracle oracle, const Options& opt) const { if constexpr(is_advanced) { if (my_is_sparse) { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -706,7 +706,7 @@ class DelayedBinaryIsometricOp : public Matrix { std::unique_ptr > sparse_internal(bool row, MaybeOracle oracle, Index_ block_start, Index_ block_length, const Options& opt) const { if constexpr(is_advanced) { if (my_is_sparse) { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -731,7 +731,7 @@ class DelayedBinaryIsometricOp : public Matrix { std::unique_ptr > sparse_internal(bool row, MaybeOracle oracle, VectorPtr indices_ptr, const Options& opt) const { if constexpr(is_advanced) { if (my_is_sparse) { - return std::make_unique >( + return std::make_unique >( my_left.get(), my_right.get(), my_operation, @@ -810,9 +810,9 @@ class DelayedBinaryIsometricOp : public Matrix { * @return Instance of a `DelayedBinaryIsometricOp` clas. */ template -std::shared_ptr > make_DelayedBinaryIsometricOp(std::shared_ptr > left, std::shared_ptr > right, Operation_ op) { - typedef typename std::remove_reference::type Op_; - return std::shared_ptr >(new DelayedBinaryIsometricOp(std::move(left), std::move(right), std::move(op))); +std::shared_ptr > make_DelayedBinaryIsometricOperation(std::shared_ptr > left, std::shared_ptr > right, Operation_ op) { + typedef typename std::remove_reference::type Operation2_; + return std::shared_ptr >(new DelayedBinaryIsometricOperation(std::move(left), std::move(right), std::move(op))); } /** @@ -820,9 +820,9 @@ std::shared_ptr > make_DelayedBinaryIsometricOp(std::shar */ // For automatic template deduction with non-const pointers. template -std::shared_ptr > make_DelayedBinaryIsometricOp(std::shared_ptr > left, std::shared_ptr > right, Operation_ op) { - typedef typename std::remove_reference::type Op_; - return std::shared_ptr >(new DelayedBinaryIsometricOp(std::move(left), std::move(right), std::move(op))); +std::shared_ptr > make_DelayedBinaryIsometricOperation(std::shared_ptr > left, std::shared_ptr > right, Operation_ op) { + typedef typename std::remove_reference::type Operation2_; + return std::shared_ptr >(new DelayedBinaryIsometricOperation(std::move(left), std::move(right), std::move(op))); } /** * @endcond @@ -830,7 +830,7 @@ std::shared_ptr > make_DelayedBinaryIsometricOp(std::shar } -#include "arith_helpers.hpp" +#include "arithmetic_helpers.hpp" #include "compare_helpers.hpp" diff --git a/include/tatami/isometric/binary/arith_helpers.hpp b/include/tatami/isometric/binary/arith_helpers.hpp deleted file mode 100644 index 76da5187..00000000 --- a/include/tatami/isometric/binary/arith_helpers.hpp +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef TATAMI_BINARY_ARITH_HELPERS_H -#define TATAMI_BINARY_ARITH_HELPERS_H - -#include "../arith_utils.hpp" -#include "utils.hpp" -#include -#include - -/** - * @file arith_helpers.hpp - * - * @brief Helper classes for binary arithmetic operations. - */ - -namespace tatami { - -/** - * @brief Delayed binary arithmetic. - * - * This should be used as the `Operation_` in the `DelayedBinaryIsometricOp` class. - * - * @tparam op_ The arithmetic operation. - */ -template -class DelayedBinaryArithHelper { -public: - /** - * @cond - */ - static constexpr bool known_sparse = (op_ == DelayedArithOp::ADD || - op_ == DelayedArithOp::SUBTRACT || - op_ == DelayedArithOp::MULTIPLY); - - static constexpr bool zero_depends_on_row = false; - - static constexpr bool zero_depends_on_column = false; - /** - * @endcond - */ - -public: - /** - * @cond - */ - template - void dense(bool, Index_, Index_, Index_ length, Value_* left_buffer, const Value_* right_buffer) const { - for (Index_ i = 0; i < length; ++i) { - delayed_arith_run(left_buffer[i], right_buffer[i]); - } - } - - template - void dense(bool, Index_, const std::vector& indices, Value_* left_buffer, const Value_* right_buffer) const { - for (Index_ i = 0, length = indices.size(); i < length; ++i) { - delayed_arith_run(left_buffer[i], right_buffer[i]); - } - } - - template - Index_ sparse(bool, Index_, const SparseRange& left, const SparseRange& right, Value_* value_buffer, Index_* index_buffer, bool needs_value, bool needs_index) const { - // Don't bother storing an explicit zero for MULTIPLY operations when either entry is zero. - constexpr bool must_have_both = (op_ == DelayedArithOp::MULTIPLY); - return delayed_binary_isometric_sparse_operation( - left, - right, - value_buffer, - index_buffer, - needs_value, - needs_index, - [](Value_& l, Value_ r) { delayed_arith_run(l, r); } - ); - } - - template - Value_ fill(Index_) const { - if constexpr(known_sparse) { - return 0; - } else if constexpr(op_ == DelayedArithOp::POWER) { - return 1; - } else { - // Zero divided/modulo by zero gives NaN. - return std::numeric_limits::quiet_NaN(); - } - } - - bool is_sparse() const { - return known_sparse; - } - /** - * @endcond - */ -}; - -/** - * @return A helper class for delayed binary addition. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryAddHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary subtraction. - */ -inline DelayedBinaryArithHelper make_DelayedBinarySubtractHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary multiplication. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryMultiplyHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary division. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryDivideHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary power. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryPowerHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary modulo. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryModuloHelper() { - return DelayedBinaryArithHelper(); -} - -/** - * @return A helper class for delayed binary integer division. - */ -inline DelayedBinaryArithHelper make_DelayedBinaryIntegerDivideHelper() { - return DelayedBinaryArithHelper(); -} - -} - -#endif diff --git a/include/tatami/isometric/binary/arithmetic_helpers.hpp b/include/tatami/isometric/binary/arithmetic_helpers.hpp new file mode 100644 index 00000000..692cd52c --- /dev/null +++ b/include/tatami/isometric/binary/arithmetic_helpers.hpp @@ -0,0 +1,150 @@ +#ifndef TATAMI_ISOMETRIC_BINARY_ARITHMETIC_HELPERS_H +#define TATAMI_ISOMETRIC_BINARY_ARITHMETIC_HELPERS_H + +#include "../arithmetic_utils.hpp" +#include "utils.hpp" +#include +#include + +/** + * @file arithmetic_helpers.hpp + * + * @brief Helper classes for binary arithmetic operations. + */ + +namespace tatami { + +/** + * @brief Delayed binary isometric arithmetic. + * + * This should be used as the `Operation_` in the `DelayedBinaryIsometricOperation` class. + * + * @tparam op_ The arithmetic operation. + */ +template +class DelayedBinaryIsometricArithmetic { +public: + /** + * @cond + */ + static constexpr bool known_sparse = (op_ == ArithmeticOperation::ADD || + op_ == ArithmeticOperation::SUBTRACT || + op_ == ArithmeticOperation::MULTIPLY); + + static constexpr bool zero_depends_on_row = false; + + static constexpr bool zero_depends_on_column = false; + /** + * @endcond + */ + +public: + /** + * @cond + */ + template + void dense(bool, Index_, Index_, Index_ length, Value_* left_buffer, const Value_* right_buffer) const { + for (Index_ i = 0; i < length; ++i) { + delayed_arithmetic_run(left_buffer[i], right_buffer[i]); + } + } + + template + void dense(bool, Index_, const std::vector& indices, Value_* left_buffer, const Value_* right_buffer) const { + for (Index_ i = 0, length = indices.size(); i < length; ++i) { + delayed_arithmetic_run(left_buffer[i], right_buffer[i]); + } + } + + template + Index_ sparse(bool, Index_, const SparseRange& left, const SparseRange& right, Value_* value_buffer, Index_* index_buffer, bool needs_value, bool needs_index) const { + // Don't bother storing an explicit zero for MULTIPLY operations when either entry is zero. + constexpr bool must_have_both = (op_ == ArithmeticOperation::MULTIPLY); + return delayed_binary_isometric_sparse_operation( + left, + right, + value_buffer, + index_buffer, + needs_value, + needs_index, + [](Value_& l, Value_ r) { delayed_arithmetic_run(l, r); } + ); + } + + template + Value_ fill(Index_) const { + if constexpr(known_sparse) { + return 0; + } else if constexpr(op_ == ArithmeticOperation::POWER) { + return 1; + } else { + // Zero divided/modulo by zero gives NaN. + return std::numeric_limits::quiet_NaN(); + } + } + + bool is_sparse() const { + return known_sparse; + } + /** + * @endcond + */ +}; + +/** + * @return A helper class for delayed binary addition, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricAdd() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary subtraction, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricSubtract() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary multiplication, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricMultiply() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary division, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricDivide() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary power, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricPower() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary modulo. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricModulo() { + return DelayedBinaryIsometricArithmetic(); +} + +/** + * @return A helper class for delayed binary integer division. + */ +inline DelayedBinaryIsometricArithmetic make_DelayedBinaryIsometricIntegerDivide() { + return DelayedBinaryIsometricArithmetic(); +} + +} + +#endif diff --git a/include/tatami/isometric/binary/boolean_helpers.hpp b/include/tatami/isometric/binary/boolean_helpers.hpp index d54761fa..35f44528 100644 --- a/include/tatami/isometric/binary/boolean_helpers.hpp +++ b/include/tatami/isometric/binary/boolean_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_BINARY_BOOLEAN_HELPERS_H -#define TATAMI_BINARY_BOOLEAN_HELPERS_H +#ifndef TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H +#define TATAMI_ISOMETRIC_BINARY_BOOLEAN_HELPERS_H #include "../boolean_utils.hpp" #include "utils.hpp" @@ -13,20 +13,20 @@ namespace tatami { /** - * @brief Delayed binary boolean operations. + * @brief Delayed binary isometric boolean operations. * - * This should be used as the `Operation_` in the `DelayedBinaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedBinaryIsometricOperation` class. * * @tparam op_ The boolean operation. */ -template -struct DelayedBinaryBooleanHelper { +template +struct DelayedBinaryIsometricBoolean { public: /** * @cond */ // It's sparse if f(0, 0) == 0. - static constexpr bool known_sparse = (op_ != DelayedBooleanOp::EQUAL); + static constexpr bool known_sparse = (op_ != BooleanOperation::EQUAL); static constexpr bool zero_depends_on_row = false; @@ -56,7 +56,7 @@ struct DelayedBinaryBooleanHelper { template Index_ sparse(bool, Index_, const SparseRange& left, const SparseRange& right, Value_* value_buffer, Index_* index_buffer, bool needs_value, bool needs_index) const { // Don't bother storing an explicit zero for AND operations when either entry is zero. - constexpr bool must_have_both = (op_ == DelayedBooleanOp::AND); + constexpr bool must_have_both = (op_ == BooleanOperation::AND); return delayed_binary_isometric_sparse_operation( left, right, @@ -86,31 +86,35 @@ struct DelayedBinaryBooleanHelper { }; /** - * @return A helper class for a delayed binary boolean equivalence operation. + * @return A helper class for a delayed binary boolean equivalence operation, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryBooleanHelper make_DelayedBinaryBooleanEqualHelper() { - return DelayedBinaryBooleanHelper(); +inline DelayedBinaryIsometricBoolean make_DelayedBinaryIsometricBooleanEqual() { + return DelayedBinaryIsometricBoolean(); } /** - * @return A helper class for a delayed binary AND comparison. + * @return A helper class for a delayed binary AND comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryBooleanHelper make_DelayedBinaryBooleanAndHelper() { - return DelayedBinaryBooleanHelper(); +inline DelayedBinaryIsometricBoolean make_DelayedBinaryIsometricBooleanAnd() { + return DelayedBinaryIsometricBoolean(); } /** - * @return A helper class for a delayed binary OR comparison. + * @return A helper class for a delayed binary OR comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryBooleanHelper make_DelayedBinaryBooleanOrHelper() { - return DelayedBinaryBooleanHelper(); +inline DelayedBinaryIsometricBoolean make_DelayedBinaryIsometricBooleanOr() { + return DelayedBinaryIsometricBoolean(); } /** - * @return A helper class for a delayed binary XOR comparison. + * @return A helper class for a delayed binary XOR comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryBooleanHelper make_DelayedBinaryBooleanXorHelper() { - return DelayedBinaryBooleanHelper(); +inline DelayedBinaryIsometricBoolean make_DelayedBinaryIsometricBooleanXor() { + return DelayedBinaryIsometricBoolean(); } } diff --git a/include/tatami/isometric/binary/compare_helpers.hpp b/include/tatami/isometric/binary/compare_helpers.hpp index 3a05fa96..4e1b40d3 100644 --- a/include/tatami/isometric/binary/compare_helpers.hpp +++ b/include/tatami/isometric/binary/compare_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_BINARY_COMPARE_HELPERS_H -#define TATAMI_BINARY_COMPARE_HELPERS_H +#ifndef TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H +#define TATAMI_ISOMETRIC_BINARY_COMPARE_HELPERS_H #include "../compare_utils.hpp" #include "utils.hpp" @@ -13,22 +13,22 @@ namespace tatami { /** - * @brief Delayed binary comparison. + * @brief Delayed binary isometric comparison. * - * This should be used as the `Operation_` in the `DelayedBinaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedBinaryIsometricOperation` class. * * @tparam op_ The comparison operation. */ -template -struct DelayedBinaryCompareHelper { +template +struct DelayedBinaryIsometricCompare { public: /** * @cond */ // It's sparse if f(0, 0) == 0. - static constexpr bool known_sparse = (op_ != DelayedCompareOp::EQUAL && - op_ != DelayedCompareOp::GREATER_THAN_OR_EQUAL && - op_ != DelayedCompareOp::LESS_THAN_OR_EQUAL); + static constexpr bool known_sparse = (op_ != CompareOperation::EQUAL && + op_ != CompareOperation::GREATER_THAN_OR_EQUAL && + op_ != CompareOperation::LESS_THAN_OR_EQUAL); static constexpr bool zero_depends_on_row = false; @@ -93,45 +93,51 @@ struct DelayedBinaryCompareHelper { }; /** - * @return A helper class for a delayed binary equality comparison. + * @return A helper class for a delayed binary equality comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryEqualHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricEqual() { + return DelayedBinaryIsometricCompare(); } /** - * @return A helper class for a delayed binary greater-than comparison. + * @return A helper class for a delayed binary greater-than comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryGreaterThanHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricGreaterThan() { + return DelayedBinaryIsometricCompare(); } /** - * @return A helper class for a delayed binary less-than comparison. + * @return A helper class for a delayed binary less-than comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryLessThanHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricLessThan() { + return DelayedBinaryIsometricCompare(); } /** - * @return A helper class for a delayed binary greater-than-or-equal comparison. + * @return A helper class for a delayed binary greater-than-or-equal comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryGreaterThanOrEqualHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricGreaterThanOrEqual() { + return DelayedBinaryIsometricCompare(); } /** - * @return A helper class for a delayed binary less-than-or-equal comparison. + * @return A helper class for a delayed binary less-than-or-equal comparison, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryLessThanOrEqualHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricLessThanOrEqual() { + return DelayedBinaryIsometricCompare(); } /** - * @return A helper class for a delayed binary non-equality comparison to a scalar. + * @return A helper class for a delayed binary non-equality comparison to a scalar, + * to be used as the `operation` in a `DelayedBinaryIsometricOperation`. */ -inline DelayedBinaryCompareHelper make_DelayedBinaryNotEqualHelper() { - return DelayedBinaryCompareHelper(); +inline DelayedBinaryIsometricCompare make_DelayedBinaryIsometricNotEqual() { + return DelayedBinaryIsometricCompare(); } } diff --git a/include/tatami/isometric/binary/mock_helpers.hpp b/include/tatami/isometric/binary/mock_helpers.hpp index e7d22211..f6d438ab 100644 --- a/include/tatami/isometric/binary/mock_helpers.hpp +++ b/include/tatami/isometric/binary/mock_helpers.hpp @@ -1,25 +1,25 @@ -#ifndef TATAMI_DELAYED_BINARY_ISOMETRIC_OP_HELPER_INTERFACE_H -#define TATAMI_DELAYED_BINARY_ISOMETRIC_OP_HELPER_INTERFACE_H +#ifndef TATAMI_ISOMETRIC_BINARY_MOCK_HELPERS_H +#define TATAMI_ISOMETRIC_BINARY_MOCK_HELPERS_H #include #include "../../base/SparseRange.hpp" /** * @file mock_helpers.hpp - * @brief Expectations for `tatami::DelayedBinaryIsometricOp` helpers. + * @brief Expectations for `tatami::DelayedBinaryIsometricOperation` helpers. */ namespace tatami { /** - * @brief Basic mock operation for `DelayedBinaryIsometricOp`. + * @brief Basic mock operation for `DelayedBinaryIsometricOperation`. * - * This class defines the basic expectations for an operation in `DelayedBinaryIsometricOp`. + * This class defines the basic expectations for an operation in `DelayedBinaryIsometricOperation`. * Actual operations aren't expected to inherit from this class; * this is only provided for documentation purposes. * Operations only need to implement methods with the same signatures for compile-time polymorphism. */ -class DelayedBinaryBasicMockHelper { +class DelayedBinaryIsometricMockBasic { public: /** * This method should apply the operation to corresponding values of `left_buffer` and `right_buffer`. @@ -90,21 +90,21 @@ class DelayedBinaryBasicMockHelper { /** * Conversion of zeros to non-zero values is dependent on rows. - * This should be `true`, otherwise an advanced operation is expected (see `DelayedBinaryAdvancedMockHelper`). + * This should be `true`, otherwise an advanced operation is expected (see `DelayedBinaryIsometricMockAdvanced`). */ static constexpr bool zero_depends_on_row = true; /** * Conversion of zeros to non-zero values is dependent on columns. - * This should be `true`, otherwise an advanced operation is expected (see `DelayedBinaryAdvancedMockHelper`). + * This should be `true`, otherwise an advanced operation is expected (see `DelayedBinaryIsometricMockAdvanced`). */ static constexpr bool zero_depends_on_column = true; }; /** - * @brief Advanced mock operation for `DelayedBinaryIsometricOp`. + * @brief Advanced mock operation for `DelayedBinaryIsometricOperation`. * - * This class defines the advanced expectations for an operation in `DelayedBinaryIsometricOp`, + * This class defines the advanced expectations for an operation in `DelayedBinaryIsometricOperation`, * which improves efficiency by taking advantage of any sparsity in the underlying matrices. * Either the operation itself preserves sparsity, or any loss of sparsity is predictable, * i.e., zeros are transformed into a constant non-zero value that does not depend on its position in the `Matrix`. @@ -113,7 +113,7 @@ class DelayedBinaryBasicMockHelper { * this is only provided for documentation purposes. * Operations only need to implement methods with the same signatures for compile-time polymorphism. */ -class DelayedBinaryAdvancedMockHelper { +class DelayedBinaryIsometricMockAdvanced { public: /** * @tparam Value_ Type of matrix value. @@ -137,14 +137,18 @@ class DelayedBinaryAdvancedMockHelper { /** * Conversion of zeros to non-zero values is not dependent on rows. * Implementations of the advanced operation interface may set this to `true` provided that `zero_depends_on_column = false`; - * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedBinaryBasicMockHelper`). + * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedBinaryIsometricMockBasic`). + * + * This value is only used when `is_sparse()` returns false. */ static constexpr bool zero_depends_on_row = false; /** * Conversion of zeros to non-zero values is not dependent on columns. * Implementations of the advanced operation interface may set this to `true` provided that `zero_depends_on_row = false`; - * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedBinaryBasicMockHelper`). + * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedBinaryIsometricMockBasic`). + * + * This value is only used when `is_sparse()` returns false. */ static constexpr bool zero_depends_on_column = false; diff --git a/include/tatami/isometric/binary/utils.hpp b/include/tatami/isometric/binary/utils.hpp index ddbaf519..18e4ff93 100644 --- a/include/tatami/isometric/binary/utils.hpp +++ b/include/tatami/isometric/binary/utils.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_BINARY_HELPER_UTILS_H -#define TATAMI_BINARY_HELPER_UTILS_H +#ifndef TATAMI_ISOMETRIC_BINARY_HELPER_UTILS_H +#define TATAMI_ISOMETRIC_BINARY_HELPER_UTILS_H namespace tatami { diff --git a/include/tatami/isometric/boolean_utils.hpp b/include/tatami/isometric/boolean_utils.hpp index abc1e063..adbde8a4 100644 --- a/include/tatami/isometric/boolean_utils.hpp +++ b/include/tatami/isometric/boolean_utils.hpp @@ -10,9 +10,9 @@ namespace tatami { /** - * Type of the delayed boolean operation. + * Type of boolean operation. */ -enum class DelayedBooleanOp : char { +enum class BooleanOperation : char { AND, OR, XOR, @@ -22,13 +22,13 @@ enum class DelayedBooleanOp : char { /** * @cond */ -template +template void delayed_boolean_run(Value_& val, bool scalar) { - if constexpr(op_ == DelayedBooleanOp::AND) { + if constexpr(op_ == BooleanOperation::AND) { val = val && scalar; - } else if constexpr(op_ == DelayedBooleanOp::OR) { + } else if constexpr(op_ == BooleanOperation::OR) { val = val || scalar; - } else if constexpr(op_ == DelayedBooleanOp::XOR) { + } else if constexpr(op_ == BooleanOperation::XOR) { val = static_cast(val) != scalar; } else { // EQUAL. val = static_cast(val) == scalar; diff --git a/include/tatami/isometric/compare_utils.hpp b/include/tatami/isometric/compare_utils.hpp index 69fb303c..5dbb51ed 100644 --- a/include/tatami/isometric/compare_utils.hpp +++ b/include/tatami/isometric/compare_utils.hpp @@ -10,9 +10,9 @@ namespace tatami { /** - * Type of the delayed comparison operation. + * Type of comparison operation. */ -enum class DelayedCompareOp : char { +enum class CompareOperation : char { EQUAL, GREATER_THAN, LESS_THAN, @@ -24,17 +24,17 @@ enum class DelayedCompareOp : char { /** * @cond */ -template +template void delayed_compare_run(Value_& val, Scalar_ scalar) { - if constexpr(op_ == DelayedCompareOp::EQUAL) { + if constexpr(op_ == CompareOperation::EQUAL) { val = val == scalar; - } else if constexpr(op_ == DelayedCompareOp::GREATER_THAN) { + } else if constexpr(op_ == CompareOperation::GREATER_THAN) { val = val > scalar; - } else if constexpr(op_ == DelayedCompareOp::LESS_THAN) { + } else if constexpr(op_ == CompareOperation::LESS_THAN) { val = val < scalar; - } else if constexpr(op_ == DelayedCompareOp::GREATER_THAN_OR_EQUAL) { + } else if constexpr(op_ == CompareOperation::GREATER_THAN_OR_EQUAL) { val = val >= scalar; - } else if constexpr(op_ == DelayedCompareOp::LESS_THAN_OR_EQUAL) { + } else if constexpr(op_ == CompareOperation::LESS_THAN_OR_EQUAL) { val = val <= scalar; } else { // NOT EQUAL. val = val != scalar; diff --git a/include/tatami/isometric/unary/DelayedUnaryIsometricOp.hpp b/include/tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp similarity index 89% rename from include/tatami/isometric/unary/DelayedUnaryIsometricOp.hpp rename to include/tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp index 91c6bce0..7273ae44 100644 --- a/include/tatami/isometric/unary/DelayedUnaryIsometricOp.hpp +++ b/include/tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_DELAYED_UNARY_ISOMETRIC_OP_H -#define TATAMI_DELAYED_UNARY_ISOMETRIC_OP_H +#ifndef TATAMI_DELAYED_UNARY_ISOMETRIC_OPERATION_H +#define TATAMI_DELAYED_UNARY_ISOMETRIC_OPERATION_H #include "../../base/Matrix.hpp" #include "../../utils/copy.hpp" @@ -10,11 +10,9 @@ #include /** - * @file DelayedUnaryIsometricOp.hpp + * @file DelayedUnaryIsometricOperation.hpp * * @brief Delayed unary isometric operations. - * - * This is equivalent to the class of the same name in the **DelayedArray** package. */ namespace tatami { @@ -22,7 +20,7 @@ namespace tatami { /** * @cond */ -namespace DelayedUnaryIsometricOp_internal { +namespace DelayedUnaryIsometricOperation_internal { template class MaybeOracleDepends { @@ -541,27 +539,28 @@ class SparseNeedsIndices : public SparseExtractor { */ /** - * @brief Delayed isometric operations on a single matrix. + * @brief Delayed isometric operation on a single matrix. * * Implements any operation that preserves the shape of the matrix and operates on each matrix value independently. * This operation is "delayed" in that it is only evaluated during data extraction, e.g., with `MyopicDenseExtractor::fetch()` or friends. - * We only consider "unary" operations that involve a single `Matrix` - see `DelayedBinaryIsometricOp` for operations between two `Matrix` instances. + * We only consider "unary" operations that involve a single `Matrix` - see `DelayedBinaryIsometricOperation` for operations between two `Matrix` instances. + * + * This class is inspired by the `DelayedUnaryIsoOp` classes from the **DelayedArray** Bioconductor package. * * @tparam Value_ Type of matrix value. * @tparam Index_ Type of index value. - * @tparam Operation_ Class implementing the operation. - * A non-sparsity-preserving operation should implement the same methods as `DelayedUnaryMockVariableDenseHelper` - * or `DelayedUnaryMockConstantDenseHelper` (depending on whether the conversion of zeros to non-zero values is constant), - * while a sparsity-preserving operation should implement the same methods as `DelayedUnaryMockSparseHelper`. + * @tparam Operation_ Helper class implementing the operation. + * This should implement the same methods as `DelayedUnaryIsometricMockBasic` or `DelayedUnaryIsometricMockAdvanced`, + * depending on whether it can take advantage of matrix sparsity. */ template -class DelayedUnaryIsometricOp : public Matrix { +class DelayedUnaryIsometricOperation : public Matrix { public: /** * @param matrix Pointer to the underlying matrix. * @param operation Instance of the functor class. */ - DelayedUnaryIsometricOp(std::shared_ptr > matrix, Operation_ operation) : my_matrix(std::move(matrix)), my_operation(std::move(operation)) {} + DelayedUnaryIsometricOperation(std::shared_ptr > matrix, Operation_ operation) : my_matrix(std::move(matrix)), my_operation(std::move(operation)) {} private: std::shared_ptr > my_matrix; @@ -618,32 +617,32 @@ class DelayedUnaryIsometricOp : public Matrix { private: template std::unique_ptr > dense_basic_internal(bool row, MaybeOracle oracle, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), opt); } template std::unique_ptr > dense_basic_internal(bool row, MaybeOracle oracle, Index_ block_start, Index_ block_length, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), block_start, block_length, opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), block_start, block_length, opt); } template std::unique_ptr > dense_basic_internal(bool row, MaybeOracle oracle, VectorPtr indices_ptr, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), std::move(indices_ptr), opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), std::move(indices_ptr), opt); } template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), opt); } template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, Index_ block_start, Index_ block_length, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), block_start, block_length, opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), block_start, block_length, opt); } template std::unique_ptr > dense_expanded_internal(bool row, MaybeOracle oracle, VectorPtr indices_ptr, const Options& opt) const { - return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), std::move(indices_ptr), opt); + return std::make_unique >(my_matrix.get(), my_operation, row, std::move(oracle), std::move(indices_ptr), opt); } template @@ -713,7 +712,7 @@ class DelayedUnaryIsometricOp : public Matrix { if ((!Operation_::non_zero_depends_on_row && !row) || (!Operation_::non_zero_depends_on_column && row)) { // If we don't depend on the rows, then we don't need row indices when 'row = false'. // Similarly, if we don't depend on columns, then we don't column row indices when 'row = true'. - return std::make_unique >( + return std::make_unique >( my_matrix.get(), my_operation, row, @@ -721,7 +720,7 @@ class DelayedUnaryIsometricOp : public Matrix { std::forward(args)... ); } else { - return std::make_unique >( + return std::make_unique >( my_matrix.get(), my_operation, row, @@ -786,17 +785,17 @@ class DelayedUnaryIsometricOp : public Matrix { * * @tparam Value_ Type of matrix value. * @tparam Index_ Type of index value. - * @tparam Operation_ Helper class defining the operation. + * @tparam Operation_ Helper class implementing the operation. * * @param matrix Pointer to a (possibly `const`) `Matrix`. * @param operation Instance of the operation helper class. * - * @return Instance of a `DelayedUnaryIsometricOp` class. + * @return Instance of a `DelayedUnaryIsometricOperation` class. */ template -std::shared_ptr > make_DelayedUnaryIsometricOp(std::shared_ptr > matrix, Operation_ operation) { - typedef typename std::remove_reference::type Op_; - return std::shared_ptr >(new DelayedUnaryIsometricOp(std::move(matrix), std::move(operation))); +std::shared_ptr > make_DelayedUnaryIsometricOperation(std::shared_ptr > matrix, Operation_ operation) { + typedef typename std::remove_reference::type Operation2_; + return std::shared_ptr >(new DelayedUnaryIsometricOperation(std::move(matrix), std::move(operation))); } /** @@ -804,26 +803,26 @@ std::shared_ptr > make_DelayedUnaryIsometricOp(std::share */ // For automatic template deduction with non-const pointers. template -std::shared_ptr > make_DelayedUnaryIsometricOp(std::shared_ptr > matrix, Operation_ operation) { - typedef typename std::remove_reference::type Op_; - return std::shared_ptr >(new DelayedUnaryIsometricOp(std::move(matrix), std::move(operation))); +std::shared_ptr > make_DelayedUnaryIsometricOperation(std::shared_ptr > matrix, Operation_ operation) { + typedef typename std::remove_reference::type Operation2_; + return std::shared_ptr >(new DelayedUnaryIsometricOperation(std::move(matrix), std::move(operation))); } // For back-compatibility. template -auto make_DelayedIsometricOp(Args_&&... args) { - return make_DelayedUnaryIsometricOp(std::forward(args)...); +auto make_DelayedIsometricOperation(Args_&&... args) { + return make_DelayedUnaryIsometricOperation(std::forward(args)...); } template -using DelayedIsometricOp = DelayedUnaryIsometricOp; +using DelayedIsometricOperation = DelayedUnaryIsometricOperation; /** * @endcond */ } -#include "arith_helpers.hpp" +#include "arithmetic_helpers.hpp" #include "math_helpers.hpp" diff --git a/include/tatami/isometric/unary/arith_helpers.hpp b/include/tatami/isometric/unary/arithmetic_helpers.hpp similarity index 51% rename from include/tatami/isometric/unary/arith_helpers.hpp rename to include/tatami/isometric/unary/arithmetic_helpers.hpp index 565fffb8..b70e873b 100644 --- a/include/tatami/isometric/unary/arith_helpers.hpp +++ b/include/tatami/isometric/unary/arithmetic_helpers.hpp @@ -1,14 +1,14 @@ -#ifndef TATAMI_UNARY_ARITH_HELPERS_H -#define TATAMI_UNARY_ARITH_HELPERS_H +#ifndef TATAMI_ISOMETRIC_UNARY_ARITHMETIC_HELPERS_H +#define TATAMI_ISOMETRIC_UNARY_ARITHMETIC_HELPERS_H -#include "../arith_utils.hpp" +#include "../arithmetic_utils.hpp" #include #include /** - * @file arith_helpers.hpp + * @file arithmetic_helpers.hpp * - * @brief Helper classes for delayed unary arithmetic operations. + * @brief Helper classes for delayed unary isometric arithmetic. */ namespace tatami { @@ -16,21 +16,21 @@ namespace tatami { /** * @cond */ -template -void delayed_arith_run_simple(Scalar_ scalar, Index_ length, Value_* buffer) { +template +void delayed_arithmetic_run_simple(Scalar_ scalar, Index_ length, Value_* buffer) { for (Index_ i = 0; i < length; ++i) { - delayed_arith_run(buffer[i], scalar); + delayed_arithmetic_run(buffer[i], scalar); } } -template -constexpr bool delayed_arith_unsupported_division_by_zero() { - return !std::numeric_limits::is_iec559 && op_ == DelayedArithOp::DIVIDE && !right_; +template +constexpr bool delayed_arithmetic_unsupported_division_by_zero() { + return !std::numeric_limits::is_iec559 && op_ == ArithmeticOperation::DIVIDE && !right_; } -template -bool delayed_arith_actual_sparse(Scalar_ scalar) { - if constexpr(delayed_arith_unsupported_division_by_zero()) { +template +bool delayed_arithmetic_actual_sparse(Scalar_ scalar) { + if constexpr(delayed_arithmetic_unsupported_division_by_zero()) { // If we didn't catch this case, the else() condition would be dividing // by zero in a Value_ that doesn't support it, and that would be visible // at compile time - possibly resulting in compiler warnings. So we @@ -40,20 +40,20 @@ bool delayed_arith_actual_sparse(Scalar_ scalar) { } else { // Empirically testing this, to accommodate special values (e.g., NaN, Inf) for scalars. Value_ output = 0; - delayed_arith_run(output, scalar); + delayed_arithmetic_run(output, scalar); return output == 0; } } -template -Value_ delayed_arith_zero(Scalar_ scalar) { - if constexpr(delayed_arith_unsupported_division_by_zero()) { +template +Value_ delayed_arithmetic_zero(Scalar_ scalar) { + if constexpr(delayed_arithmetic_unsupported_division_by_zero()) { // Avoid potential problems with division by zero that can be detected // at compile time (e.g., resulting in unnecessary compiler warnings). throw std::runtime_error("division by zero is not supported with IEEE-754 floats"); } else { Value_ output = 0; - delayed_arith_run(output, scalar); + delayed_arithmetic_run(output, scalar); return output; } } @@ -62,9 +62,9 @@ Value_ delayed_arith_zero(Scalar_ scalar) { */ /** - * @brief Delayed scalar arithmetic. + * @brief Delayed unary isometric scalar arithmetic. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The arithmetic operation. * @tparam right_ Whether the scalar should be on the right hand side of the arithmetic operation. @@ -72,14 +72,14 @@ Value_ delayed_arith_zero(Scalar_ scalar) { * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar value. */ -template -class DelayedArithScalarHelper { +template +class DelayedUnaryIsometricArithmeticScalar { public: /** - * @param scalar Scalar value to be added. + * @param scalar Scalar value to be used in the operation. */ - DelayedArithScalarHelper(Scalar_ scalar) : my_scalar(scalar) { - my_sparse = delayed_arith_actual_sparse(my_scalar); + DelayedUnaryIsometricArithmeticScalar(Scalar_ scalar) : my_scalar(scalar) { + my_sparse = delayed_arithmetic_actual_sparse(my_scalar); } private: @@ -111,23 +111,23 @@ class DelayedArithScalarHelper { */ template void dense(bool, Index_, Index_, Index_ length, Value_* buffer) const { - delayed_arith_run_simple(my_scalar, length, buffer); + delayed_arithmetic_run_simple(my_scalar, length, buffer); } template void dense(bool, Index_, const std::vector& indices, Value_* buffer) const { - delayed_arith_run_simple(my_scalar, indices.size(), buffer); + delayed_arithmetic_run_simple(my_scalar, indices.size(), buffer); } template void sparse(bool, Index_, Index_ number, Value_* buffer, const Index_*) const { - delayed_arith_run_simple(my_scalar, number, buffer); + delayed_arithmetic_run_simple(my_scalar, number, buffer); } template Value_ fill(Index_) const { - return delayed_arith_zero(my_scalar); + return delayed_arithmetic_zero(my_scalar); } /** * @endcond @@ -135,9 +135,9 @@ class DelayedArithScalarHelper { }; /** - * @brief Delayed vector arithmetic. + * @brief Delayed unary isometric vector arithmetic. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The arithmetic operation. * @tparam right_ Whether the vector's values should be on the right hand side of the arithmetic operation. @@ -148,16 +148,16 @@ class DelayedArithScalarHelper { * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. */ -template > -class DelayedArithVectorHelper { +template > +class DelayedUnaryIsometricArithmeticVector { public: /** * @param vector Vector of values to use in the operation. * This should be of length equal to the number of rows if `margin_ = 0`, otherwise it should be of length equal to the number of columns. */ - DelayedArithVectorHelper(Vector_ vector) : my_vector(std::move(vector)) { + DelayedUnaryIsometricArithmeticVector(Vector_ vector) : my_vector(std::move(vector)) { for (auto x : my_vector) { - if (!delayed_arith_actual_sparse(x)) { + if (!delayed_arithmetic_actual_sparse(x)) { my_sparse = false; break; } @@ -194,10 +194,10 @@ class DelayedArithVectorHelper { template void dense(bool row, Index_ idx, Index_ start, Index_ length, Value_* buffer) const { if (row == (margin_ == 0)) { - delayed_arith_run_simple(my_vector[idx], length, buffer); + delayed_arithmetic_run_simple(my_vector[idx], length, buffer); } else { for (Index_ i = 0; i < length; ++i) { - delayed_arith_run(buffer[i], my_vector[i + start]); + delayed_arithmetic_run(buffer[i], my_vector[i + start]); } } } @@ -205,10 +205,10 @@ class DelayedArithVectorHelper { template void dense(bool row, Index_ idx, const std::vector& indices, Value_* buffer) const { if (row == (margin_ == 0)) { - delayed_arith_run_simple(my_vector[idx], indices.size(), buffer); + delayed_arithmetic_run_simple(my_vector[idx], indices.size(), buffer); } else { for (Index_ i = 0, length = indices.size(); i < length; ++i) { - delayed_arith_run(buffer[i], my_vector[indices[i]]); + delayed_arithmetic_run(buffer[i], my_vector[indices[i]]); } } } @@ -216,17 +216,17 @@ class DelayedArithVectorHelper { template void sparse(bool row, Index_ idx, Index_ number, Value_* buffer, const Index_* indices) const { if (row == (margin_ == 0)) { - delayed_arith_run_simple(my_vector[idx], number, buffer); + delayed_arithmetic_run_simple(my_vector[idx], number, buffer); } else { for (Index_ i = 0; i < number; ++i) { - delayed_arith_run(buffer[i], my_vector[indices[i]]); + delayed_arithmetic_run(buffer[i], my_vector[indices[i]]); } } } template Value_ fill(Index_ idx) const { - return delayed_arith_zero(my_vector[idx]); + return delayed_arithmetic_zero(my_vector[idx]); } /** * @endcond @@ -237,11 +237,12 @@ class DelayedArithVectorHelper { * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be added. - * @return A helper class for delayed scalar addition. + * @return A helper class for delayed scalar addition, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedAddScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricAddScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** @@ -249,22 +250,24 @@ DelayedArithScalarHelper make_Delaye * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be subtracted. - * @return A helper class for delayed scalar subtraction. + * @return A helper class for delayed scalar subtraction, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedSubtractScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricSubtractScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be multiplied. - * @return A helper class for delayed scalar multiplication. + * @return A helper class for delayed scalar multiplication, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedMultiplyScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricMultiplyScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** @@ -272,11 +275,12 @@ DelayedArithScalarHelper make_D * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be divided. - * @return A helper class for delayed scalar division. + * @return A helper class for delayed scalar division, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedDivideScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricDivideScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** @@ -284,11 +288,12 @@ DelayedArithScalarHelper make_D * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be power transformed. - * @return A helper class for delayed scalar power transformation. + * @return A helper class for delayed scalar power transformation, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedPowerScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricPowerScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** @@ -296,11 +301,12 @@ DelayedArithScalarHelper make_De * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be modulo transformed. - * @return A helper class for delayed scalar modulus. + * @return A helper class for delayed scalar modulus, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedModuloScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricModuloScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** @@ -308,107 +314,115 @@ DelayedArithScalarHelper make_D * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be integer divided. - * @return A helper class for delayed scalar integer division. + * @return A helper class for delayed scalar integer division, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedArithScalarHelper make_DelayedIntegerDivideScalarHelper(Scalar_ scalar) { - return DelayedArithScalarHelper(std::move(scalar)); +DelayedUnaryIsometricArithmeticScalar make_DelayedUnaryIsometricIntegerDivideScalar(Scalar_ scalar) { + return DelayedUnaryIsometricArithmeticScalar(std::move(scalar)); } /** - * @tparam margin_ Matrix dimension along which the addition is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the addition is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to be added to the rows/columns. - * @return A helper class for delayed vector addition. + * @return A helper class for delayed vector addition, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedAddVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricAddVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** * @tparam right_ Whether the scalar should be on the right hand side of the subtraction. - * @tparam margin_ Matrix dimension along which the subtraction is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the subtraction is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to subtract from (or be subtracted by) the rows/columns. - * @return A helper class for delayed vector subtraction. + * @return A helper class for delayed vector subtraction, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedSubtractVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricSubtractVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the multiplication is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the multiplication is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to multiply the rows/columns. - * @return A helper class for delayed vector multiplication. + * @return A helper class for delayed vector multiplication, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedMultiplyVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricMultiplyVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** * @tparam right_ Whether the scalar should be on the right hand side of the division. - * @tparam margin_ Matrix dimension along which the division is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the division is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to divide (or be divided by) the rows/columns. - * @return A helper class for delayed vector division. + * @return A helper class for delayed vector division, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedDivideVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricDivideVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** * @tparam right_ Whether the scalar should be on the right hand side of the power transformation. - * @tparam margin_ Matrix dimension along which the power transformation is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the power transformation is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to use in the power transformation of the rows/columns. - * @return A helper class for delayed vector power transformation. + * @return A helper class for delayed vector power transformation, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedPowerVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricPowerVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** * @tparam right_ Whether the scalar should be on the right hand side of the modulus. - * @tparam margin_ Matrix dimension along which the modulus is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the modulus is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to use in the modulus of the rows/columns. - * @return A helper class for delayed vector modulus. + * @return A helper class for delayed vector modulus, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedModuloVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricModuloVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } /** * @tparam right_ Whether the scalar should be on the right hand side of the integer division. - * @tparam margin_ Matrix dimension along which the integer division is to occur, see `DelayedArithVectorHelper`. + * @tparam margin_ Matrix dimension along which the integer division is to occur, see `DelayedUnaryIsometricArithmeticVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * * @param vector Vector to integer divide (or be integer divided by) the rows/columns. - * @return A helper class for delayed vector division. + * @return A helper class for delayed vector division, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedArithVectorHelper make_DelayedIntegerDivideVectorHelper(Vector_ vector) { - return DelayedArithVectorHelper(std::move(vector)); +DelayedUnaryIsometricArithmeticVector make_DelayedUnaryIsometricIntegerDivideVector(Vector_ vector) { + return DelayedUnaryIsometricArithmeticVector(std::move(vector)); } } diff --git a/include/tatami/isometric/unary/boolean_helpers.hpp b/include/tatami/isometric/unary/boolean_helpers.hpp index 911c5522..16efaec7 100644 --- a/include/tatami/isometric/unary/boolean_helpers.hpp +++ b/include/tatami/isometric/unary/boolean_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_BOOLEAN_HELPERS_H -#define TATAMI_BOOLEAN_HELPERS_H +#ifndef TATAMI_ISOMETRIC_UNARY_BOOLEAN_HELPERS_H +#define TATAMI_ISOMETRIC_UNARY_BOOLEAN_HELPERS_H #include "../boolean_utils.hpp" #include @@ -7,7 +7,7 @@ /** * @file boolean_helpers.hpp * - * @brief Helper classes for delayed unary boolean operations. + * @brief Helper classes for delayed unary isometric boolean operations. */ namespace tatami { @@ -15,14 +15,14 @@ namespace tatami { /** * @cond */ -template +template void delayed_boolean_run_simple(bool scalar, Index_ length, Value_* buffer) { for (Index_ i = 0; i < length; ++i) { delayed_boolean_run(buffer[i], scalar); } } -template +template bool delayed_boolean_actual_sparse(bool scalar) { Value_ output = 0; delayed_boolean_run(output, scalar); @@ -33,20 +33,20 @@ bool delayed_boolean_actual_sparse(bool scalar) { */ /** - * @brief Delayed scalar boolean operation. + * @brief Delayed unary isometric scalar boolean operation. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The boolean operation. * @tparam Value_ Type of the data value. */ -template -class DelayedBooleanScalarHelper { +template +class DelayedUnaryIsometricBooleanScalar { public: /** * @param scalar Scalar value. */ - DelayedBooleanScalarHelper(bool scalar) : my_scalar(scalar) { + DelayedUnaryIsometricBooleanScalar(bool scalar) : my_scalar(scalar) { my_sparse = delayed_boolean_actual_sparse(my_scalar); } @@ -104,14 +104,14 @@ class DelayedBooleanScalarHelper { }; /** - * @brief Delayed boolean NOT operation. + * @brief Delayed unary isometric boolean NOT operation. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam Value_ Type of the data value. */ template -class DelayedBooleanNotHelper { +class DelayedUnaryIsometricBooleanNotOperation { public: /** * @cond @@ -168,9 +168,9 @@ class DelayedBooleanNotHelper { }; /** - * @brief Delayed vector boolean operations. + * @brief Delayed unary isometric vector boolean operations. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The boolean operation. * @tparam margin_ Matrix dimension along which the operation is to occur. @@ -179,14 +179,14 @@ class DelayedBooleanNotHelper { * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. */ -template > -class DelayedBooleanVectorHelper { +template > +class DelayedUnaryIsometricBooleanVector { public: /** * @param vector Vector of values to use in the operation. * This should be of length equal to the number of rows if `margin_ = 0`, otherwise it should be of length equal to the number of columns. */ - DelayedBooleanVectorHelper(Vector_ vector) : my_vector(std::move(vector)) { + DelayedUnaryIsometricBooleanVector(Vector_ vector) : my_vector(std::move(vector)) { for (auto x : my_vector) { if (!delayed_boolean_actual_sparse(x)) { my_sparse = false; @@ -268,99 +268,108 @@ class DelayedBooleanVectorHelper { /** * @tparam Value_ Type of the data value. - * @return A helper class for a delayed NOT operation. + * @return A helper class for a delayed NOT operation, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedBooleanNotHelper make_DelayedBooleanNotHelper() { - return DelayedBooleanNotHelper(); +DelayedUnaryIsometricBooleanNotOperation make_DelayedUnaryIsometricBooleanNot() { + return DelayedUnaryIsometricBooleanNotOperation(); } /** * @tparam Value_ Type of the data value. * @param scalar Scalar value to use in the operation. - * @return A helper class for a delayed AND operation with a scalar. + * @return A helper class for a delayed AND operation with a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedBooleanScalarHelper make_DelayedBooleanAndScalarHelper(bool scalar) { - return DelayedBooleanScalarHelper(scalar); +DelayedUnaryIsometricBooleanScalar make_DelayedUnaryIsometricBooleanAndScalar(bool scalar) { + return DelayedUnaryIsometricBooleanScalar(scalar); } /** * @tparam Value_ Type of the data value. * @param scalar Scalar value to use in the operation. - * @return A helper class for a delayed OR operation with a scalar. + * @return A helper class for a delayed OR operation with a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedBooleanScalarHelper make_DelayedBooleanOrScalarHelper(bool scalar) { - return DelayedBooleanScalarHelper(scalar); +DelayedUnaryIsometricBooleanScalar make_DelayedUnaryIsometricBooleanOrScalar(bool scalar) { + return DelayedUnaryIsometricBooleanScalar(scalar); } /** * @tparam Value_ Type of the data value. * @param scalar Scalar value to be used in the operation. - * @return A helper class for a delayed XOR operation with a scalar. + * @return A helper class for a delayed XOR operation with a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedBooleanScalarHelper make_DelayedBooleanXorScalarHelper(bool scalar) { - return DelayedBooleanScalarHelper(scalar); +DelayedUnaryIsometricBooleanScalar make_DelayedUnaryIsometricBooleanXorScalar(bool scalar) { + return DelayedUnaryIsometricBooleanScalar(scalar); } /** * @tparam Value_ Type of the data value. * @param scalar Scalar value to be used in the operation. - * @return A helper class for a delayed boolean equality operation with a scalar. + * @return A helper class for a delayed boolean equality operation with a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedBooleanScalarHelper make_DelayedBooleanEqualScalarHelper(bool scalar) { - return DelayedBooleanScalarHelper(scalar); +DelayedUnaryIsometricBooleanScalar make_DelayedUnaryIsometricBooleanEqualScalar(bool scalar) { + return DelayedUnaryIsometricBooleanScalar(scalar); } /** * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedBooleanVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricBooleanVector`. * @param vector Vector of values to be used in the operation. - * @return A helper class for a delayed AND operation with a vector. + * @return A helper class for a delayed AND operation with a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedBooleanVectorHelper make_DelayedBooleanAndVectorHelper(Vector_ vector) { - return DelayedBooleanVectorHelper(std::move(vector)); +DelayedUnaryIsometricBooleanVector make_DelayedUnaryIsometricBooleanAndVector(Vector_ vector) { + return DelayedUnaryIsometricBooleanVector(std::move(vector)); } /** * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedBooleanVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricBooleanVector`. * @param vector Vector of values to be used in the operation. - * @return A helper class for a delayed OR operation with a vector. + * @return A helper class for a delayed OR operation with a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedBooleanVectorHelper make_DelayedBooleanOrVectorHelper(Vector_ vector) { - return DelayedBooleanVectorHelper(std::move(vector)); +DelayedUnaryIsometricBooleanVector make_DelayedUnaryIsometricBooleanOrVector(Vector_ vector) { + return DelayedUnaryIsometricBooleanVector(std::move(vector)); } /** * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedBooleanVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricBooleanVector`. * @param vector Vector of values to be used in the operation. - * @return A helper class for a delayed XOR operation with a vector. + * @return A helper class for a delayed XOR operation with a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedBooleanVectorHelper make_DelayedBooleanXorVectorHelper(Vector_ vector) { - return DelayedBooleanVectorHelper(std::move(vector)); +DelayedUnaryIsometricBooleanVector make_DelayedUnaryIsometricBooleanXorVector(Vector_ vector) { + return DelayedUnaryIsometricBooleanVector(std::move(vector)); } /** * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedBooleanVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricBooleanVector`. * @param vector Vector of values to be used in the operation. - * @return A helper class for a delayed boolean equality operation with a vector. + * @return A helper class for a delayed boolean equality operation with a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedBooleanVectorHelper make_DelayedBooleanEqualVectorHelper(Vector_ vector) { - return DelayedBooleanVectorHelper(std::move(vector)); +DelayedUnaryIsometricBooleanVector make_DelayedUnaryIsometricBooleanEqualVector(Vector_ vector) { + return DelayedUnaryIsometricBooleanVector(std::move(vector)); } } diff --git a/include/tatami/isometric/unary/compare_helpers.hpp b/include/tatami/isometric/unary/compare_helpers.hpp index 8d02ed40..709853d3 100644 --- a/include/tatami/isometric/unary/compare_helpers.hpp +++ b/include/tatami/isometric/unary/compare_helpers.hpp @@ -1,5 +1,5 @@ -#ifndef TATAMI_COMPARE_HELPERS_H -#define TATAMI_COMPARE_HELPERS_H +#ifndef TATAMI_ISOMETRIC_UNARY_COMPARE_HELPERS_H +#define TATAMI_ISOMETRIC_UNARY_COMPARE_HELPERS_H #include "../compare_utils.hpp" #include @@ -7,7 +7,7 @@ /** * @file compare_helpers.hpp * - * @brief Helper classes for delayed unary comparison operations. + * @brief Helper classes for delayed unary isometric comparison operations. */ namespace tatami { @@ -15,14 +15,14 @@ namespace tatami { /** * @cond */ -template +template void delayed_compare_run_simple(Scalar_ scalar, Index_ length, Value_* buffer) { for (Index_ i = 0; i < length; ++i) { delayed_compare_run(buffer[i], scalar); } } -template +template bool delayed_compare_actual_sparse(Scalar_ scalar) { Value_ output = 0; delayed_compare_run(output, scalar); @@ -35,19 +35,19 @@ bool delayed_compare_actual_sparse(Scalar_ scalar) { /** * @brief Delayed scalar comparison. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The comparison operation. * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar value. */ -template -class DelayedCompareScalarHelper { +template +class DelayedUnaryIsometricCompareScalar { public: /** * @param scalar Scalar value to be added. */ - DelayedCompareScalarHelper(Scalar_ scalar) : my_scalar(scalar) { + DelayedUnaryIsometricCompareScalar(Scalar_ scalar) : my_scalar(scalar) { my_sparse = delayed_compare_actual_sparse(my_scalar); } @@ -107,7 +107,7 @@ class DelayedCompareScalarHelper { /** * @brief Delayed vector comparisons. * - * This should be used as the `Operation_` in the `DelayedUnaryIsometricOp` class. + * This should be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam op_ The comparison operation. * @tparam margin_ Matrix dimension along which the operation is to occur. @@ -116,14 +116,14 @@ class DelayedCompareScalarHelper { * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. */ -template > -class DelayedCompareVectorHelper { +template > +class DelayedUnaryIsometricCompareVector { public: /** * @param vector Vector of values to use in the operation. * This should be of length equal to the number of rows if `MARGIN = 0`, otherwise it should be of length equal to the number of columns. */ - DelayedCompareVectorHelper(Vector_ vector) : my_vector(std::move(vector)) { + DelayedUnaryIsometricCompareVector(Vector_ vector) : my_vector(std::move(vector)) { for (auto x : my_vector) { if (!delayed_compare_actual_sparse(x)) { my_sparse = false; @@ -207,138 +207,150 @@ class DelayedCompareVectorHelper { * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed equality comparison to a scalar. + * @return A helper class for a delayed equality comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedEqualScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricEqualScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed greater-than comparison to a scalar. + * @return A helper class for a delayed greater-than comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedGreaterThanScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricGreaterThanScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed less-than comparison to a scalar. + * @return A helper class for a delayed less-than comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedLessThanScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricLessThanScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed greater-than-or-equal comparison to a scalar. + * @return A helper class for a delayed greater-than-or-equal comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedGreaterThanOrEqualScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricGreaterThanOrEqualScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed less-than-or-equal comparison to a scalar. + * @return A helper class for a delayed less-than-or-equal comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedLessThanOrEqualScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricLessThanOrEqualScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** * @tparam Value_ Type of the data value. * @tparam Scalar_ Type of the scalar. * @param scalar Scalar value to be compared. - * @return A helper class for a delayed non-equality comparison to a scalar. + * @return A helper class for a delayed non-equality comparison to a scalar, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template -DelayedCompareScalarHelper make_DelayedNotEqualScalarHelper(Scalar_ scalar) { - return DelayedCompareScalarHelper(std::move(scalar)); +DelayedUnaryIsometricCompareScalar make_DelayedUnaryIsometricNotEqualScalar(Scalar_ scalar) { + return DelayedUnaryIsometricCompareScalar(std::move(scalar)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed equality comparison to a vector. + * @return A helper class for a delayed equality comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedEqualVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricEqualVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed greater-than comparison to a vector. + * @return A helper class for a delayed greater-than comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedGreaterThanVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricGreaterThanVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed less-than comparison to a vector. + * @return A helper class for a delayed less-than comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedLessThanVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricLessThanVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed greater-than-or-equal comparison to a vector. + * @return A helper class for a delayed greater-than-or-equal comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedGreaterThanOrEqualVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricGreaterThanOrEqualVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed less-than-or-equal comparison to a vector. + * @return A helper class for a delayed less-than-or-equal comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedLessThanOrEqualVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricLessThanOrEqualVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } /** - * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedCompareVectorHelper`. + * @tparam margin_ Matrix dimension along which the comparison is to occur, see `DelayedUnaryIsometricCompareVector`. * @tparam Value_ Type of the data value. * @tparam Vector_ Type of the vector. * @param vector Vector of values to be compared. - * @return A helper class for a delayed non-equality comparison to a vector. + * @return A helper class for a delayed non-equality comparison to a vector, + * to be used as the `operation` in a `DelayedUnaryIsometricOperation`. */ template > -DelayedCompareVectorHelper make_DelayedNotEqualVectorHelper(Vector_ vector) { - return DelayedCompareVectorHelper(std::move(vector)); +DelayedUnaryIsometricCompareVector make_DelayedUnaryIsometricNotEqualVector(Vector_ vector) { + return DelayedUnaryIsometricCompareVector(std::move(vector)); } } diff --git a/include/tatami/isometric/unary/math_helpers.hpp b/include/tatami/isometric/unary/math_helpers.hpp index 28406ca4..69f96b06 100644 --- a/include/tatami/isometric/unary/math_helpers.hpp +++ b/include/tatami/isometric/unary/math_helpers.hpp @@ -13,10 +13,13 @@ namespace tatami { /** * @brief Take the absolute value of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAbsHelper { +class DelayedUnaryIsometricAbs { public: /** * @cond @@ -75,10 +78,13 @@ class DelayedAbsHelper { /** * @brief Take the sign of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedSignHelper { +class DelayedUnaryIsometricSign { public: /** * @cond @@ -138,22 +144,24 @@ class DelayedSignHelper { /** * @brief Take the logarithm of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. * * @tparam Value_ Type of the data value. * @tparam Base_ Numeric type for the log base. */ template -class DelayedLogHelper { +class DelayedUnaryIsometricLog { public: /** * Defaults to the natural log. */ - DelayedLogHelper() : my_base(1) {} + DelayedUnaryIsometricLog() : my_base(1) {} /** * @param base Base of the logarithm. */ - DelayedLogHelper(Base_ base) : my_base(std::log(base)) {} + DelayedUnaryIsometricLog(Base_ base) : my_base(std::log(base)) {} public: /** @@ -215,10 +223,13 @@ class DelayedLogHelper { /** * @brief Take the square root of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedSqrtHelper { +class DelayedUnaryIsometricSqrt { public: /** * @cond @@ -276,10 +287,13 @@ class DelayedSqrtHelper { /** * @brief Take the ceiling of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedCeilingHelper { +class DelayedUnaryIsometricCeiling { public: /** * @cond @@ -337,10 +351,13 @@ class DelayedCeilingHelper { /** * @brief Take the floor of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedFloorHelper { +class DelayedUnaryIsometricFloor { public: /** * @cond @@ -398,10 +415,13 @@ class DelayedFloorHelper { /** * @brief Take the trunc of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedTruncHelper { +class DelayedUnaryIsometricTrunc { public: /** * @cond @@ -460,21 +480,23 @@ class DelayedTruncHelper { /** * @brief Take the logarithm of a matrix entry plus 1. * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. * @tparam Base_ Numeric type for the log base. */ template -class DelayedLog1pHelper { +class DelayedUnaryIsometricLog1p { public: /** * Defaults to the natural log. */ - DelayedLog1pHelper() : my_base(1) {} + DelayedUnaryIsometricLog1p() : my_base(1) {} /** * @param base Base of the logarithm. */ - DelayedLog1pHelper(Base_ base) : my_base(std::log(base)) {} + DelayedUnaryIsometricLog1p(Base_ base) : my_base(std::log(base)) {} public: /** @@ -535,10 +557,13 @@ class DelayedLog1pHelper { /** * @brief Round a matrix entry to the nearest integer. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedRoundHelper { +class DelayedUnaryIsometricRound { public: /** * @cond @@ -596,10 +621,13 @@ class DelayedRoundHelper { /** * @brief Use a matrix entry as an exponent. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedExpHelper { +class DelayedUnaryIsometricExp { public: /** * @cond @@ -657,10 +685,13 @@ class DelayedExpHelper { /** * @brief Use a matrix entry as an exponent minus 1. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedExpm1Helper { +class DelayedUnaryIsometricExpm1 { public: /** * @cond @@ -718,10 +749,13 @@ class DelayedExpm1Helper { /** * @brief Take the arc cosine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAcosHelper { +class DelayedUnaryIsometricAcos { public: /** * @cond @@ -780,10 +814,13 @@ class DelayedAcosHelper { /** * @brief Take the inverse hyperbolic cosine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAcoshHelper { +class DelayedUnaryIsometricAcosh { public: /** * @cond @@ -842,10 +879,13 @@ class DelayedAcoshHelper { /** * @brief Take the arc sine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAsinHelper { +class DelayedUnaryIsometricAsin { public: /** * @cond @@ -903,10 +943,13 @@ class DelayedAsinHelper { /** * @brief Take the inverse hyperbolic sine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAsinhHelper { +class DelayedUnaryIsometricAsinh { public: /** * @cond @@ -964,10 +1007,13 @@ class DelayedAsinhHelper { /** * @brief Take the arc tangent of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAtanHelper { +class DelayedUnaryIsometricAtan { public: /** * @cond @@ -1025,10 +1071,13 @@ class DelayedAtanHelper { /** * @brief Take the inverse hyperbolic tangent of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedAtanhHelper { +class DelayedUnaryIsometricAtanh { public: /** * @cond @@ -1086,10 +1135,13 @@ class DelayedAtanhHelper { /** * @brief Take the cosine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedCosHelper { +class DelayedUnaryIsometricCos { public: /** * @cond @@ -1147,10 +1199,13 @@ class DelayedCosHelper { /** * @brief Take the hyperbolic cosine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedCoshHelper { +class DelayedUnaryIsometricCosh { public: /** * @cond @@ -1208,10 +1263,13 @@ class DelayedCoshHelper { /** * @brief Take the sine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedSinHelper { +class DelayedUnaryIsometricSin { public: /** * @cond @@ -1269,10 +1327,13 @@ class DelayedSinHelper { /** * @brief Take the hyperbolic sine of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedSinhHelper { +class DelayedUnaryIsometricSinh { public: /** * @cond @@ -1330,10 +1391,13 @@ class DelayedSinhHelper { /** * @brief Take the tangent of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedTanHelper { +class DelayedUnaryIsometricTan { public: /** * @cond @@ -1391,10 +1455,13 @@ class DelayedTanHelper { /** * @brief Take the hyperbolic tangent of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedTanhHelper { +class DelayedUnaryIsometricTanh { public: /** * @cond @@ -1452,10 +1519,13 @@ class DelayedTanhHelper { /** * @brief Take the gamma of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedGammaHelper { +class DelayedUnaryIsometricGamma { public: /** * @cond @@ -1514,10 +1584,13 @@ class DelayedGammaHelper { /** * @brief Take the logarithm of the gamma of a matrix entry. + * + * This can be used as the `Operation_` in the `DelayedUnaryIsometricOperation` class. + * * @tparam Value_ Type of the data value. */ template -class DelayedLgammaHelper { +class DelayedUnaryIsometricLgamma { public: /** * @cond diff --git a/include/tatami/isometric/unary/mock_helpers.hpp b/include/tatami/isometric/unary/mock_helpers.hpp index 184535a1..ca0cbdec 100644 --- a/include/tatami/isometric/unary/mock_helpers.hpp +++ b/include/tatami/isometric/unary/mock_helpers.hpp @@ -6,20 +6,20 @@ /** * @file mock_helpers.hpp - * @brief Expectations for `tatami::DelayedUnaryIsometricOp` helpers. + * @brief Expectations for `tatami::DelayedUnaryIsometricOperation` helpers. */ namespace tatami { /** - * @brief Basic mock operation for a `DelayedUnaryIsometricOp`. + * @brief Basic mock operation for a `DelayedUnaryIsometricOperation`. * - * This defines the basic expectations for an operation to use in `DelayedUnaryIsometricOp`. + * This defines the basic expectations for an operation to use in `DelayedUnaryIsometricOperation`. * Actual operations aren't expected to inherit from this class; * this is only provided for documentation purposes. * Operations only need to implement methods with the same signatures for compile-time polymorphism. */ -class DelayedUnaryBasicMockHelper { +class DelayedUnaryIsometricMockBasic { public: /** * This method should apply the operation to values in `buffer`, @@ -82,21 +82,21 @@ class DelayedUnaryBasicMockHelper { /** * Conversion of zeros to non-zero values is dependent on the row of origin. - * This should be true, otherwise an advanced operation interface is expected (see `DelayedUnaryAdvancedMockHelper`). + * This should be true, otherwise an advanced operation interface is expected (see `DelayedUnaryIsometricMockAdvanced`). */ static constexpr bool zero_depends_on_row = true; /** * Conversion of zeros to non-zero values is dependent on the column of origin. - * This should be true, otherwise an advanced operation interface is expected (see `DelayedUnaryAdvancedMockHelper`). + * This should be true, otherwise an advanced operation interface is expected (see `DelayedUnaryIsometricMockAdvanced`). */ static constexpr bool zero_depends_on_column = true; }; /** - * @brief Advanced mock operation for `DelayedUnaryIsometricOp`. + * @brief Advanced mock operation for `DelayedUnaryIsometricOperation`. * - * This class defines the advanced expectations for an operation in `DelayedUnaryIsometricOp`, + * This class defines the advanced expectations for an operation in `DelayedUnaryIsometricOperation`, * which improves efficiency by taking advantage of any sparsity in the underlying matrix. * Either the operation itself preserves sparsity, or any loss of sparsity is predictable, * i.e., zeros are transformed into a constant non-zero value that does not depend on its position in the `Matrix`. @@ -105,7 +105,7 @@ class DelayedUnaryBasicMockHelper { * this is only provided for documentation purposes. * Operations only need to implement methods with the same signatures for compile-time polymorphism. */ -class DelayedUnaryAdvancedMockHelper { +class DelayedUnaryIsometricMockAdvanced { public: /** * This method should apply the operation to values in `buffer`. @@ -227,14 +227,18 @@ class DelayedUnaryAdvancedMockHelper { /** * Conversion of zeros to non-zero values is not dependent on the row of origin. * Implementations of the advanced operation interface may set this to `true` provided that `zero_depends_on_column = false`; - * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedUnaryBasicMockHelper`). + * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedUnaryIsometricMockBasic`). + * + * This value is only used if `is_sparse()` returns false. */ static constexpr bool zero_depends_on_row = false; /** * Conversion of zeros to non-zero values is not dependent on the column of origin. * Implementations of the advanced operation interface may set this to `true` provided that `zero_depends_on_row = false`. - * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedUnaryBasicMockHelper`). + * at least one of these must be false, otherwise a basic operation interface is expected (see `DelayedUnaryIsometricMockBasic`). + * + * This value is only used if `is_sparse()` returns false. */ static constexpr bool zero_depends_on_column = false; diff --git a/include/tatami/tatami.hpp b/include/tatami/tatami.hpp index b21877ba..05e91c22 100644 --- a/include/tatami/tatami.hpp +++ b/include/tatami/tatami.hpp @@ -11,8 +11,8 @@ #include "sparse/convert_to_fragmented_sparse.hpp" #include "sparse/compress_sparse_triplets.hpp" -#include "isometric/unary/DelayedUnaryIsometricOp.hpp" -#include "isometric/binary/DelayedBinaryIsometricOp.hpp" +#include "isometric/unary/DelayedUnaryIsometricOperation.hpp" +#include "isometric/binary/DelayedBinaryIsometricOperation.hpp" #include "other/DelayedBind.hpp" #include "other/DelayedCast.hpp" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index aa10caa7..726cf066 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -67,9 +67,9 @@ decorate_executable(subset_test) add_executable( isometric_unary_test - src/isometric/unary/DelayedUnaryIsometricOp.cpp - src/isometric/unary/arith_vector_helpers.cpp - src/isometric/unary/arith_scalar_helpers.cpp + src/isometric/unary/DelayedUnaryIsometricOperation.cpp + src/isometric/unary/arithmetic_vector_helpers.cpp + src/isometric/unary/arithmetic_scalar_helpers.cpp src/isometric/unary/math_helpers.cpp src/isometric/unary/compare_scalar_helpers.cpp src/isometric/unary/compare_vector_helpers.cpp @@ -80,8 +80,8 @@ decorate_executable(isometric_unary_test) add_executable( isometric_binary_test - src/isometric/binary/DelayedBinaryIsometricOp.cpp - src/isometric/binary/arith_helpers.cpp + src/isometric/binary/DelayedBinaryIsometricOperation.cpp + src/isometric/binary/arithmetic_helpers.cpp src/isometric/binary/compare_helpers.cpp src/isometric/binary/boolean_helpers.cpp ) diff --git a/tests/src/isometric/binary/DelayedBinaryIsometricOp.cpp b/tests/src/isometric/binary/DelayedBinaryIsometricOperation.cpp similarity index 73% rename from tests/src/isometric/binary/DelayedBinaryIsometricOp.cpp rename to tests/src/isometric/binary/DelayedBinaryIsometricOperation.cpp index ec225921..eb8aa706 100644 --- a/tests/src/isometric/binary/DelayedBinaryIsometricOp.cpp +++ b/tests/src/isometric/binary/DelayedBinaryIsometricOperation.cpp @@ -5,35 +5,35 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/binary/DelayedBinaryIsometricOp.hpp" +#include "tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -TEST(DelayedBinaryIsometricOp, ConstOverload) { +TEST(DelayedBinaryIsometricOperation, ConstOverload) { int nrow = 23, ncol = 42; auto simulated = tatami_test::simulate_sparse_vector(nrow * ncol, 0.1); auto dense = std::shared_ptr(new tatami::DenseRowMatrix(nrow, ncol, std::move(simulated))); - auto op = tatami::make_DelayedBinaryAddHelper(); - auto mat = tatami::make_DelayedBinaryIsometricOp(dense, dense, std::move(op)); + auto op = tatami::make_DelayedBinaryIsometricAdd(); + auto mat = tatami::make_DelayedBinaryIsometricOperation(dense, dense, std::move(op)); // cursory checks. EXPECT_EQ(mat->nrow(), nrow); EXPECT_EQ(mat->ncol(), ncol); } -TEST(DelayedBinaryIsometricOp, Misshappen) { +TEST(DelayedBinaryIsometricOperation, Misshappen) { std::vector src(200); auto dense = std::shared_ptr(new tatami::DenseRowMatrix(10, 20, src)); auto dense2 = std::shared_ptr(new tatami::DenseRowMatrix(20, 10, src)); tatami_test::throws_error([&]() { - tatami::make_DelayedBinaryIsometricOp(dense, dense2, tatami::DelayedBinaryBasicMockHelper()); + tatami::make_DelayedBinaryIsometricOperation(dense, dense2, tatami::DelayedBinaryIsometricMockBasic()); }, "should be the same"); } -class DelayedBinaryIsometricOpMockTest : public ::testing::TestWithParam > { +class DelayedBinaryIsometricOperationTest : public ::testing::TestWithParam > { protected: inline static int nrow = 23, ncol = 42; inline static std::vector simulated; @@ -44,13 +44,13 @@ class DelayedBinaryIsometricOpMockTest : public ::testing::TestWithParam(nrow, ncol, std::move(simulated))); sparse = tatami::convert_to_compressed_sparse(dense.get()); - bdense = tatami::make_DelayedBinaryIsometricOp(dense, dense, tatami::DelayedBinaryBasicMockHelper()); - bsparse = tatami::make_DelayedBinaryIsometricOp(sparse, sparse, tatami::DelayedBinaryAdvancedMockHelper()); + bdense = tatami::make_DelayedBinaryIsometricOperation(dense, dense, tatami::DelayedBinaryIsometricMockBasic()); + bsparse = tatami::make_DelayedBinaryIsometricOperation(sparse, sparse, tatami::DelayedBinaryIsometricMockAdvanced()); ref.reset(new tatami::DenseRowMatrix(nrow, ncol, std::vector(nrow * ncol))); } }; -TEST_P(DelayedBinaryIsometricOpMockTest, Basic) { +TEST_P(DelayedBinaryIsometricOperationTest, Mock) { EXPECT_FALSE(bdense->is_sparse()); EXPECT_EQ(bdense->is_sparse_proportion(), 0); EXPECT_TRUE(bsparse->is_sparse()); @@ -72,8 +72,8 @@ TEST_P(DelayedBinaryIsometricOpMockTest, Basic) { } INSTANTIATE_TEST_SUITE_P( - DelayedBinary, - DelayedBinaryIsometricOpMockTest, + DelayedBinaryIsometricOperation, + DelayedBinaryIsometricOperationTest, ::testing::Combine( ::testing::Values(true, false), // row access ::testing::Values(true, false) // oracle usage diff --git a/tests/src/isometric/binary/arith_helpers.cpp b/tests/src/isometric/binary/arithmetic_helpers.cpp similarity index 68% rename from tests/src/isometric/binary/arith_helpers.cpp rename to tests/src/isometric/binary/arithmetic_helpers.cpp index c9c76470..942af602 100644 --- a/tests/src/isometric/binary/arith_helpers.cpp +++ b/tests/src/isometric/binary/arithmetic_helpers.cpp @@ -5,14 +5,14 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/binary/DelayedBinaryIsometricOp.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class BinaryArithUtils { +class DelayedBinaryIsometricArithmeticUtils { protected: inline static size_t nrow = 91, ncol = 121; inline static std::shared_ptr dense_left, sparse_left, dense_right, sparse_right; @@ -62,7 +62,7 @@ class BinaryArithUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ tatami_test::standard_test_access_parameter_combinations() \ ); @@ -89,7 +89,7 @@ class BinaryArithUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ ::testing::Combine( \ tatami_test::standard_test_access_parameter_combinations(), \ @@ -123,7 +123,7 @@ class BinaryArithUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ ::testing::Combine( \ tatami_test::standard_test_access_parameter_combinations(), \ @@ -139,7 +139,7 @@ class BinaryArithUtils { ********* ADDITION ********* ****************************/ -class BinaryArithAdditionUtils : public BinaryArithUtils { +class DelayedBinaryIsometricAddUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -148,11 +148,11 @@ class BinaryArithAdditionUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); - auto op = tatami::make_DelayedBinaryAddHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + DelayedBinaryIsometricArithmeticUtils::assemble(); + auto op = tatami::make_DelayedBinaryIsometricAdd(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -166,8 +166,8 @@ class BinaryArithAdditionUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithAdditionTest, BinaryArithAdditionUtils) -TEST_F(BinaryArithAdditionTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricAddTest, DelayedBinaryIsometricAddUtils) +TEST_F(DelayedBinaryIsometricAddTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense_mod->is_sparse_proportion(), 0); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -180,21 +180,21 @@ TEST_F(BinaryArithAdditionTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); EXPECT_EQ(sparse_mod->prefer_rows_proportion(), 0); - auto mixed_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, dense_right, tatami::make_DelayedBinaryAddHelper()); + auto mixed_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, dense_right, tatami::make_DelayedBinaryIsometricAdd()); EXPECT_FALSE(mixed_mod->is_sparse()); EXPECT_EQ(mixed_mod->prefer_rows_proportion(), 0.5); EXPECT_EQ(mixed_mod->is_sparse_proportion(), 0.5); } -BINARY_ARITH_FULL_TEST(BinaryArithAdditionFullTest, BinaryArithAdditionUtils) -BINARY_ARITH_BLOCK_TEST(BinaryArithAdditionBlockTest, BinaryArithAdditionUtils) -BINARY_ARITH_INDEX_TEST(BinaryArithAdditionIndexTest, BinaryArithAdditionUtils) +BINARY_ARITH_FULL_TEST(DelayedBinaryIsometricAddFullTest, DelayedBinaryIsometricAddUtils) +BINARY_ARITH_BLOCK_TEST(DelayedBinaryIsometricAddBlockTest, DelayedBinaryIsometricAddUtils) +BINARY_ARITH_INDEX_TEST(DelayedBinaryIsometricAddIndexTest, DelayedBinaryIsometricAddUtils) /******************************* ********* SUBTRACTION ********* *******************************/ -class BinaryArithSubtractionUtils : public BinaryArithUtils { +class DelayedBinaryIsometricSubtractUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -203,11 +203,11 @@ class BinaryArithSubtractionUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); - auto op = tatami::make_DelayedBinarySubtractHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + DelayedBinaryIsometricArithmeticUtils::assemble(); + auto op = tatami::make_DelayedBinaryIsometricSubtract(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -221,24 +221,24 @@ class BinaryArithSubtractionUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithSubtractionTest, BinaryArithSubtractionUtils) -TEST_F(BinaryArithSubtractionTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricSubtractTest, DelayedBinaryIsometricSubtractUtils) +TEST_F(DelayedBinaryIsometricSubtractTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); - auto mixed_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, dense_right, tatami::make_DelayedBinarySubtractHelper()); + auto mixed_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, dense_right, tatami::make_DelayedBinaryIsometricSubtract()); EXPECT_FALSE(mixed_mod->is_sparse()); } -BINARY_ARITH_FULL_TEST(BinaryArithSubtractionFullTest, BinaryArithSubtractionUtils) -BINARY_ARITH_BLOCK_TEST(BinaryArithSubtractionBlockTest, BinaryArithSubtractionUtils) -BINARY_ARITH_INDEX_TEST(BinaryArithSubtractionIndexTest, BinaryArithSubtractionUtils) +BINARY_ARITH_FULL_TEST(DelayedBinaryIsometricSubtractFullTest, DelayedBinaryIsometricSubtractUtils) +BINARY_ARITH_BLOCK_TEST(DelayedBinaryIsometricSubtractBlockTest, DelayedBinaryIsometricSubtractUtils) +BINARY_ARITH_INDEX_TEST(DelayedBinaryIsometricSubtractIndexTest, DelayedBinaryIsometricSubtractUtils) /********************************** ********* MULTIPLICATION ********* **********************************/ -class BinaryArithMultiplicationUtils : public BinaryArithUtils { +class DelayedBinaryIsometricMultiplyUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -247,12 +247,12 @@ class BinaryArithMultiplicationUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); + DelayedBinaryIsometricArithmeticUtils::assemble(); - auto op = tatami::make_DelayedBinaryMultiplyHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + auto op = tatami::make_DelayedBinaryIsometricMultiply(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -266,15 +266,15 @@ class BinaryArithMultiplicationUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithMultiplicationTest, BinaryArithMultiplicationUtils) -TEST_F(BinaryArithMultiplicationTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricMultiplyTest, DelayedBinaryIsometricMultiplyUtils) +TEST_F(DelayedBinaryIsometricMultiplyTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); } -BINARY_ARITH_FULL_TEST(BinaryArithMultiplicationFullTest, BinaryArithMultiplicationUtils) -BINARY_ARITH_BLOCK_TEST(BinaryArithMultiplicationBlockTest, BinaryArithMultiplicationUtils) -BINARY_ARITH_INDEX_TEST(BinaryArithMultiplicationIndexTest, BinaryArithMultiplicationUtils) +BINARY_ARITH_FULL_TEST(DelayedBinaryIsometricMultiplyFullTest, DelayedBinaryIsometricMultiplyUtils) +BINARY_ARITH_BLOCK_TEST(DelayedBinaryIsometricMultiplyBlockTest, DelayedBinaryIsometricMultiplyUtils) +BINARY_ARITH_INDEX_TEST(DelayedBinaryIsometricMultiplyIndexTest, DelayedBinaryIsometricMultiplyUtils) /**************************** ********* DIVISION ********* @@ -299,7 +299,7 @@ BINARY_ARITH_INDEX_TEST(BinaryArithMultiplicationIndexTest, BinaryArithMultiplic } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ tatami_test::standard_test_access_parameter_combinations() \ ); @@ -327,7 +327,7 @@ BINARY_ARITH_INDEX_TEST(BinaryArithMultiplicationIndexTest, BinaryArithMultiplic } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ ::testing::Combine( \ tatami_test::standard_test_access_parameter_combinations(), \ @@ -362,7 +362,7 @@ BINARY_ARITH_INDEX_TEST(BinaryArithMultiplicationIndexTest, BinaryArithMultiplic } \ \ INSTANTIATE_TEST_SUITE_P( \ - BinaryArith, \ + DelayedBinaryIsometricArithmetic, \ name, \ ::testing::Combine( \ tatami_test::standard_test_access_parameter_combinations(), \ @@ -375,7 +375,7 @@ BINARY_ARITH_INDEX_TEST(BinaryArithMultiplicationIndexTest, BinaryArithMultiplic ); -class BinaryArithDivisionUtils : public BinaryArithUtils { +class DelayedBinaryIsometricDivideUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -384,12 +384,12 @@ class BinaryArithDivisionUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); + DelayedBinaryIsometricArithmeticUtils::assemble(); - auto op = tatami::make_DelayedBinaryDivideHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + auto op = tatami::make_DelayedBinaryIsometricDivide(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -403,23 +403,23 @@ class BinaryArithDivisionUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithDivisionTest, BinaryArithDivisionUtils) -TEST_F(BinaryArithDivisionTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricDivideTest, DelayedBinaryIsometricDivideUtils) +TEST_F(DelayedBinaryIsometricDivideTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); EXPECT_TRUE(dense_mod->prefer_rows()); EXPECT_FALSE(sparse_mod->prefer_rows()); } -BINARY_ARITH_FULL_TEST_WITH_NAN(BinaryArithDivisionFullTest, BinaryArithDivisionUtils) -BINARY_ARITH_BLOCK_TEST_WITH_NAN(BinaryArithDivisionBlockTest, BinaryArithDivisionUtils) -BINARY_ARITH_INDEX_TEST_WITH_NAN(BinaryArithDivisionIndexTest, BinaryArithDivisionUtils) +BINARY_ARITH_FULL_TEST_WITH_NAN(DelayedBinaryIsometricDivideFullTest, DelayedBinaryIsometricDivideUtils) +BINARY_ARITH_BLOCK_TEST_WITH_NAN(DelayedBinaryIsometricDivideBlockTest, DelayedBinaryIsometricDivideUtils) +BINARY_ARITH_INDEX_TEST_WITH_NAN(DelayedBinaryIsometricDivideIndexTest, DelayedBinaryIsometricDivideUtils) /******************************* ************ POWER ************ *******************************/ -class BinaryArithPowerUtils : public BinaryArithUtils { +class DelayedBinaryIsometricPowerUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -428,18 +428,18 @@ class BinaryArithPowerUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); + DelayedBinaryIsometricArithmeticUtils::assemble(); - tatami::DelayedAbsHelper op0; - auto dense_left0 = tatami::make_DelayedUnaryIsometricOp(dense_left, op0); - auto sparse_left0 = tatami::make_DelayedUnaryIsometricOp(sparse_left, op0); - auto dense_right0 = tatami::make_DelayedUnaryIsometricOp(dense_right, op0); - auto sparse_right0 = tatami::make_DelayedUnaryIsometricOp(sparse_right, op0); + tatami::DelayedUnaryIsometricAbs op0; + auto dense_left0 = tatami::make_DelayedUnaryIsometricOperation(dense_left, op0); + auto sparse_left0 = tatami::make_DelayedUnaryIsometricOperation(sparse_left, op0); + auto dense_right0 = tatami::make_DelayedUnaryIsometricOperation(dense_right, op0); + auto sparse_right0 = tatami::make_DelayedUnaryIsometricOperation(sparse_right, op0); - auto op = tatami::make_DelayedBinaryPowerHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left0, dense_right0, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left0, sparse_right0, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + auto op = tatami::make_DelayedBinaryIsometricPower(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left0, dense_right0, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left0, sparse_right0, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left0)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right0)), op @@ -453,21 +453,21 @@ class BinaryArithPowerUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithPowerTest, BinaryArithPowerUtils) -TEST_F(BinaryArithPowerTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricPowerTest, DelayedBinaryIsometricPowerUtils) +TEST_F(DelayedBinaryIsometricPowerTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); } -BINARY_ARITH_FULL_TEST(BinaryArithPowerFullTest, BinaryArithPowerUtils) -BINARY_ARITH_BLOCK_TEST(BinaryArithPowerBlockTest, BinaryArithPowerUtils) -BINARY_ARITH_INDEX_TEST(BinaryArithPowerIndexTest, BinaryArithPowerUtils) +BINARY_ARITH_FULL_TEST(DelayedBinaryIsometricPowerFullTest, DelayedBinaryIsometricPowerUtils) +BINARY_ARITH_BLOCK_TEST(DelayedBinaryIsometricPowerBlockTest, DelayedBinaryIsometricPowerUtils) +BINARY_ARITH_INDEX_TEST(DelayedBinaryIsometricPowerIndexTest, DelayedBinaryIsometricPowerUtils) /**************************** ********** MODULO ********** ****************************/ -class BinaryArithModuloUtils : public BinaryArithUtils { +class DelayedBinaryIsometricModuloUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -476,12 +476,12 @@ class BinaryArithModuloUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); + DelayedBinaryIsometricArithmeticUtils::assemble(); - auto op = tatami::make_DelayedBinaryModuloHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + auto op = tatami::make_DelayedBinaryIsometricModulo(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -495,23 +495,23 @@ class BinaryArithModuloUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithModuloTest, BinaryArithModuloUtils) -TEST_F(BinaryArithModuloTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricModuloTest, DelayedBinaryIsometricModuloUtils) +TEST_F(DelayedBinaryIsometricModuloTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); EXPECT_TRUE(dense_mod->prefer_rows()); EXPECT_FALSE(sparse_mod->prefer_rows()); } -BINARY_ARITH_FULL_TEST_WITH_NAN(BinaryArithModuloFullTest, BinaryArithModuloUtils) -BINARY_ARITH_BLOCK_TEST_WITH_NAN(BinaryArithModuloBlockTest, BinaryArithModuloUtils) -BINARY_ARITH_INDEX_TEST_WITH_NAN(BinaryArithModuloIndexTest, BinaryArithModuloUtils) +BINARY_ARITH_FULL_TEST_WITH_NAN(DelayedBinaryIsometricModuloFullTest, DelayedBinaryIsometricModuloUtils) +BINARY_ARITH_BLOCK_TEST_WITH_NAN(DelayedBinaryIsometricModuloBlockTest, DelayedBinaryIsometricModuloUtils) +BINARY_ARITH_INDEX_TEST_WITH_NAN(DelayedBinaryIsometricModuloIndexTest, DelayedBinaryIsometricModuloUtils) /**************************** ***** INTEGER DIVISION ***** ****************************/ -class BinaryArithIntegerDivisionUtils : public BinaryArithUtils { +class DelayedBinaryIsometricIntegerDivideUtils : public DelayedBinaryIsometricArithmeticUtils { protected: inline static std::shared_ptr dense_mod, sparse_mod, sparse_uns, ref; @@ -520,12 +520,12 @@ class BinaryArithIntegerDivisionUtils : public BinaryArithUtils { return; } - BinaryArithUtils::assemble(); + DelayedBinaryIsometricArithmeticUtils::assemble(); - auto op = tatami::make_DelayedBinaryIntegerDivideHelper(); - dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); - sparse_uns = tatami::make_DelayedBinaryIsometricOp( + auto op = tatami::make_DelayedBinaryIsometricIntegerDivide(); + dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); + sparse_uns = tatami::make_DelayedBinaryIsometricOperation( std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_left)), std::shared_ptr(new tatami_test::UnsortedWrapper(sparse_right)), op @@ -540,14 +540,14 @@ class BinaryArithIntegerDivisionUtils : public BinaryArithUtils { } }; -BINARY_ARITH_BASIC_SETUP(BinaryArithIntegerDivisionTest, BinaryArithIntegerDivisionUtils) -TEST_F(BinaryArithIntegerDivisionTest, Basic) { +BINARY_ARITH_BASIC_SETUP(DelayedBinaryIsometricIntegerDivideTest, DelayedBinaryIsometricIntegerDivideUtils) +TEST_F(DelayedBinaryIsometricIntegerDivideTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); EXPECT_TRUE(dense_mod->prefer_rows()); EXPECT_FALSE(sparse_mod->prefer_rows()); } -BINARY_ARITH_FULL_TEST_WITH_NAN(BinaryArithIntegerDivisionFullTest, BinaryArithIntegerDivisionUtils) -BINARY_ARITH_BLOCK_TEST_WITH_NAN(BinaryArithIntegerDivisionBlockTest, BinaryArithIntegerDivisionUtils) -BINARY_ARITH_INDEX_TEST_WITH_NAN(BinaryArithIntegerDivisionIndexTest, BinaryArithIntegerDivisionUtils) +BINARY_ARITH_FULL_TEST_WITH_NAN(DelayedBinaryIsometricIntegerDivideFullTest, DelayedBinaryIsometricIntegerDivideUtils) +BINARY_ARITH_BLOCK_TEST_WITH_NAN(DelayedBinaryIsometricIntegerDivideBlockTest, DelayedBinaryIsometricIntegerDivideUtils) +BINARY_ARITH_INDEX_TEST_WITH_NAN(DelayedBinaryIsometricIntegerDivideIndexTest, DelayedBinaryIsometricIntegerDivideUtils) diff --git a/tests/src/isometric/binary/boolean_helpers.cpp b/tests/src/isometric/binary/boolean_helpers.cpp index d90dabe4..893deb2e 100644 --- a/tests/src/isometric/binary/boolean_helpers.cpp +++ b/tests/src/isometric/binary/boolean_helpers.cpp @@ -5,13 +5,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/binary/DelayedBinaryIsometricOp.hpp" +#include "tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class BinaryBooleanTest : public ::testing::Test { +class DelayedBinaryIsometricBooleanTest : public ::testing::Test { protected: inline static size_t nrow = 123, ncol = 155; inline static std::shared_ptr dense_left, sparse_left, dense_right, sparse_right; @@ -29,10 +29,10 @@ class BinaryBooleanTest : public ::testing::Test { } }; -TEST_F(BinaryBooleanTest, EQUAL) { - auto op = tatami::make_DelayedBinaryBooleanEqualHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricBooleanTest, EQUAL) { + auto op = tatami::make_DelayedBinaryIsometricBooleanEqual(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -50,10 +50,10 @@ TEST_F(BinaryBooleanTest, EQUAL) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryBooleanTest, AND) { - auto op = tatami::make_DelayedBinaryBooleanAndHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricBooleanTest, AND) { + auto op = tatami::make_DelayedBinaryIsometricBooleanAnd(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -71,10 +71,10 @@ TEST_F(BinaryBooleanTest, AND) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryBooleanTest, OR) { - auto op = tatami::make_DelayedBinaryBooleanOrHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricBooleanTest, OR) { + auto op = tatami::make_DelayedBinaryIsometricBooleanOr(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -92,10 +92,10 @@ TEST_F(BinaryBooleanTest, OR) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryBooleanTest, XOR) { - auto op = tatami::make_DelayedBinaryBooleanXorHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricBooleanTest, XOR) { + auto op = tatami::make_DelayedBinaryIsometricBooleanXor(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); diff --git a/tests/src/isometric/binary/compare_helpers.cpp b/tests/src/isometric/binary/compare_helpers.cpp index f079870a..3a929f61 100644 --- a/tests/src/isometric/binary/compare_helpers.cpp +++ b/tests/src/isometric/binary/compare_helpers.cpp @@ -5,13 +5,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/binary/DelayedBinaryIsometricOp.hpp" +#include "tatami/isometric/binary/DelayedBinaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class BinaryCompareTest : public ::testing::Test { +class DelayedBinaryIsometricCompareTest : public ::testing::Test { protected: inline static size_t nrow = 151, ncol = 71; inline static std::shared_ptr dense_left, sparse_left, dense_right, sparse_right; @@ -31,10 +31,10 @@ class BinaryCompareTest : public ::testing::Test { } }; -TEST_F(BinaryCompareTest, Equal) { - auto op = tatami::make_DelayedBinaryEqualHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, Equal) { + auto op = tatami::make_DelayedBinaryIsometricEqual(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -52,10 +52,10 @@ TEST_F(BinaryCompareTest, Equal) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryCompareTest, GreaterThan) { - auto op = tatami::make_DelayedBinaryGreaterThanHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, GreaterThan) { + auto op = tatami::make_DelayedBinaryIsometricGreaterThan(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -73,10 +73,10 @@ TEST_F(BinaryCompareTest, GreaterThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryCompareTest, LessThan) { - auto op = tatami::make_DelayedBinaryLessThanHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, LessThan) { + auto op = tatami::make_DelayedBinaryIsometricLessThan(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -94,10 +94,10 @@ TEST_F(BinaryCompareTest, LessThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryCompareTest, GreaterThanOrEqual) { - auto op = tatami::make_DelayedBinaryGreaterThanOrEqualHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, GreaterThanOrEqual) { + auto op = tatami::make_DelayedBinaryIsometricGreaterThanOrEqual(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -115,10 +115,10 @@ TEST_F(BinaryCompareTest, GreaterThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryCompareTest, LessThanOrEqual) { - auto op = tatami::make_DelayedBinaryLessThanOrEqualHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, LessThanOrEqual) { + auto op = tatami::make_DelayedBinaryIsometricLessThanOrEqual(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -136,10 +136,10 @@ TEST_F(BinaryCompareTest, LessThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(BinaryCompareTest, NotEqual) { - auto op = tatami::make_DelayedBinaryNotEqualHelper(); - auto dense_mod = tatami::make_DelayedBinaryIsometricOp(dense_left, dense_right, op); - auto sparse_mod = tatami::make_DelayedBinaryIsometricOp(sparse_left, sparse_right, op); +TEST_F(DelayedBinaryIsometricCompareTest, NotEqual) { + auto op = tatami::make_DelayedBinaryIsometricNotEqual(); + auto dense_mod = tatami::make_DelayedBinaryIsometricOperation(dense_left, dense_right, op); + auto sparse_mod = tatami::make_DelayedBinaryIsometricOperation(sparse_left, sparse_right, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); diff --git a/tests/src/isometric/unary/DelayedUnaryIsometricOp.cpp b/tests/src/isometric/unary/DelayedUnaryIsometricOperation.cpp similarity index 75% rename from tests/src/isometric/unary/DelayedUnaryIsometricOp.cpp rename to tests/src/isometric/unary/DelayedUnaryIsometricOperation.cpp index bfe947b9..94f88633 100644 --- a/tests/src/isometric/unary/DelayedUnaryIsometricOp.cpp +++ b/tests/src/isometric/unary/DelayedUnaryIsometricOperation.cpp @@ -5,27 +5,27 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -TEST(DelayedUnaryIsometricOp, ConstOverload) { +TEST(DelayedUnaryIsometricOperation, ConstOverload) { int nrow = 23, ncol = 42; auto simulated = tatami_test::simulate_sparse_vector(nrow * ncol, 0.1); auto dense = std::shared_ptr(new tatami::DenseRowMatrix(nrow, ncol, simulated)); auto vec = std::vector(nrow); - auto op = tatami::make_DelayedAddVectorHelper<0>(vec); - auto mat = tatami::make_DelayedUnaryIsometricOp(dense, std::move(op)); + auto op = tatami::make_DelayedUnaryIsometricAddVector<0>(vec); + auto mat = tatami::make_DelayedUnaryIsometricOperation(dense, std::move(op)); // cursory checks. EXPECT_EQ(mat->nrow(), dense->nrow()); EXPECT_EQ(mat->ncol(), dense->ncol()); } -class DelayedUnaryIsometricOpMockTest : public ::testing::TestWithParam > { +class DelayedUnaryIsometricOperationTest : public ::testing::TestWithParam > { protected: inline static int nrow = 57, ncol = 37; inline static std::vector simulated; @@ -36,13 +36,13 @@ class DelayedUnaryIsometricOpMockTest : public ::testing::TestWithParam(nrow, ncol, std::move(simulated))); sparse = tatami::convert_to_compressed_sparse(dense.get()); - udense = tatami::make_DelayedUnaryIsometricOp(dense, tatami::DelayedUnaryBasicMockHelper()); - usparse = tatami::make_DelayedUnaryIsometricOp(sparse, tatami::DelayedUnaryAdvancedMockHelper()); + udense = tatami::make_DelayedUnaryIsometricOperation(dense, tatami::DelayedUnaryIsometricMockBasic()); + usparse = tatami::make_DelayedUnaryIsometricOperation(sparse, tatami::DelayedUnaryIsometricMockAdvanced()); ref.reset(new tatami::DenseRowMatrix(nrow, ncol, std::vector(nrow * ncol))); } }; -TEST_P(DelayedUnaryIsometricOpMockTest, Mock) { +TEST_P(DelayedUnaryIsometricOperationTest, Mock) { EXPECT_FALSE(udense->is_sparse()); EXPECT_EQ(udense->is_sparse_proportion(), 0); @@ -65,8 +65,8 @@ TEST_P(DelayedUnaryIsometricOpMockTest, Mock) { } INSTANTIATE_TEST_SUITE_P( - DelayedUnary, - DelayedUnaryIsometricOpMockTest, + DelayedUnaryIsometricOperation, + DelayedUnaryIsometricOperationTest, ::testing::Combine( ::testing::Values(true, false), // row access ::testing::Values(true, false) // oracle usage diff --git a/tests/src/isometric/unary/arith_scalar_helpers.cpp b/tests/src/isometric/unary/arithmetic_scalar_helpers.cpp similarity index 62% rename from tests/src/isometric/unary/arith_scalar_helpers.cpp rename to tests/src/isometric/unary/arithmetic_scalar_helpers.cpp index e6c61a3c..e3a8b8ac 100644 --- a/tests/src/isometric/unary/arith_scalar_helpers.cpp +++ b/tests/src/isometric/unary/arithmetic_scalar_helpers.cpp @@ -6,13 +6,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class ArithScalarUtils { +class DelayedUnaryIsometricUtilsScalar { protected: inline static size_t nrow = 123, ncol = 89; inline static std::shared_ptr dense, sparse; @@ -32,19 +32,19 @@ class ArithScalarUtils { ********* COMMUTATIVE ********* *******************************/ -class ArithCommutativeScalarTest : public ::testing::TestWithParam, public ArithScalarUtils { +class DelayedUnaryIsometricArithmeticCommutativeScalarTest : public ::testing::TestWithParam, public DelayedUnaryIsometricUtilsScalar { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithCommutativeScalarTest, Addition) { +TEST_P(DelayedUnaryIsometricArithmeticCommutativeScalarTest, Add) { double val = GetParam(); - auto op = tatami::make_DelayedAddScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricAddScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -68,11 +68,11 @@ TEST_P(ArithCommutativeScalarTest, Addition) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(ArithCommutativeScalarTest, Multiplication) { +TEST_P(DelayedUnaryIsometricArithmeticCommutativeScalarTest, Multiply) { double val = GetParam(); - auto op = tatami::make_DelayedMultiplyScalarHelper(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricMultiplyScalar(val); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_EQ(dense->nrow(), dense_mod->nrow()); EXPECT_EQ(dense->ncol(), dense_mod->ncol()); @@ -89,8 +89,8 @@ TEST_P(ArithCommutativeScalarTest, Multiplication) { } INSTANTIATE_TEST_SUITE_P( - ArithScalar, - ArithCommutativeScalarTest, + DelayedUnaryIsometricArithmeticScalar, + DelayedUnaryIsometricArithmeticCommutativeScalarTest, ::testing::Values(5, 0.1, -0.7, 0) ); @@ -98,27 +98,27 @@ INSTANTIATE_TEST_SUITE_P( ********* NON-COMMUTATIVE ********* ***********************************/ -class ArithNonCommutativeScalarTest : public ::testing::TestWithParam >, public ArithScalarUtils { +class DelayedUnaryIsometricArithmeticNonCommutativeScalarTest : public ::testing::TestWithParam >, public DelayedUnaryIsometricUtilsScalar { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithNonCommutativeScalarTest, Subtraction) { +TEST_P(DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, Subtract) { std::shared_ptr dense_mod, sparse_mod; auto my_param = GetParam(); double val = std::get<0>(my_param); bool on_right = std::get<1>(my_param); if (on_right) { - auto op = tatami::make_DelayedSubtractScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedSubtractScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -146,20 +146,20 @@ TEST_P(ArithNonCommutativeScalarTest, Subtraction) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(ArithNonCommutativeScalarTest, Division) { +TEST_P(DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, Divide) { std::shared_ptr dense_mod, sparse_mod; auto my_param = GetParam(); double val = std::get<0>(my_param); bool on_right = std::get<1>(my_param); if (on_right) { - auto op = tatami::make_DelayedDivideScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedDivideScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -185,24 +185,24 @@ TEST_P(ArithNonCommutativeScalarTest, Division) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ (val == 0)); } -TEST_P(ArithNonCommutativeScalarTest, Power) { +TEST_P(DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, Power) { std::shared_ptr dense_mod, sparse_mod; - tatami::DelayedAbsHelper op0; - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op0); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op0); + tatami::DelayedUnaryIsometricAbs op0; + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op0); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op0); auto my_param = GetParam(); double val = std::abs(std::get<0>(my_param)); bool on_right = std::get<1>(my_param); if (on_right) { - auto op = tatami::make_DelayedPowerScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense_mod, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse_mod, op); + auto op = tatami::make_DelayedUnaryIsometricPowerScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense_mod, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse_mod, op); } else { - auto op = tatami::make_DelayedPowerScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense_mod, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse_mod, op); + auto op = tatami::make_DelayedUnaryIsometricPowerScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense_mod, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse_mod, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -230,20 +230,20 @@ TEST_P(ArithNonCommutativeScalarTest, Power) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(ArithNonCommutativeScalarTest, Modulo) { +TEST_P(DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, Modulo) { std::shared_ptr dense_mod, sparse_mod; auto my_param = GetParam(); double val = std::get<0>(my_param); bool on_right = std::get<1>(my_param); if (on_right) { - auto op = tatami::make_DelayedModuloScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedModuloScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -270,20 +270,20 @@ TEST_P(ArithNonCommutativeScalarTest, Modulo) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ !(on_right && val)); } -TEST_P(ArithNonCommutativeScalarTest, IntegerDivision) { +TEST_P(DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, IntegerDivide) { std::shared_ptr dense_mod, sparse_mod; auto my_param = GetParam(); double val = std::get<0>(my_param); bool on_right = std::get<1>(my_param); if (on_right) { - auto op = tatami::make_DelayedIntegerDivideScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedIntegerDivideScalarHelper(val); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideScalar(val); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -312,8 +312,8 @@ TEST_P(ArithNonCommutativeScalarTest, IntegerDivision) { } INSTANTIATE_TEST_SUITE_P( - ArithScalar, - ArithNonCommutativeScalarTest, + DelayedUnaryIsometricArithmeticScalar, + DelayedUnaryIsometricArithmeticNonCommutativeScalarTest, ::testing::Combine( ::testing::Values(5, 0.1, -0.7, 0), ::testing::Values(true, false) @@ -324,19 +324,19 @@ INSTANTIATE_TEST_SUITE_P( ********* SPECIAL VALUES ********* **********************************/ -TEST(ArithScalarTest, NonIeee754Multiply) { +TEST(DelayedUnaryIsometricArithmeticScalar, NonIeee754Multiply) { int scalar = 5; - auto op = tatami::make_DelayedMultiplyScalarHelper(scalar); + auto op = tatami::make_DelayedUnaryIsometricMultiplyScalar(scalar); EXPECT_TRUE(op.is_sparse()); } -TEST(ArithScalarTest, NonFiniteMultiply) { +TEST(DelayedUnaryIsometricArithmeticScalar, NonFiniteMultiply) { double scalar = std::numeric_limits::infinity(); - auto op = tatami::make_DelayedMultiplyScalarHelper(scalar); + auto op = tatami::make_DelayedUnaryIsometricMultiplyScalar(scalar); EXPECT_FALSE(op.is_sparse()); } -TEST(ArithScalarTest, NonIeee754Divide) { - auto op = tatami::make_DelayedDivideScalarHelper(5.0); +TEST(DelayedUnaryIsometricArithmeticScalar, NonIeee754Divide) { + auto op = tatami::make_DelayedUnaryIsometricDivideScalar(5.0); tatami_test::throws_error([&]() { op.template fill(5); }, "IEEE-754"); } diff --git a/tests/src/isometric/unary/arith_vector_helpers.cpp b/tests/src/isometric/unary/arithmetic_vector_helpers.cpp similarity index 73% rename from tests/src/isometric/unary/arith_vector_helpers.cpp rename to tests/src/isometric/unary/arithmetic_vector_helpers.cpp index 174d5754..904c625d 100644 --- a/tests/src/isometric/unary/arith_vector_helpers.cpp +++ b/tests/src/isometric/unary/arithmetic_vector_helpers.cpp @@ -5,13 +5,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class ArithVectorUtils { +class DelayedUnaryIsometricArithmeticVectorUtils { protected: inline static size_t nrow = 291, ncol = 188; inline static std::shared_ptr dense, sparse; @@ -67,7 +67,7 @@ class ArithVectorUtils { }; \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ base::simulation_parameter_combinations() \ ); @@ -89,7 +89,7 @@ class ArithVectorUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -118,7 +118,7 @@ class ArithVectorUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -152,7 +152,7 @@ class ArithVectorUtils { } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -169,7 +169,7 @@ class ArithVectorUtils { ********* ADDITION ********* ****************************/ -class ArithVectorAdditionUtils : public ArithVectorUtils { +class DelayedUnaryIsometricAddVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -186,13 +186,13 @@ class ArithVectorAdditionUtils : public ArithVectorUtils { std::shared_ptr& sparse_ptr) { if (row) { - auto op = tatami::make_DelayedAddVectorHelper<0>(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricAddVector<0>(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedAddVectorHelper<1>(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricAddVector<1>(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } @@ -202,7 +202,7 @@ class ArithVectorAdditionUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto vec = create_vector(row ? nrow : ncol, 5, 0.5); @@ -218,8 +218,8 @@ class ArithVectorAdditionUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorAdditionTest, ArithVectorAdditionUtils) -TEST_P(ArithVectorAdditionTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricAddVectorTest, DelayedUnaryIsometricAddVectorUtils) +TEST_P(DelayedUnaryIsometricAddVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense_mod->is_sparse_proportion(), 0); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -233,24 +233,24 @@ TEST_P(ArithVectorAdditionTest, Basic) { EXPECT_EQ(sparse_mod->prefer_rows_proportion(), 0); } -ARITH_VECTOR_FULL_TEST(ArithVectorAdditionFullTest, ArithVectorAdditionUtils) -ARITH_VECTOR_BLOCK_TEST(ArithVectorAdditionBlockTest, ArithVectorAdditionUtils) -ARITH_VECTOR_INDEX_TEST(ArithVectorAdditionIndexTest, ArithVectorAdditionUtils) +ARITH_VECTOR_FULL_TEST(DelayedUnaryIsometricAddVectorFullTest, DelayedUnaryIsometricAddVectorUtils) +ARITH_VECTOR_BLOCK_TEST(DelayedUnaryIsometricAddVectorBlockTest, DelayedUnaryIsometricAddVectorUtils) +ARITH_VECTOR_INDEX_TEST(DelayedUnaryIsometricAddVectorIndexTest, DelayedUnaryIsometricAddVectorUtils) -class ArithVectorAdditionZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricAddVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorAdditionZeroedTest, Basic) { +TEST_P(DelayedUnaryIsometricAddVectorZeroedTest, Basic) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorAdditionUtils::apply_operation(row, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricAddVectorUtils::apply_operation(row, zeroed, dense_z, sparse_z); EXPECT_FALSE(dense_z->is_sparse()); EXPECT_TRUE(sparse_z->is_sparse()); @@ -263,16 +263,16 @@ TEST_P(ArithVectorAdditionZeroedTest, Basic) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorAdditionZeroedTest, - ArithVectorAdditionUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricAddVectorZeroedTest, + DelayedUnaryIsometricAddVectorUtils::simulation_parameter_combinations() ); /******************************* ********* SUBTRACTION ********* *******************************/ -class ArithVectorSubtractionUtils : public ArithVectorUtils { +class DelayedUnaryIsometricSubtractVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -292,23 +292,23 @@ class ArithVectorSubtractionUtils : public ArithVectorUtils { { if (row) { if (right) { - auto op = tatami::make_DelayedSubtractVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedSubtractVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } else { if (right) { - auto op = tatami::make_DelayedSubtractVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedSubtractVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricSubtractVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } } @@ -319,7 +319,7 @@ class ArithVectorSubtractionUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -341,8 +341,8 @@ class ArithVectorSubtractionUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorSubtractionTest, ArithVectorSubtractionUtils) -TEST_P(ArithVectorSubtractionTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricSubtractVectorTest, DelayedUnaryIsometricSubtractVectorUtils) +TEST_P(DelayedUnaryIsometricSubtractVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); EXPECT_EQ(dense->nrow(), dense_mod->nrow()); @@ -352,25 +352,25 @@ TEST_P(ArithVectorSubtractionTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST(ArithVectorSubtractionFullTest, ArithVectorSubtractionUtils) -ARITH_VECTOR_BLOCK_TEST(ArithVectorSubtractionBlockTest, ArithVectorSubtractionUtils) -ARITH_VECTOR_INDEX_TEST(ArithVectorSubtractionIndexTest, ArithVectorSubtractionUtils) +ARITH_VECTOR_FULL_TEST(DelayedUnaryIsometricSubtractVectorFullTest, DelayedUnaryIsometricSubtractVectorUtils) +ARITH_VECTOR_BLOCK_TEST(DelayedUnaryIsometricSubtractVectorBlockTest, DelayedUnaryIsometricSubtractVectorUtils) +ARITH_VECTOR_INDEX_TEST(DelayedUnaryIsometricSubtractVectorIndexTest, DelayedUnaryIsometricSubtractVectorUtils) -class ArithVectorSubtractionZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricSubtractVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorSubtractionZeroedTest, Basic) { +TEST_P(DelayedUnaryIsometricSubtractVectorZeroedTest, Basic) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorSubtractionUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricSubtractVectorUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); EXPECT_FALSE(dense_z->is_sparse()); EXPECT_TRUE(sparse_z->is_sparse()); @@ -397,16 +397,16 @@ TEST_P(ArithVectorSubtractionZeroedTest, Basic) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorSubtractionZeroedTest, - ArithVectorSubtractionUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricSubtractVectorZeroedTest, + DelayedUnaryIsometricSubtractVectorUtils::simulation_parameter_combinations() ); /********************************** ********* MULTIPLICATION ********* **********************************/ -class ArithVectorMultiplicationUtils : public ArithVectorUtils { +class DelayedUnaryIsometricMultiplyVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -423,13 +423,13 @@ class ArithVectorMultiplicationUtils : public ArithVectorUtils { std::shared_ptr& sparse_ptr) { if (row) { - auto op = tatami::make_DelayedMultiplyVectorHelper<0>(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricMultiplyVector<0>(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedMultiplyVectorHelper<1>(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricMultiplyVector<1>(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } @@ -439,7 +439,7 @@ class ArithVectorMultiplicationUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto vec = create_vector(row ? nrow : ncol, 99, -2.5); @@ -455,8 +455,8 @@ class ArithVectorMultiplicationUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorMultiplicationTest, ArithVectorMultiplicationUtils) -TEST_P(ArithVectorMultiplicationTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricMultiplyVectorTest, DelayedUnaryIsometricMultiplyVectorUtils) +TEST_P(DelayedUnaryIsometricMultiplyVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense_mod->is_sparse_proportion(), 0); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -468,24 +468,24 @@ TEST_P(ArithVectorMultiplicationTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST(ArithVectorMultiplicationFullTest, ArithVectorMultiplicationUtils) -ARITH_VECTOR_BLOCK_TEST(ArithVectorMultiplicationBlockTest, ArithVectorMultiplicationUtils) -ARITH_VECTOR_INDEX_TEST(ArithVectorMultiplicationIndexTest, ArithVectorMultiplicationUtils) +ARITH_VECTOR_FULL_TEST(DelayedUnaryIsometricMultiplyVectorFullTest, DelayedUnaryIsometricMultiplyVectorUtils) +ARITH_VECTOR_BLOCK_TEST(DelayedUnaryIsometricMultiplyVectorBlockTest, DelayedUnaryIsometricMultiplyVectorUtils) +ARITH_VECTOR_INDEX_TEST(DelayedUnaryIsometricMultiplyVectorIndexTest, DelayedUnaryIsometricMultiplyVectorUtils) -class ArithVectorMultiplicationZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricMultiplyVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorMultiplicationZeroedTest, Basic) { +TEST_P(DelayedUnaryIsometricMultiplyVectorZeroedTest, Basic) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorMultiplicationUtils::apply_operation(row, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricMultiplyVectorUtils::apply_operation(row, zeroed, dense_z, sparse_z); tatami::DenseRowMatrix ref(nrow, ncol, std::vector(nrow * ncol)); @@ -497,16 +497,16 @@ TEST_P(ArithVectorMultiplicationZeroedTest, Basic) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorMultiplicationZeroedTest, - ArithVectorMultiplicationUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricMultiplyVectorZeroedTest, + DelayedUnaryIsometricMultiplyVectorUtils::simulation_parameter_combinations() ); /**************************** ********* DIVISION ********* ****************************/ -class ArithVectorDivisionUtils : public ArithVectorUtils { +class DelayedUnaryIsometricDivideVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -526,23 +526,23 @@ class ArithVectorDivisionUtils : public ArithVectorUtils { { if (row) { if (right) { - auto op = tatami::make_DelayedDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } else { if (right) { - auto op = tatami::make_DelayedDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } } @@ -553,7 +553,7 @@ class ArithVectorDivisionUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -582,8 +582,8 @@ class ArithVectorDivisionUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorDivisionTest, ArithVectorDivisionUtils) -TEST_P(ArithVectorDivisionTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricDivideVectorTest, DelayedUnaryIsometricDivideVectorUtils) +TEST_P(DelayedUnaryIsometricDivideVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); auto right = std::get<1>(last_params); @@ -600,25 +600,25 @@ TEST_P(ArithVectorDivisionTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST(ArithVectorDivisionFullTest, ArithVectorDivisionUtils); -ARITH_VECTOR_BLOCK_TEST(ArithVectorDivisionBlockTest, ArithVectorDivisionUtils); -ARITH_VECTOR_INDEX_TEST(ArithVectorDivisionIndexTest, ArithVectorDivisionUtils); +ARITH_VECTOR_FULL_TEST(DelayedUnaryIsometricDivideVectorFullTest, DelayedUnaryIsometricDivideVectorUtils); +ARITH_VECTOR_BLOCK_TEST(DelayedUnaryIsometricDivideVectorBlockTest, DelayedUnaryIsometricDivideVectorUtils); +ARITH_VECTOR_INDEX_TEST(DelayedUnaryIsometricDivideVectorIndexTest, DelayedUnaryIsometricDivideVectorUtils); -class ArithVectorDivisionZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricDivideVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorDivisionZeroedTest, AllZero) { +TEST_P(DelayedUnaryIsometricDivideVectorZeroedTest, AllZero) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorDivisionUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricDivideVectorUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); auto copy = simulated; if (right) { @@ -643,7 +643,7 @@ TEST_P(ArithVectorDivisionZeroedTest, AllZero) { test_simple_row_access_wt_nan(sparse_z.get(), &ref); } -TEST_P(ArithVectorDivisionZeroedTest, OneZero) { +TEST_P(DelayedUnaryIsometricDivideVectorZeroedTest, OneZero) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -652,7 +652,7 @@ TEST_P(ArithVectorDivisionZeroedTest, OneZero) { std::vector solo_zero(row ? nrow : ncol, 1); solo_zero[0] = 0; std::shared_ptr dense_z, sparse_z; - ArithVectorDivisionUtils::apply_operation(row, right, solo_zero, dense_z, sparse_z); + DelayedUnaryIsometricDivideVectorUtils::apply_operation(row, right, solo_zero, dense_z, sparse_z); auto copy = simulated; if (row) { @@ -696,16 +696,16 @@ TEST_P(ArithVectorDivisionZeroedTest, OneZero) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorDivisionZeroedTest, - ArithVectorDivisionUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricDivideVectorZeroedTest, + DelayedUnaryIsometricDivideVectorUtils::simulation_parameter_combinations() ); /**************************** ********** POWER *********** ****************************/ -class ArithVectorPowerUtils : public ArithVectorUtils { +class DelayedUnaryIsometricPowerVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -723,29 +723,29 @@ class ArithVectorPowerUtils : public ArithVectorUtils { std::shared_ptr& dense_ptr, std::shared_ptr& sparse_ptr) { - tatami::DelayedAbsHelper op0; - auto dense_tmp = tatami::make_DelayedUnaryIsometricOp(dense, op0); - auto sparse_tmp = tatami::make_DelayedUnaryIsometricOp(sparse, op0); + tatami::DelayedUnaryIsometricAbs op0; + auto dense_tmp = tatami::make_DelayedUnaryIsometricOperation(dense, op0); + auto sparse_tmp = tatami::make_DelayedUnaryIsometricOperation(sparse, op0); if (row) { if (right) { - auto op = tatami::make_DelayedPowerVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense_tmp, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse_tmp, op); + auto op = tatami::make_DelayedUnaryIsometricPowerVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense_tmp, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse_tmp, op); } else { - auto op = tatami::make_DelayedPowerVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense_tmp, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse_tmp, op); + auto op = tatami::make_DelayedUnaryIsometricPowerVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense_tmp, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse_tmp, op); } } else { if (right) { - auto op = tatami::make_DelayedPowerVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense_tmp, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse_tmp, op); + auto op = tatami::make_DelayedUnaryIsometricPowerVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense_tmp, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse_tmp, op); } else { - auto op = tatami::make_DelayedPowerVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense_tmp, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse_tmp, op); + auto op = tatami::make_DelayedUnaryIsometricPowerVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense_tmp, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse_tmp, op); } } } @@ -756,7 +756,7 @@ class ArithVectorPowerUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -779,8 +779,8 @@ class ArithVectorPowerUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorPowerTest, ArithVectorPowerUtils) -TEST_P(ArithVectorPowerTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricPowerVectorTest, DelayedUnaryIsometricPowerVectorUtils) +TEST_P(DelayedUnaryIsometricPowerVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); auto right = std::get<1>(last_params); @@ -797,25 +797,25 @@ TEST_P(ArithVectorPowerTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST(ArithVectorPowerFullTest, ArithVectorPowerUtils); -ARITH_VECTOR_BLOCK_TEST(ArithVectorPowerBlockTest, ArithVectorPowerUtils); -ARITH_VECTOR_INDEX_TEST(ArithVectorPowerIndexTest, ArithVectorPowerUtils); +ARITH_VECTOR_FULL_TEST(DelayedUnaryIsometricPowerVectorFullTest, DelayedUnaryIsometricPowerVectorUtils); +ARITH_VECTOR_BLOCK_TEST(DelayedUnaryIsometricPowerVectorBlockTest, DelayedUnaryIsometricPowerVectorUtils); +ARITH_VECTOR_INDEX_TEST(DelayedUnaryIsometricPowerVectorIndexTest, DelayedUnaryIsometricPowerVectorUtils); -class ArithVectorPowerZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricPowerVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorPowerZeroedTest, AllZero) { +TEST_P(DelayedUnaryIsometricPowerVectorZeroedTest, AllZero) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorPowerUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricPowerVectorUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); auto copy = simulated; if (right) { @@ -840,7 +840,7 @@ TEST_P(ArithVectorPowerZeroedTest, AllZero) { test_simple_row_access_wt_nan(sparse_z.get(), &ref); } -TEST_P(ArithVectorPowerZeroedTest, OneZero) { +TEST_P(DelayedUnaryIsometricPowerVectorZeroedTest, OneZero) { // But actually, even 1 zero is enough to break sparsity. auto sim_params = GetParam(); auto row = std::get<0>(sim_params); @@ -849,7 +849,7 @@ TEST_P(ArithVectorPowerZeroedTest, OneZero) { std::vector solo_zero(row ? nrow : ncol, 1); solo_zero[0] = 0; std::shared_ptr dense_z, sparse_z; - ArithVectorPowerUtils::apply_operation(row, right, solo_zero, dense_z, sparse_z); + DelayedUnaryIsometricPowerVectorUtils::apply_operation(row, right, solo_zero, dense_z, sparse_z); auto copy = simulated; for (auto& x : copy) { @@ -896,9 +896,9 @@ TEST_P(ArithVectorPowerZeroedTest, OneZero) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorPowerZeroedTest, - ArithVectorPowerUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricPowerVectorZeroedTest, + DelayedUnaryIsometricPowerVectorUtils::simulation_parameter_combinations() ); /**************************** @@ -923,7 +923,7 @@ INSTANTIATE_TEST_SUITE_P( } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -953,7 +953,7 @@ INSTANTIATE_TEST_SUITE_P( } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -988,7 +988,7 @@ INSTANTIATE_TEST_SUITE_P( } \ \ INSTANTIATE_TEST_SUITE_P( \ - ArithVector, \ + DelayedUnaryIsometricArithmeticVector, \ name, \ ::testing::Combine( \ name::simulation_parameter_combinations(), \ @@ -1002,7 +1002,7 @@ INSTANTIATE_TEST_SUITE_P( ); -class ArithVectorModuloUtils : public ArithVectorUtils { +class DelayedUnaryIsometricModuloVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -1022,23 +1022,23 @@ class ArithVectorModuloUtils : public ArithVectorUtils { { if (row) { if (right) { - auto op = tatami::make_DelayedModuloVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedModuloVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } else { if (right) { - auto op = tatami::make_DelayedModuloVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedModuloVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricModuloVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } } @@ -1049,7 +1049,7 @@ class ArithVectorModuloUtils : public ArithVectorUtils { static void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -1072,8 +1072,8 @@ class ArithVectorModuloUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorModuloTest, ArithVectorModuloUtils); -TEST_P(ArithVectorModuloTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricModuloVectorTest, DelayedUnaryIsometricModuloVectorUtils); +TEST_P(DelayedUnaryIsometricModuloVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); auto right = std::get<1>(last_params); @@ -1090,25 +1090,25 @@ TEST_P(ArithVectorModuloTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST_WITH_NAN(ArithVectorModuloFullTest, ArithVectorModuloUtils); -ARITH_VECTOR_BLOCK_TEST_WITH_NAN(ArithVectorModuloBlockTest, ArithVectorModuloUtils); -ARITH_VECTOR_INDEX_TEST_WITH_NAN(ArithVectorModuloIndexTest, ArithVectorModuloUtils); +ARITH_VECTOR_FULL_TEST_WITH_NAN(DelayedUnaryIsometricModuloVectorFullTest, DelayedUnaryIsometricModuloVectorUtils); +ARITH_VECTOR_BLOCK_TEST_WITH_NAN(DelayedUnaryIsometricModuloVectorBlockTest, DelayedUnaryIsometricModuloVectorUtils); +ARITH_VECTOR_INDEX_TEST_WITH_NAN(DelayedUnaryIsometricModuloVectorIndexTest, DelayedUnaryIsometricModuloVectorUtils); -class ArithVectorModuloZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricModuloVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorModuloZeroedTest, AllZero) { +TEST_P(DelayedUnaryIsometricModuloVectorZeroedTest, AllZero) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorModuloUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricModuloVectorUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); auto copy = simulated; if (right) { @@ -1134,16 +1134,16 @@ TEST_P(ArithVectorModuloZeroedTest, AllZero) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorModuloZeroedTest, - ArithVectorModuloUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricModuloVectorZeroedTest, + DelayedUnaryIsometricModuloVectorUtils::simulation_parameter_combinations() ); /**************************** ***** INTEGER DIVISION ***** ****************************/ -class ArithVectorIntegerDivisionUtils : public ArithVectorUtils { +class DelayedUnaryIsometricIntegerDivideVectorUtils : public DelayedUnaryIsometricArithmeticVectorUtils { public: typedef std::tuple SimulationParameters; @@ -1163,23 +1163,23 @@ class ArithVectorIntegerDivisionUtils : public ArithVectorUtils { { if (row) { if (right) { - auto op = tatami::make_DelayedIntegerDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedIntegerDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } else { if (right) { - auto op = tatami::make_DelayedIntegerDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedIntegerDivideVectorHelper(vec); - dense_ptr = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_ptr = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricIntegerDivideVector(vec); + dense_ptr = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_ptr = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } } } @@ -1190,7 +1190,7 @@ class ArithVectorIntegerDivisionUtils : public ArithVectorUtils { void assemble(SimulationParameters sim_params) { ARITH_VECTOR_CONFIGURE(sim_params); - ArithVectorUtils::assemble(); + DelayedUnaryIsometricArithmeticVectorUtils::assemble(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); @@ -1214,8 +1214,8 @@ class ArithVectorIntegerDivisionUtils : public ArithVectorUtils { } }; -ARITH_VECTOR_BASIC_SETUP(ArithVectorIntegerDivisionTest, ArithVectorIntegerDivisionUtils); -TEST_P(ArithVectorIntegerDivisionTest, Basic) { +ARITH_VECTOR_BASIC_SETUP(DelayedUnaryIsometricIntegerDivideVectorTest, DelayedUnaryIsometricIntegerDivideVectorUtils); +TEST_P(DelayedUnaryIsometricIntegerDivideVectorTest, Basic) { EXPECT_FALSE(dense_mod->is_sparse()); auto right = std::get<1>(last_params); @@ -1232,25 +1232,25 @@ TEST_P(ArithVectorIntegerDivisionTest, Basic) { EXPECT_FALSE(sparse_mod->prefer_rows()); } -ARITH_VECTOR_FULL_TEST_WITH_NAN(ArithVectorIntegerDivisionFullTest, ArithVectorIntegerDivisionUtils); -ARITH_VECTOR_BLOCK_TEST_WITH_NAN(ArithVectorIntegerDivisionBlockTest, ArithVectorIntegerDivisionUtils); -ARITH_VECTOR_INDEX_TEST_WITH_NAN(ArithVectorIntegerDivisionIndexTest, ArithVectorIntegerDivisionUtils); +ARITH_VECTOR_FULL_TEST_WITH_NAN(DelayedUnaryIsometricIntegerDivideVectorFullTest, DelayedUnaryIsometricIntegerDivideVectorUtils); +ARITH_VECTOR_BLOCK_TEST_WITH_NAN(DelayedUnaryIsometricIntegerDivideVectorBlockTest, DelayedUnaryIsometricIntegerDivideVectorUtils); +ARITH_VECTOR_INDEX_TEST_WITH_NAN(DelayedUnaryIsometricIntegerDivideVectorIndexTest, DelayedUnaryIsometricIntegerDivideVectorUtils); -class ArithVectorIntegerDivisionZeroedTest : public ::testing::TestWithParam, public ArithVectorUtils { +class DelayedUnaryIsometricIntegerDivideVectorZeroedTest : public ::testing::TestWithParam, public DelayedUnaryIsometricArithmeticVectorUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(ArithVectorIntegerDivisionZeroedTest, AllZero) { +TEST_P(DelayedUnaryIsometricIntegerDivideVectorZeroedTest, AllZero) { auto sim_params = GetParam(); auto row = std::get<0>(sim_params); auto right = std::get<1>(sim_params); std::vector zeroed(row ? nrow : ncol); std::shared_ptr dense_z, sparse_z; - ArithVectorIntegerDivisionUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); + DelayedUnaryIsometricIntegerDivideVectorUtils::apply_operation(row, right, zeroed, dense_z, sparse_z); auto copy = simulated; if (right) { @@ -1277,7 +1277,7 @@ TEST_P(ArithVectorIntegerDivisionZeroedTest, AllZero) { } INSTANTIATE_TEST_SUITE_P( - ArithVector, - ArithVectorIntegerDivisionZeroedTest, - ArithVectorIntegerDivisionUtils::simulation_parameter_combinations() + DelayedUnaryIsometricArithmeticVector, + DelayedUnaryIsometricIntegerDivideVectorZeroedTest, + DelayedUnaryIsometricIntegerDivideVectorUtils::simulation_parameter_combinations() ); diff --git a/tests/src/isometric/unary/boolean_scalar_helpers.cpp b/tests/src/isometric/unary/boolean_scalar_helpers.cpp index 444c6965..49417d8e 100644 --- a/tests/src/isometric/unary/boolean_scalar_helpers.cpp +++ b/tests/src/isometric/unary/boolean_scalar_helpers.cpp @@ -5,13 +5,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class BooleanScalarUtils { +class DelayedUnaryIsometricBooleanScalarUtils { protected: inline static size_t nrow = 83, ncol = 111; inline static std::shared_ptr dense, sparse; @@ -27,19 +27,19 @@ class BooleanScalarUtils { } }; -class BooleanScalarTest : public ::testing::TestWithParam, public BooleanScalarUtils { +class DelayedUnaryIsometricBooleanScalarTest : public ::testing::TestWithParam, public DelayedUnaryIsometricBooleanScalarUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_P(BooleanScalarTest, AND) { +TEST_P(DelayedUnaryIsometricBooleanScalarTest, AND) { bool other = GetParam(); - auto op = tatami::make_DelayedBooleanAndScalarHelper(other); + auto op = tatami::make_DelayedUnaryIsometricBooleanAndScalar(other); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -59,12 +59,12 @@ TEST_P(BooleanScalarTest, AND) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanScalarTest, OR) { +TEST_P(DelayedUnaryIsometricBooleanScalarTest, OR) { bool other = GetParam(); - auto op = tatami::make_DelayedBooleanOrScalarHelper(other); + auto op = tatami::make_DelayedUnaryIsometricBooleanOrScalar(other); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -89,12 +89,12 @@ TEST_P(BooleanScalarTest, OR) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanScalarTest, XOR) { +TEST_P(DelayedUnaryIsometricBooleanScalarTest, XOR) { bool other = GetParam(); - auto op = tatami::make_DelayedBooleanXorScalarHelper(other); + auto op = tatami::make_DelayedUnaryIsometricBooleanXorScalar(other); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -119,12 +119,12 @@ TEST_P(BooleanScalarTest, XOR) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanScalarTest, EQUAL) { +TEST_P(DelayedUnaryIsometricBooleanScalarTest, EQUAL) { bool other = GetParam(); - auto op = tatami::make_DelayedBooleanEqualScalarHelper(other); + auto op = tatami::make_DelayedUnaryIsometricBooleanEqualScalar(other); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -150,22 +150,22 @@ TEST_P(BooleanScalarTest, EQUAL) { } INSTANTIATE_TEST_SUITE_P( - BooleanScalar, - BooleanScalarTest, + DelayedUnaryIsometricBooleanScalar, + DelayedUnaryIsometricBooleanScalarTest, ::testing::Values(true, false) ); -class BooleanNotTest : public ::testing::Test, public BooleanScalarUtils { +class DelayedUnaryIsometricBooleanNotTest : public ::testing::Test, public DelayedUnaryIsometricBooleanScalarUtils { protected: static void SetUpTestSuite() { assemble(); } }; -TEST_F(BooleanNotTest, Basic) { - auto op = tatami::make_DelayedBooleanNotHelper(); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricBooleanNotTest, Basic) { + auto op = tatami::make_DelayedUnaryIsometricBooleanNot(); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); diff --git a/tests/src/isometric/unary/boolean_vector_helpers.cpp b/tests/src/isometric/unary/boolean_vector_helpers.cpp index f3de3c68..e3722453 100644 --- a/tests/src/isometric/unary/boolean_vector_helpers.cpp +++ b/tests/src/isometric/unary/boolean_vector_helpers.cpp @@ -4,13 +4,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class BooleanVectorTest : public ::testing::TestWithParam > { +class DelayedUnaryIsometricBooleanVectorTest : public ::testing::TestWithParam > { protected: inline static size_t nrow = 191, ncol = 88; inline static std::shared_ptr dense, sparse; @@ -31,7 +31,7 @@ class BooleanVectorTest : public ::testing::TestWithParam } }; -TEST_P(BooleanVectorTest, AND) { +TEST_P(DelayedUnaryIsometricBooleanVectorTest, AND) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -45,13 +45,13 @@ TEST_P(BooleanVectorTest, AND) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedBooleanAndVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanAndVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedBooleanAndVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanAndVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -75,7 +75,7 @@ TEST_P(BooleanVectorTest, AND) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanVectorTest, OR) { +TEST_P(DelayedUnaryIsometricBooleanVectorTest, OR) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -87,13 +87,13 @@ TEST_P(BooleanVectorTest, OR) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedBooleanOrVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanOrVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedBooleanOrVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanOrVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -121,7 +121,7 @@ TEST_P(BooleanVectorTest, OR) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanVectorTest, XOR) { +TEST_P(DelayedUnaryIsometricBooleanVectorTest, XOR) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -133,13 +133,13 @@ TEST_P(BooleanVectorTest, XOR) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedBooleanXorVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanXorVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedBooleanXorVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanXorVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -167,7 +167,7 @@ TEST_P(BooleanVectorTest, XOR) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(BooleanVectorTest, EQUAL) { +TEST_P(DelayedUnaryIsometricBooleanVectorTest, EQUAL) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -181,13 +181,13 @@ TEST_P(BooleanVectorTest, EQUAL) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedBooleanEqualVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanEqualVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } else { - auto op = tatami::make_DelayedBooleanEqualVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto op = tatami::make_DelayedUnaryIsometricBooleanEqualVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -216,8 +216,8 @@ TEST_P(BooleanVectorTest, EQUAL) { } INSTANTIATE_TEST_SUITE_P( - BooleanVector, - BooleanVectorTest, + DelayedUnaryIsometricBooleanVector, + DelayedUnaryIsometricBooleanVectorTest, ::testing::Combine( ::testing::Values(true, false), // add by row, or by column ::testing::Values(true, false) // check sparse case diff --git a/tests/src/isometric/unary/compare_scalar_helpers.cpp b/tests/src/isometric/unary/compare_scalar_helpers.cpp index 69b9787c..27486a5d 100644 --- a/tests/src/isometric/unary/compare_scalar_helpers.cpp +++ b/tests/src/isometric/unary/compare_scalar_helpers.cpp @@ -5,13 +5,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class CompareScalarTest : public ::testing::TestWithParam { +class DelayedUnaryIsometricCompareScalarTest : public ::testing::TestWithParam { protected: inline static size_t nrow = 123, ncol = 89; inline static std::shared_ptr dense, sparse; @@ -34,12 +34,12 @@ class CompareScalarTest : public ::testing::TestWithParam { } }; -TEST_P(CompareScalarTest, Equal) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, Equal) { double val = GetParam(); - auto op = tatami::make_DelayedEqualScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricEqualScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -64,12 +64,12 @@ TEST_P(CompareScalarTest, Equal) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareScalarTest, GreaterThan) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, GreaterThan) { double val = GetParam(); - auto op = tatami::make_DelayedGreaterThanScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -94,12 +94,12 @@ TEST_P(CompareScalarTest, GreaterThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareScalarTest, LessThan) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, LessThan) { double val = GetParam(); - auto op = tatami::make_DelayedLessThanScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricLessThanScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -124,12 +124,12 @@ TEST_P(CompareScalarTest, LessThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareScalarTest, GreaterThanOrEqual) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, GreaterThanOrEqual) { double val = GetParam(); - auto op = tatami::make_DelayedGreaterThanOrEqualScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanOrEqualScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -154,12 +154,12 @@ TEST_P(CompareScalarTest, GreaterThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareScalarTest, LessThanOrEqual) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, LessThanOrEqual) { double val = GetParam(); - auto op = tatami::make_DelayedLessThanOrEqualScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricLessThanOrEqualScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -184,12 +184,12 @@ TEST_P(CompareScalarTest, LessThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareScalarTest, NotEqual) { +TEST_P(DelayedUnaryIsometricCompareScalarTest, NotEqual) { double val = GetParam(); - auto op = tatami::make_DelayedNotEqualScalarHelper(val); + auto op = tatami::make_DelayedUnaryIsometricNotEqualScalar(val); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_EQ(dense->nrow(), nrow); @@ -215,7 +215,7 @@ TEST_P(CompareScalarTest, NotEqual) { } INSTANTIATE_TEST_SUITE_P( - CompareScalar, - CompareScalarTest, + DelayedUnaryIsometricCompareScalar, + DelayedUnaryIsometricCompareScalarTest, ::testing::Values(0, -1, 1) ); diff --git a/tests/src/isometric/unary/compare_vector_helpers.cpp b/tests/src/isometric/unary/compare_vector_helpers.cpp index e5033733..8e0cffc5 100644 --- a/tests/src/isometric/unary/compare_vector_helpers.cpp +++ b/tests/src/isometric/unary/compare_vector_helpers.cpp @@ -4,13 +4,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class CompareVectorTest : public ::testing::TestWithParam > { +class DelayedUnaryIsometricCompareVectorTest : public ::testing::TestWithParam > { protected: inline static size_t nrow = 291, ncol = 188; inline static std::shared_ptr dense, sparse; @@ -41,7 +41,7 @@ class CompareVectorTest : public ::testing::TestWithParam } }; -TEST_P(CompareVectorTest, Equal) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, Equal) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -60,13 +60,13 @@ TEST_P(CompareVectorTest, Equal) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedEqualVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricEqualVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedEqualVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricEqualVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -94,7 +94,7 @@ TEST_P(CompareVectorTest, Equal) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareVectorTest, GreaterThan) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, GreaterThan) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -112,13 +112,13 @@ TEST_P(CompareVectorTest, GreaterThan) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedGreaterThanVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedGreaterThanVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -146,7 +146,7 @@ TEST_P(CompareVectorTest, GreaterThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareVectorTest, LessThan) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, LessThan) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -164,13 +164,13 @@ TEST_P(CompareVectorTest, LessThan) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedLessThanVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricLessThanVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedLessThanVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricLessThanVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -198,7 +198,7 @@ TEST_P(CompareVectorTest, LessThan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareVectorTest, GreaterThanOrEqual) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, GreaterThanOrEqual) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -216,13 +216,13 @@ TEST_P(CompareVectorTest, GreaterThanOrEqual) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedGreaterThanOrEqualVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanOrEqualVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedGreaterThanOrEqualVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricGreaterThanOrEqualVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -250,7 +250,7 @@ TEST_P(CompareVectorTest, GreaterThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareVectorTest, LessThanOrEqual) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, LessThanOrEqual) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -268,13 +268,13 @@ TEST_P(CompareVectorTest, LessThanOrEqual) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedLessThanOrEqualVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricLessThanOrEqualVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedLessThanOrEqualVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricLessThanOrEqualVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -302,7 +302,7 @@ TEST_P(CompareVectorTest, LessThanOrEqual) { quick_test_all(sparse_mod.get(), &ref); } -TEST_P(CompareVectorTest, NotEqual) { +TEST_P(DelayedUnaryIsometricCompareVectorTest, NotEqual) { auto param = GetParam(); bool row = std::get<0>(param); bool is_sparse = std::get<1>(param); @@ -314,13 +314,13 @@ TEST_P(CompareVectorTest, NotEqual) { std::shared_ptr dense_mod, sparse_mod; if (row) { - auto op = tatami::make_DelayedNotEqualVectorHelper<0>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricNotEqualVector<0>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } else { - auto op = tatami::make_DelayedNotEqualVectorHelper<1>(vec); - dense_mod = tatami::make_DelayedUnaryIsometricOp(this->dense, op); - sparse_mod = tatami::make_DelayedUnaryIsometricOp(this->sparse, op); + auto op = tatami::make_DelayedUnaryIsometricNotEqualVector<1>(vec); + dense_mod = tatami::make_DelayedUnaryIsometricOperation(this->dense, op); + sparse_mod = tatami::make_DelayedUnaryIsometricOperation(this->sparse, op); } EXPECT_FALSE(dense_mod->is_sparse()); @@ -349,8 +349,8 @@ TEST_P(CompareVectorTest, NotEqual) { } INSTANTIATE_TEST_SUITE_P( - CompareVector, - CompareVectorTest, + DelayedUnaryIsometricCompareVector, + DelayedUnaryIsometricCompareVectorTest, ::testing::Combine( ::testing::Values(true, false), // add by row, or by column ::testing::Values(true, false) // check sparse case diff --git a/tests/src/isometric/unary/math_helpers.cpp b/tests/src/isometric/unary/math_helpers.cpp index 7dfca677..4b51f7cf 100644 --- a/tests/src/isometric/unary/math_helpers.cpp +++ b/tests/src/isometric/unary/math_helpers.cpp @@ -4,13 +4,13 @@ #include #include "tatami/dense/DenseMatrix.hpp" -#include "tatami/isometric/unary/DelayedUnaryIsometricOp.hpp" +#include "tatami/isometric/unary/DelayedUnaryIsometricOperation.hpp" #include "tatami/sparse/convert_to_compressed_sparse.hpp" #include "tatami_test/tatami_test.hpp" #include "../utils.h" -class MathTest : public ::testing::Test { +class DelayedUnaryIsometricMathTest : public ::testing::Test { protected: inline static size_t nrow = 82, ncol = 51; inline static std::shared_ptr dense, sparse; @@ -32,10 +32,10 @@ class MathTest : public ::testing::Test { } }; -TEST_F(MathTest, Abs) { - tatami::DelayedAbsHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Abs) { + tatami::DelayedUnaryIsometricAbs op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -55,10 +55,10 @@ TEST_F(MathTest, Abs) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Sign) { - tatami::DelayedSignHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Sign) { + tatami::DelayedUnaryIsometricSign op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -76,10 +76,10 @@ TEST_F(MathTest, Sign) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Sqrt) { - tatami::DelayedSqrtHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Sqrt) { + tatami::DelayedUnaryIsometricSqrt op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -97,12 +97,12 @@ TEST_F(MathTest, Sqrt) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Log) { +TEST_F(DelayedUnaryIsometricMathTest, Log) { // Trying with the natural base. { - tatami::DelayedLogHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + tatami::DelayedUnaryIsometricLog op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -122,9 +122,9 @@ TEST_F(MathTest, Log) { // Trying with another base. { - tatami::DelayedLogHelper op(2.0); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + tatami::DelayedUnaryIsometricLog op(2.0); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -143,12 +143,12 @@ TEST_F(MathTest, Log) { } } -TEST_F(MathTest, Log1pBy) { +TEST_F(DelayedUnaryIsometricMathTest, Log1pBy) { // Trying with the natural base. { - tatami::DelayedLog1pHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + tatami::DelayedUnaryIsometricLog1p op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -168,9 +168,9 @@ TEST_F(MathTest, Log1pBy) { // Trying with another base. { - tatami::DelayedLog1pHelper op(2.0); - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); + tatami::DelayedUnaryIsometricLog1p op(2.0); + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -189,10 +189,10 @@ TEST_F(MathTest, Log1pBy) { } } -TEST_F(MathTest, Exp) { - tatami::DelayedExpHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Exp) { + tatami::DelayedUnaryIsometricExp op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -210,10 +210,10 @@ TEST_F(MathTest, Exp) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Expm1) { - tatami::DelayedExpm1Helper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Expm1) { + tatami::DelayedUnaryIsometricExpm1 op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -231,10 +231,10 @@ TEST_F(MathTest, Expm1) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Round) { - tatami::DelayedRoundHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Round) { + tatami::DelayedUnaryIsometricRound op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -252,10 +252,10 @@ TEST_F(MathTest, Round) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Ceiling) { - tatami::DelayedCeilingHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Ceiling) { + tatami::DelayedUnaryIsometricCeiling op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -273,10 +273,10 @@ TEST_F(MathTest, Ceiling) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Floor) { - tatami::DelayedFloorHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Floor) { + tatami::DelayedUnaryIsometricFloor op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -294,10 +294,10 @@ TEST_F(MathTest, Floor) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Trunc) { - tatami::DelayedTruncHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Trunc) { + tatami::DelayedUnaryIsometricTrunc op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -315,10 +315,10 @@ TEST_F(MathTest, Trunc) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Sin) { - tatami::DelayedSinHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Sin) { + tatami::DelayedUnaryIsometricSin op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -336,10 +336,10 @@ TEST_F(MathTest, Sin) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Cos) { - tatami::DelayedCosHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Cos) { + tatami::DelayedUnaryIsometricCos op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -357,10 +357,10 @@ TEST_F(MathTest, Cos) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Tan) { - tatami::DelayedTanHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Tan) { + tatami::DelayedUnaryIsometricTan op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -378,11 +378,11 @@ TEST_F(MathTest, Tan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Asin) { +TEST_F(DelayedUnaryIsometricMathTest, Asin) { // Use a tighter range to get most values inside the domain of [-1, 1]. - tatami::DelayedAsinHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense_unit, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse_unit, op); + tatami::DelayedUnaryIsometricAsin op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense_unit, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse_unit, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -400,10 +400,10 @@ TEST_F(MathTest, Asin) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Acos) { - tatami::DelayedAcosHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense_unit, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse_unit, op); +TEST_F(DelayedUnaryIsometricMathTest, Acos) { + tatami::DelayedUnaryIsometricAcos op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense_unit, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse_unit, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -421,10 +421,10 @@ TEST_F(MathTest, Acos) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Atan) { - tatami::DelayedAtanHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Atan) { + tatami::DelayedUnaryIsometricAtan op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -442,10 +442,10 @@ TEST_F(MathTest, Atan) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Sinh) { - tatami::DelayedSinhHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Sinh) { + tatami::DelayedUnaryIsometricSinh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -463,10 +463,10 @@ TEST_F(MathTest, Sinh) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Cosh) { - tatami::DelayedCoshHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Cosh) { + tatami::DelayedUnaryIsometricCosh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -484,10 +484,10 @@ TEST_F(MathTest, Cosh) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Tanh) { - tatami::DelayedTanhHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Tanh) { + tatami::DelayedUnaryIsometricTanh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -505,10 +505,10 @@ TEST_F(MathTest, Tanh) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Asinh) { - tatami::DelayedAsinhHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Asinh) { + tatami::DelayedUnaryIsometricAsinh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -526,10 +526,10 @@ TEST_F(MathTest, Asinh) { quick_test_all(sparse_mod.get(), &ref); } -TEST_F(MathTest, Acosh) { - tatami::DelayedAcoshHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Acosh) { + tatami::DelayedUnaryIsometricAcosh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -547,10 +547,10 @@ TEST_F(MathTest, Acosh) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Atanh) { - tatami::DelayedAtanhHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense_unit, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse_unit, op); +TEST_F(DelayedUnaryIsometricMathTest, Atanh) { + tatami::DelayedUnaryIsometricAtanh op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense_unit, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse_unit, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_TRUE(sparse_mod->is_sparse()); @@ -568,10 +568,10 @@ TEST_F(MathTest, Atanh) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Gamma) { - tatami::DelayedGammaHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Gamma) { + tatami::DelayedUnaryIsometricGamma op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse()); @@ -589,10 +589,10 @@ TEST_F(MathTest, Gamma) { quick_test_all(sparse_mod.get(), &ref, /* has_nan = */ true); } -TEST_F(MathTest, Lgamma) { - tatami::DelayedLgammaHelper op; - auto dense_mod = tatami::make_DelayedUnaryIsometricOp(dense, op); - auto sparse_mod = tatami::make_DelayedUnaryIsometricOp(sparse, op); +TEST_F(DelayedUnaryIsometricMathTest, Lgamma) { + tatami::DelayedUnaryIsometricLgamma op; + auto dense_mod = tatami::make_DelayedUnaryIsometricOperation(dense, op); + auto sparse_mod = tatami::make_DelayedUnaryIsometricOperation(sparse, op); EXPECT_FALSE(dense_mod->is_sparse()); EXPECT_FALSE(sparse_mod->is_sparse());