MayaFlux 0.3.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 448 of file OperationHelper.hpp.

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