Field of matrices being returned with class `matrix` instead of `list`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- C++
- Sterne
- 211
- Forks
- 54
- Ø Merge
- 5 Min.
- Gemergte PRs (30 T.)
- 1
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RcppCore/RcppArmadillo
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
RcppCore/RcppArmadillo#454 · 3 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
RcppCore/RcppArmadillo#364 · 10 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
RcppCore/RcppArmadillo#299 · 6 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
RcppCore/RcppArmadillo#268 · 3 Reaktionen ·
-
enhancement help wanted
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
RcppCore/RcppArmadillo#250 · 1 Kommentar ·
Alle Issues in RcppCore/RcppArmadillo
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
AXERA-TECH/ax-llm#77 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
games-on-whales/wolf#509 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
bug-unconfirmed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
NVIDIA/cuda-samples#453 ·