Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++;具有类似于Python/NumPy的数组操作的库_Python_C++_Arrays_Numpy - Fatal编程技术网

C++;具有类似于Python/NumPy的数组操作的库

C++;具有类似于Python/NumPy的数组操作的库,python,c++,arrays,numpy,Python,C++,Arrays,Numpy,请原谅我问了一个可能太宽泛的问题。但是,我的任务非常具体:对Python没有太多的经验,我想把Python代码重写到C++(OpenCV),我想知道是否有一些C++库有良好的文档化的比较(我知道OpenBLAS,EGIN等等)。这将允许我相对容易地重复原始代码中的所有数组操作,这对于我使用OpenCV来说是一个相当大的挑战。也许有人写过关于语法比较的帖子 Python代码: image = im_orig.copy() # Create input for multiples of net in

请原谅我问了一个可能太宽泛的问题。但是,我的任务非常具体:对Python没有太多的经验,我想把Python代码重写到C++(OpenCV),我想知道是否有一些C++库有良好的文档化的比较(我知道OpenBLAS,EGIN等等)。这将允许我相对容易地重复原始代码中的所有数组操作,这对于我使用OpenCV来说是一个相当大的挑战。也许有人写过关于语法比较的帖子

Python代码:

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 DeNeNeCy(特别是从Python C++ API),程序实际上是可读的,不像Cython所生产的。

< P>我认为Eigen可能适合你。如果你没有试过(根据你的问题我不知道),你应该看看。除了速度非常快(从我收集的信息来看,它是最快的),它还有一个非常自然的语法。它并没有得到更好的,如果只涉及C++。

< /p>你可能想搜索一个C++数字库,但是注意如果你正在重写C++中的代码来提高性能,你可能会失望,好的数字代码开始时会很快。谢谢你,我知道NUMPY很快,但是无论如何要去掉Python是很重要的。不应该出现在工程师的词汇表中:-)谢谢!不,我只有OpenCV的经验。也许有一些关于在Eigen和NumPy之间重写的提示?我知道这听起来有点懒,但是从一个解决方案切换到另一个解决方案变得非常困难和耗时。你知道你的原始代码是关于什么的,对吗?从数学上讲,它是做什么的?然后你可以从这里开始:首先解释基本的矩阵/线性代数……至于直接重写指令:我认为这样的东西不存在,一般来说也不会很有用。但是一般来说,对于numpy所能做的一切,在Egeng库中应该有一个等价的或至少非常类似的操作。好的,只要有一个等价的,我就试试。非常感谢。