[英]Octave value dimensions
I'm using Octave in c++ code. 我在c ++代码中使用Octave。 I'm trying to figure out the dimensions of every element of
out
我想弄清楚的每一个元素的尺寸
out
octave_value_list out = feval (q, in, 1);
I used 我用了
dim_vector x=out(0).dims();
According to dim-vector.h, it can only support up to 7 dimensions. 根据dim-vector.h,它最多只能支持7个维度。 Is there any way I can get the rows, columns and pages for every element of
out
? 有什么方法可以让我得到的每一个元素的行,列和页面
out
?
First, there is need to correct a mistake on your premises: 首先,需要纠正您的场所中的错误:
According to dim-vector.h, it can only support up to 7 dimensions.
根据dim-vector.h,它最多只能支持7个维度。
Not true. 不对。 What the header says is that there are constructors for only up to 7 dimensions.
标头说的是,最多只能有7个维度的构造函数。 Above that, you'll have to increase the number of dimensions and set their lengths yourself.
除此之外,您必须增加尺寸数量并自行设置尺寸长度。
Compare the following which are equivalent: 比较以下等效项:
// create dim_vector for 5x5x5 array
dim_vector d1 = dim_vector (5, 5, 5);
dim_vector d2 = dim_vector ();
dim_vector d3 = d2.redim (3);
d3(2) = 5;
d2.resize (3, 5);
To generate dim_vectors above 7 dimensions, you can: 要生成7个维度以上的dim_vector,您可以:
// 10 dimensional dim_vector of size 5x5x5...x5
dim_vector d = dim_vector ();
d.resize (10, 5);
See doxygen dev docs for dim_vector . 有关dim_vector,请参见doxygen开发文档 。 They are more complete on the current development sources.
在当前的开发资源上,它们更加完整。
Now, to answer your specific question 现在,回答您的特定问题
Is there any way I can get the rows, columns and pages for every element of out?
我有什么办法可以获取每个元素的行,列和页面?
Just index the dim_vector you get out of each octave_value
in the octave_value_list
只需索引从octave_value_list中的每个
octave_value
中获得的octave_value_list
octave_value_list out = feval (q, in, 1);
for (octave_idx_type out_i = 0; out_i < out.length (); out_++)
{
dim_vector d = out(out_i).dims ();
for (octave_idx_type di = 0 ; di < d.length (); di++)
std::cout << "Length of dimension " << di << ": " << d(di) << std:endl;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.