如果希望实现类似Numpy以下功能:
import numpy as np
a = np.array([[1,2],[3,4],[5,6]])
b = np.zeros([3, 2])
b[2, :] = a[1,:]
则在Numcpp实现代码如下:
#include "NumCpp.hpp"
#include <cstdlib>
#include <iostream>
int main ()
{
nc::NdArray<float> a = { {1, 2}, {3, 4}, {5, 6},{7, 8} };
auto b = nc::zeros<float>({3, 2});
b.put(2, b.cSlice(), a(1, a.cSlice()));
std::cout << "b: " << b;
return EXIT_SUCCESS;
}
参考资料:
https://github.com/dpilger26/NumCpp/issues/104