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

◆ create_eigen_matrix() [1/2]

template<typename T >
static Eigen::MatrixXd MayaFlux::Yantra::OperationHelper::create_eigen_matrix ( const std::vector< std::span< const T > > &  spans)
inlinestaticprivate

Create Eigen matrix from spans.

Definition at line 449 of file OperationHelper.hpp.

450 {
451 if (spans.empty()) {
452 return {};
453 }
454
455 int rows = spans[0].size();
456 int cols = spans.size();
457
458 for (const auto& span : spans) {
459 if (span.size() != rows) {
460 throw std::invalid_argument("All spans must have same size");
461 }
462 }
463
464 Eigen::MatrixXd matrix(rows, cols);
465 for (int col = 0; col < cols; ++col) {
466 for (int row = 0; row < rows; ++row) {
467 matrix(row, col) = static_cast<double>(spans[col][row]);
468 }
469 }
470 return matrix;
471 }