MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   从C数组初始化ublas向量 (https://www.labfans.com/bbs/showthread.php?t=22904)

poster 2019-12-10 16:49

从C数组初始化ublas向量
 
我正在使用C ++ ublas库编写Matlab扩展,并且我希望能够从Matlab交互程序传递的C数组中初始化ublas向量。我如何从C数组初始化ublas向量,而不必(出于效率考虑)显式复制数据。我在寻找以下几行代码:

using namespace boost::numeric::ublas; int pv[10] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; vector v (pv); 通常,是否可以从数组初始化C ++ std::vector ?像这样:

#include #include using namespace std; int main() { int pv[4] = { 4, 4, 4, 4}; vector v (pv, pv+4); pv[0] = 0; cout


所有时间均为北京时间。现在的时间是 10:26

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.