S
Sean Dettrick
Hi,
I have several <vector>'s of the same length, with entries
as follows:
I=[0,3,6,0,5,3,0]
A=[1,2,3,4,5,6,7]
B=[2,3,4,5,6,7,8]
I want to use STL to make (I == 0) a mask to operate on the
elements of A and B, i.e. I want to do this:
for (int i=0;i<I.size();i++){
if ( I == 0 ){
A = 0;
B = 0;
}
}
In fortran 90 it would be easy:
A = merge( 0, A, I==0 )
B = merge( 0, B, I==0 )
Can anybody point out how to do it in C++? I don't see how
replace_if can do it.
Thanks in advance,
Sean Dettrick
I have several <vector>'s of the same length, with entries
as follows:
I=[0,3,6,0,5,3,0]
A=[1,2,3,4,5,6,7]
B=[2,3,4,5,6,7,8]
I want to use STL to make (I == 0) a mask to operate on the
elements of A and B, i.e. I want to do this:
for (int i=0;i<I.size();i++){
if ( I == 0 ){
A = 0;
B = 0;
}
}
In fortran 90 it would be easy:
A = merge( 0, A, I==0 )
B = merge( 0, B, I==0 )
Can anybody point out how to do it in C++? I don't see how
replace_if can do it.
Thanks in advance,
Sean Dettrick