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

◆ transform_matrix_multichannel() [2/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_matrix_multichannel ( DataType &  input,
const Eigen::MatrixXd &  transformation_matrix,
uint32_t  num_channels,
std::vector< std::vector< double > > &  working_buffer 
)

Multi-channel matrix transformation with error handling (OUT-OF-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - will NOT be modified
transformation_matrixMatrix to apply per channel
num_channelsNumber of channels
working_bufferBuffer for operations (will be resized if needed)
Returns
Transformed data

Definition at line 519 of file MatrixHelper.hpp.

523{
524 auto [target_data, structure_info] = OperationHelper::setup_operation_buffer(input, working_buffer);
525
526 if (transformation_matrix.rows() != num_channels || transformation_matrix.cols() != num_channels) {
527 throw std::invalid_argument("Transformation matrix dimensions must match number of channels");
528 }
529
530 if (target_data.size() != num_channels) {
531 throw std::invalid_argument("Data channel count must match specified number of channels");
532 }
533
534 size_t min_frames = std::ranges::min(target_data | std::views::transform([](const auto& span) { return span.size(); }));
535
536 auto frame_indices = std::views::iota(size_t { 0 }, min_frames);
537
538 std::ranges::for_each(frame_indices, [&](size_t frame) {
539 Eigen::VectorXd frame_vector(num_channels);
540
541 for (size_t channel = 0; channel < num_channels; ++channel) {
542 frame_vector[channel] = target_data[channel][frame];
543 }
544
545 Eigen::VectorXd transformed = transformation_matrix * frame_vector;
546
547 for (size_t channel = 0; channel < num_channels; ++channel) {
548 working_buffer[channel][frame] = transformed[channel];
549 }
550 });
551
552 return OperationHelper::reconstruct_from_double<DataType>(working_buffer, structure_info);
553}

References MayaFlux::Yantra::OperationHelper::setup_operation_buffer().

+ Here is the call graph for this function: