gpt4 book ai didi

c++ - 面向 Python 程序员的 C/C++

转载 作者:太空狗 更新时间:2023-10-29 20:42:47 24 4
gpt4 key购买 nike

<分区>

我必须从 Python 切换到 C/C++。
你知道一个快速的“引用教程”或类似的东西来引用如何开始吗?例如 Numpy 和 Scipy 教程之类的东西。
我已经阅读了很多“文档”,例如

  • C++ 傻瓜书
  • K&R C 编程语言
  • 大量博客和在线文档,例如:http://eli.thegreenplace.net/2010/01/11/pointers-to-arrays-in-c/,
  • http://newdata.box.sk/bx/c/
  • StackOverflow 上的大量问答
  • ...

但我仍然不清楚如何开始移植到 C/C++,例如:

#!/usr/bin/env python

import time
import numpy as np
import tables as tb

"""Retrieve 3D positions form 1000 files and store them in one single HDF5 file.
"""

t = time.time()

# Empty array
sample = np.array([])
sample.shape = (0,3)

# Loop over the files
for i in range(0, 1000):
filename = "mill2sort-"+str(i)+"-extracted.h5"
print "Doing ", filename
# Open data file
h5f = tb.openFile(filename, 'r')
# Stack new data under previous data
sample = np.vstack((sample, h5f.root.data.read()))
h5f.close()

# Create the new file
h5 = tb.openFile("mill2sort-extracted-all", 'w')
# Save the array
h5.createArray(h5.root, 'data', sample, title='mill_2_sub_sample_all')
h5.flush()
h5.close()

print "Done in ", time.time()-t, " seconds."

在 C 或 C++ 中。在这个例子中,我什至无法理解如何将 3D 数组传递给找到它的维度的函数,比如

int getArrayDimensions(int* array, int *dimensions){
*dimensions = sizeof(*array)/sizeof(array[0]);
return 0;
}

数组是

int array[3][3][3] = ...

感谢您的任何建议!:)

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com