How can a data with high dimensionality be mapped to eigen types?

AFPP

I have an n-dimensional data in C++ and would like to be able to have them in dynamic Eigen types (preferably without copying).

float** mydata = new float*[nDim]; // Number of dimensions
for (size_t i = 0; i < nDim; i++)
{
    mydata[i] = new float[nRows*nCols];
    // fill the data for each dimension
    // ...
}

std::vector<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic>> A(nDim);
for (size_t i = 0; i < nDim; i++)
{
    A.at(i).resize(nRows, nCols);
    // How can I map my n-dimensional data to Eigen matrices preferably without copying mydata?
    // something like: A.at(i).data = mydata
}

Could someone kindly help me with this?

Avi Ginsburg

If you don't want to copy the data, you should use a bunch of Eigen::Maps. This wraps the existing data with an Eigen object with the exception of things like resizing. You can save a list of Maps in a vector:

std::vector<Eigen::Map<Eigen::MatrixXf>> arrayOfMaps;
arrayOfMaps.reserve(nDims);
for (size_t i = 0; i < nDim; i++)
{
    arrayOfMaps.push_back(Eigen::Map<Eigen::MatrixXf>(mydata[i], nRows, nCols));
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can correct Ambiguous handler methods mapped?

How can I group the data of a mapped object in javascript?

How to draw JavaScript charts that can cope with very high data volumes?

How can preserve the types for a mapped object in Typescript

How can I infer an object property's value in TypeScript when using mapped types?

How can I join two data that have different types of data?

How can I bind a toggle to the clicked element to mapped data in react

how to catch mapped data with button clicks in react?

How to make sense of dense layer units as dimensionality of predicted data?

How to vectorize with mismatched dimensionality

How to improve GEMM performance on data-mapped (Eigen::Map) matrices sharing memory with an std::vector?

How can I map types in a class library without mapped classes leaking from that library

How to do memory mapped IO on custom data types?

How to pass data through mapped promises?

How can I use an Eigen::Map object for Eigen::EigenSolver?

Spring Data JPA: query ManyToMany, How Can I get the data from mapped Class?

Data mining, curse of dimensionality

How to replace properties using mapped types in Typescript

union with eigen data types

Typescript - How to use nested mapped types

How to return mapped data to DOM

Can mapped types make properties optional, but only if a condition is met?

how to read mapped data from firestore in kotlin

How to get Unique Data and Mapped with Field in MongoDB

Can a polymorphic constant be mapped over a list of *types*?

How can I make a mapped type retain its types when accessing a variable?

How to correctly use mapped types

How to use Mapped Types with React.useState?

How can I build an Eigen::Map to a matlab::data::Array object that I intend to populate with data