MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ transform_logarithmic() [2/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_logarithmic ( DataType &  input,
double  a,
double  b,
double  c = 1.0,
double  base = std::numbers::e 
)

Logarithmic transformation y = a * log_base(b * x + c) (IN-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - WILL BE MODIFIED
aScale factor
bInput scale factor
cOffset to ensure positive argument
baseLogarithm base (default: e for natural log)
Returns
Transformed data

Definition at line 246 of file MathematicalHelper.hpp.

247{
248 auto [target_data, structure_info] = OperationHelper::extract_structured_double(input);
249
250 double log_base_factor = (base == std::numbers::e) ? 1.0 : (1.0 / std::log(base));
251
252 for (auto& span : target_data) {
253 std::ranges::transform(span, span.begin(),
254 [a, b, c, log_base_factor](double x) {
255 double arg = b * x + c;
256 if (arg <= 0.0)
257 return 0.0;
258 return a * std::log(arg) * log_base_factor;
259 });
260 }
261
262 auto reconstructed_data = target_data
263 | std::views::transform([](const auto& span) {
264 return std::vector<double>(span.begin(), span.end());
265 })
266 | std::ranges::to<std::vector>();
267
268 return OperationHelper::reconstruct_from_double<DataType>(reconstructed_data, structure_info);
269}

References transform_logarithmic().

Referenced by MayaFlux::Yantra::MathematicalTransformer< InputType, OutputType >::transform_implementation(), transform_logarithmic(), and transform_logarithmic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: