Assignment of arrays in C++ like Matlab? -


so in matlab, if make n x n x n x n x 6 dimensional matrix, can assign values matrix in groups of 6 so:

mymatrix(1,1,1,1,:) = [69, 3, 864, 21, 95, 20]; 

is there analogous way write n x n x n x n x 6 dimensional matrix in c++ in groups of 6?

also, there analogous way set 6 elements equal 6 elements i.e myarray(n,n,n,8,:) = myarray(n,n,n,6,:)?

(no std::vector solutions please- need keep matrix in array form existing code built arrays using c++/cuda , extremely complex)

with #include <algorithm>, may use std::copy:

int mymatrix[n][n][n][n][6]; const int src[6] = {69, 3, 864, 21, 95, 20};  std::copy(std::begin(src), std::end(src), mymatrix[0][0][0][0]); 

and equivalent of myarray(n,n,n,8,:) = myarray(n,n,n,6,:) be:

std::copy(std::begin(mymatrix[n-1][n-1][n-1][5]),  // source start           std::end(mymatrix[n-1][n-1][n-1][5]),    // source end           std::begin(mymatrix[n-1][n-1][n-1][7])); // dest start 

note indexing in c/c++ start @ 0 , not @ 1.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -