Test permuting and removing componenents of an array
download this example: permuting-arrays-testing.edp or return to Matrices and Arrays
real[int] V=[1,2,2,1,20],C(5), D(5); cout << " array V. Size of V = " << V << endl; // // indexing // int[int] I(0:4); cout << " array of indices I = " << I << endl; // cout<<" Permuting indices second and third and nonsetting last entry "<<endl; // I(2)=3;I(3)=2;I(4)=-1; cout << " array of permuted indices I = " << I << endl; // // permuting values on V // C=V(I); cout << "C=V(I) permutation of array V. Size of C = " << C << endl; D(I)=V; cout << " array D(I)=V. Size of D = " << D << endl; cout << " array I. Size of I = " << I << endl; for (int i=0;i<I.n;i++) if (I(i)>=0) cout<<" i = "<<i<<" I(i) = "<<I(i)<<" V(i)= "<<V[i]<<" ==> D(I(i))= "<<D(I[i])<<endl; int[int] I1(0:4); cout << "Again... array of indices I = " << I1 << endl; // cout<< "permuting to remove the 1 from V "<<endl; // int ii=I1(3); I1(3)=I1(4);I1(4)=ii; cout << "Again...new array of indices I = " << I1 << endl; C=0; C=V(I1); cout << " Array V with 1 at the end. Size = " << C << endl; C.resize(C.n-1); cout << " Array V without 1. Size = " << C << endl;