mir.ndslice: assign a vector to a matrix row

David scherd3113 at gmail.com
Sat Dec 15 19:04:37 UTC 2018


Hi

I am wondering if it is possible to assign a vector to a row of a 
matrix?

============ main.d ==========
import mir.ndslice;

void main() {

   auto matrix = slice!double(3, 4);
   matrix[] = 0;
   matrix.diagonal[] = 1;

   auto row = matrix[0];
   row[3] = 4;
   assert(matrix[0, 3] == 4);

   // assign it to rows of a matrix?
   auto vector = sliced!(double)([10, 11, 12, 13]);

   // ??? Here I would like to assign the vector to the last (but 
it is not working)
   // matrix[2] = vector;
}
============

So I am wondering what the correct way is to do such an 
assignment without looping?




More information about the Digitalmars-d-learn mailing list