Is there any way to directly define new array from a known larger array? For example:
a1,a2=[1 2;3 4]
This doesn’t give results I need. However, if I set array from a vector of vector, it succeeds:
b1,b2=[[1 2],[3 4]]
Therefore, is there any method to define array directly from a regular array (matrix, tensor), not nested array?
Looking to capture entire rows or columns?
a1, a2 = eachrow([1 2; 3 4])
I think it’s no different to change into nested vectors and set variables.
But be wary that
eachrow returns views to original matrix, that is makes references to the original matrix. If you want new vectors you may just project them by
What’s the meaning of project? Do you mean
map or some other functions?
You could just
collect each view to make copies.
I understand. Thx for your reply. I think your suggestion is also transfer matrix into vector of vector then set.