Field of matrices being returned with class `matrix` instead of `list`
还没有人认领这个 Issue。
评估
调研方向
Start by running the supplied RcppArmadillo reproducer and compare class(), typeof(), dim(), and str() for the arma::fieldarma::cube result. Trace the exporter path for arma::field and determine why the returned list receives matrix dimensions; done means the field is a list without dimensions while the contained cubes retain their array structure.
由索引模型根据 Issue 内容生成。
描述
Stumbled across an interesting hiccup in the exporter for arma::field<T> (the generic vector). In particular, the attributes associated with an arma::field<arma::mat> shows as matrix under a class(x) call instead of list. The only way to obtain the list type is to use a typeof() call.
#include<RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
Rcpp::List test_case() {
// Random dimensions
int N = 5,
P = 8,
J = 10,
K = 3,
S = 2;
// Create a 2d matrix
arma::mat standard_2d_matrix(P, N);
// Create a 3rd array
arma::cube standard_3d_array(J, S, N);
// Create a 4D Array
arma::field<arma::cube> nonstandard_4d_array(N);
// Fill it with cubes
nonstandard_4d_array.fill(arma::ones<arma::cube>(J, K, S));
return Rcpp::List::create(
Rcpp::Named("d2", standard_2d_matrix),
Rcpp::Named("d3", standard_3d_array),
Rcpp::Named("d4", nonstandard_4d_array)
);
}
The class issue is shown under d4 being matrix instead of list.
exporter_check = test_case()
sapply(exporter_check, FUN = class)
# d2 d3 d4
# "matrix" "array" "matrix"
sapply(exporter_check, FUN = typeof)
# d2 d3 d4
# "double" "double" "list"
Moreover, the list is registering as a matrix with dim(x) of N x 1 instead of a list without dimensions.
sapply(exporter_check, FUN = dim)
# $d2
# [1] 8 5
# $d3
# [1] 10 2 5
# $d4
# [1] 5 1
And the object structure:
str(exporter_check)
# List of 3
# $ d2: num [1:8, 1:5] 1.49e-154 1.49e-154 2.57e-322 6.95e-310 6.95e-310 ...
# $ d3: num [1:10, 1:2, 1:5] 1.49e-154 1.49e-154 9.96e-320 1.63e-322 1.43e-322 ...
# $ d4:List of 5
# ..$ : num [1:10, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
# ..$ : num [1:10, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
# ..$ : num [1:10, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
# ..$ : num [1:10, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
# ..$ : num [1:10, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
# ..- attr(*, "dim")= int [1:2] 5 1
- 主要语言
- C++
- 星标
- 211
- 派生
- 54
- 平均合并
- 5 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
RcppCore/RcppArmadillo 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
RcppCore/RcppArmadillo#454 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
RcppCore/RcppArmadillo#364 · 10 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
RcppCore/RcppArmadillo#299 · 6 条评论 ·
-
难度 4/5 3-5 天 新手友好度 20/100
RcppCore/RcppArmadillo#268 · 3 个 reaction ·
-
enhancement help wanted
难度 4/5 3-5 天 新手友好度 35/100
RcppCore/RcppArmadillo#250 · 1 条评论 ·
查看 RcppCore/RcppArmadillo 的全部 Issue
相似的 Issue
-
Website Doc Typo 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 1/5 1-3 小时 新手友好度 92/100
autowarefoundation/autoware_universe#13413 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
automated-analysis bug memory-safety
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 88/100