#include <Eigen/Dense>
#include <iostream>
#include <vector>
using EigenIntMatrix = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
using EigenIntMatrixMap = Eigen::Map<EigenIntMatrix>;
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;
auto data = std::vector<int>(eigenC.rows() * eigenC.cols());
EigenIntMatrixMap(data.data(), eigenC.rows(), eigenC.cols()) = eigenC;
{
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:139
bool array_equal(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2) noexcept
Definition: array_equal.hpp:47