C++具有类似于 Python/NumPy 的数组操作的库
C++ library with array operations similar to Python/NumPy
请原谅可能问一个过于宽泛的问题。但是,我的任务非常具体:由于没有太多的Python经验,我想将Python代码重写为C++(OpenCV),我想知道对于某些C++库(我知道存在OpenBLAS,Eigen等)是否有很好的文档比较,这将使我相对容易地重复在原始代码中进行的所有数组操作,这对我来说使用OpenCV来说是一个相当大的挑战。也许有人真的写了关于语法比较的文章?
蟒蛇代码:
image = im_orig.copy()
# Create input for multiples of net input/output changes.
im_bg_width = int(_np.ceil(
float(image.shape[1]) * scale_factor / _STRIDE) * _STRIDE)
im_bg_height = int(_np.ceil(
float(image.shape[0]) * scale_factor / _STRIDE) * _STRIDE)
pad_size = 64
im_bot_pixels = image[-1:, :, :]
im_bot = _np.tile(im_bot_pixels, (pad_size, 1, 1))
image = _np.vstack((image, im_bot))
im_right_pixels = image[:, -1:, :]
im_right = _np.tile(im_right_pixels, (1, pad_size, 1))
image = _np.hstack((image, im_right))
image = _scipy.misc.imresize(image, scale_factor, interp='bilinear')
image = image.astype('float32') - _MEAN
net_input = _np.zeros((im_bg_height, im_bg_width, 3), dtype='float32')
net_input[:min(net_input.shape[0], image.shape[0]),
:min(net_input.shape[1], image.shape[1]), :] =
image[:min(net_input.shape[0], image.shape[0]),
:min(net_input.shape[1], image.shape[1]), :]
编辑:我想不惜一切代价摆脱python依赖(特别是来自python C++ API),并使程序实际上可读,不像Cython生产的那样。
我认为 Eigen 可能适合你。如果你还没有尝试过(我不知道根据你的问题),你应该看看它。除了非常快(从我收集到的最快的语法中),它还具有非常自然的语法。如果只关心C++,情况并没有好转。
http://eigen.tuxfamily.org
相关文章:
- 对字符数组中的元素执行逐位操作
- 给定一个整数数组,需要在Max_Heap上运行操作。得到错误"segmentation fault",有什么想法吗?(C++)
- 在矢量数组C++中使用算法库操作
- C++ 黑客等级 - 数组操作
- 使用字符数组堆叠。如何执行"+"和"*"操作?
- C++数组指针上的删除操作
- 如何有效地使用 std::async 对指针数组执行操作
- 用于在一维数组上嵌套循环操作的正确 openmp 指令
- 带有动态数组的操作内存中的垃圾箱
- 如何修复问题中的"teminated due to timeout"错误 数组操作 |黑客兰克?
- 数组A中最大的元素数量可以通过使用操作最多可将其降低至1
- 在数组大小中使用位操作的原因
- C++ 如何处理 ifstream 和 char 数组的">>"操作?
- c操作指向char数组的指针,混淆
- 数组操作
- C# * 和 & 操作器,用于指向数组
- C++具有类似于 Python/NumPy 的数组操作的库
- 此数组操作在C++中如何工作
- 简单的数组操作错误
- 使用矢量的二维数组操作