将 MATLAB 单元格类型转换为 c++

发布于 2025-01-04 06:11:02 字数 262 浏览 3 评论 0原文

我正在使用 Armadillo 进行矩阵代数转换 C++ 中的 MATLAB 程序。

我被困在 cell类型。有人有一些提示吗?

i'm converting a MATLAB program in c++ using Armadillo for matrix algebra.

i'm stuck on cell type. someone has some hints?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伤痕我心 2025-01-11 06:11:02

这是因为“单元格”并不是真正的类型 - 它是您想要放入其中的任何内容的占位符。在 C# 和 Python 等语言中,我能想到的最接近的东西是“元组”,它本质上可以包含匿名类型。

由于C++没有内置的元组类型,我建议你看一下 Boost,这是一个非常全面、成熟且开源的库,几乎可以满足您在 C++ 中所需的任何内容。在 Boost 下,查看 Fusion 库,或者如果您需要不简单的东西,请访问Tuple 库。

编辑 正如 Matt 在下面提到的,从 TR1 开始,元组是 C++ 标准库的一部分。请参阅此处 Matt 的链接。

That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types.

Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open-source library for practically anything you need in C++. Under Boost, take a look at the Fusion library, or if you require something not simpler, at the Tuple library.

EDIT as Matt mensioned below, as of TR1, tuples are part of the C++ standard library. See Matt's link here.

寄居者 2025-01-11 06:11:02

犰狳有 field 类!

Armadillo has field class!

无法言说的痛 2025-01-11 06:11:02

您的单元格数据可能会很好地转换为 C++ 对象。我建议您检查单元格包含的内容,看看是否可以将其表示为一个类。然后,您将能够创建对象的向量/数组/矩阵,并像 MATLAB 中的单元格一样处理它们。

Your cell data will likely translate fairly well into a C++ object. I would recommend you examine what your cells contain and see if you could represent it as a class. Then you would be able to create vectors/arrays/matrices of your objects and have them treated similar to cells in MATLAB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文