Discussion:
[Rcpp-devel] 4-dimensional array
Shaami
2018-04-18 00:38:26 UTC
Permalink
Dear Prof.

I am not finding how to introduce a 4-dimensional array using
RcppArmadillo. Could you please provide a simple example of introducing a
4-dimensional array and how to store the values in it? For example, exactly
the same as I did for the cube as follows


arma::cube X(N, M, Q, fill::zeros);

for(int n=0; n<N; n++)
{
for(int m=0; m<M; m++)
{
for(int q=0; q<Q; q++)
{
X(n, m, q) + = n+m-q
}
}
}

Thank you

Shaami
Avraham Adler
2018-04-18 01:56:38 UTC
Permalink
May not be possible. See
https://stackoverflow.com/questions/16105548/4-dimensional-matrix-in-armadillo

Avi
Post by Shaami
Dear Prof.
I am not finding how to introduce a 4-dimensional array using
RcppArmadillo. Could you please provide a simple example of introducing a
4-dimensional array and how to store the values in it? For example, exactly
the same as I did for the cube as follows
arma::cube X(N, M, Q, fill::zeros);
for(int n=0; n<N; n++)
{
for(int m=0; m<M; m++)
{
for(int q=0; q<Q; q++)
{
X(n, m, q) + = n+m-q
}
}
}
Thank you
Shaami
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Sent from Gmail Mobile
Dirk Eddelbuettel
2018-04-18 02:13:36 UTC
Permalink
On 18 April 2018 at 01:56, Avraham Adler wrote:
| May not be possible. See
| https://stackoverflow.com/questions/16105548/4-dimensional-matrix-in-armadillo

Avi is correct.

Armadillo, as clearly documented, knows

vector 1d
matrix 2d
cube 3d
fields lists of matrices or cubes

plus sp_mat for sparse matrices. No 4d arrays.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Jeffrey Pollock
2018-04-18 10:35:18 UTC
Permalink
The Eigen tensor module (easily available via RcppEigen as far as I can
tell) might be worth a look:
http://eigen.tuxfamily.org/index.php?title=Tensor_support
Post by Dirk Eddelbuettel
| May not be possible. See
| https://stackoverflow.com/questions/16105548/4-dimensional-matrix-in-
armadillo
Avi is correct.
Armadillo, as clearly documented, knows
vector 1d
matrix 2d
cube 3d
fields lists of matrices or cubes
plus sp_mat for sparse matrices. No 4d arrays.
Dirk
--
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Continue reading on narkive:
Loading...