C-了解二维动态阵列的方面大小

发布于 2025-02-06 19:48:44 字数 521 浏览 5 评论 0原文

我现在在C中实施深度学习。 我想知道具有任何长度的二维动态阵列的水平和垂直长度。

我的尝试:

    double** a1 = createArray(?, ?);
    size_t a1_size = _msize(*a1)/sizeof(double);

createArray函数:

double** createArray(int l, int m){
    double **result;

    result = calloc(sizeof(double*), l);
    result[0] = calloc(sizeof(double), l * m);
    for (int i = 1; i < l; ++i) result[i] = result[i - 1] + m;

    return result;
}

我尝试使用_msize函数来解决此问题,但失败了。

您能说出二维动态阵列的水平和垂直尺寸吗?你能帮助我吗?

I am now implementing deep learning in C.
I want to know the horizontal and vertical lengths of the two-dimensional dynamic array created with any length.

My attempt:

    double** a1 = createArray(?, ?);
    size_t a1_size = _msize(*a1)/sizeof(double);

createArray function:

double** createArray(int l, int m){
    double **result;

    result = calloc(sizeof(double*), l);
    result[0] = calloc(sizeof(double), l * m);
    for (int i = 1; i < l; ++i) result[i] = result[i - 1] + m;

    return result;
}

I tried to solve this using the _msize function but failed.

Can you tell the horizontal and vertical sizes of the two-dimensional dynamic array? Can you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文