Recently, I need to solve two problems.
The first is I have two vectors,
src. They are the same length.
flag = [0,1,4,0,3,0]
src = [11,9,6,7,0,7]
flagis a vector whose element is 0 or 1 and
srccontains some intergers. Then I need to get the vector
src_selected_idxis a vector whose elements are in the positions indicated by
How to perform it?
Then I need to set an matrix of
Mwhose size is
10*10and for most elements are 0s with sparse ones.
Here I need to set
M[1,9], M[4,6], M[3,0]to the value
1(the row index is each element of
flag_ones_idxwhile the col index is each element of
src_selected_idx). Any ways to do it?