#include <Eigen/Dense>
#include <iostream>
typedef Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> EigenIntMatrix;
typedef Eigen::Map<EigenIntMatrix> EigenIntMatrixMap;
int main()
{
auto ncA = nc::random::randInt<int>({ 5, 5 }, 0, 10);
auto ncB = nc::random::randInt<int>({ 5, 5 }, 0, 10);
std::cout << "ncA:\n" << ncA << std::endl;
std::cout << "ncB:\n" << ncB << std::endl;
auto eigenA = EigenIntMatrixMap(ncA.data(), ncA.numRows(), ncA.numCols());
auto eigenB = EigenIntMatrixMap(ncB.data(), ncB.numRows(), ncB.numCols());
auto eigenC = eigenA + eigenB;
auto ncC = ncA + ncB;
int* dataPtr = new int[eigenC.rows() * eigenC.cols()];
EigenIntMatrixMap(dataPtr, eigenC.rows(), eigenC.cols()) = eigenC;
constexpr bool takeOwnership = true;
auto ncCeigen =
nc::NdArray<int>(dataPtr, eigenC.rows(), eigenC.cols(), takeOwnership);
{
std::cout << "Arrays are equal." << std::endl;
std::cout << ncC << std::endl;
}
else
{
std::cout << "Arrays are not equal." << std::endl;
std::cout << "ncCeigen:\n" << ncCeigen << std::endl;
std::cout << "ncC:\n" << ncC << std::endl;
}
return 0;
}
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:138
bool array_equal(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2) noexcept
Definition: array_equal.hpp:47