私は GSL 関数を使用して順列を生成しています。正常に動作し、結果は 4 です! 順列。
gsl_permutation * p = gsl_permutation_calloc (4);
gsl_permutation_init (p);
do
{
gsl_permutation_fprintf (stdout, p, " %u");
printf("\n");
}
while (gsl_permutation_next(p) == GSL_SUCCESS);
return 0;
出力は
0 1 2 3
1 0 2 3
...... n!
私の問題は、2 つの並列配列のベースで順列の数を減らしたいということです。
int value= {0,1,2,3};
int id = {1,1,3,3};
「値」の順列を生成する前に私が望むのは、要素の数を次のように減らすことです
疑似コード
if id of value element==id of next value element
join that elements like below
newValue= {0_1,2_3}
so total no of elements are 2
I will then pass this 2 to generate permutation
result should be 2!
and after permutation if one of the permutation should be {1,0}
it will re-split it into {2,3,0,1}
どうすれば C に変換できるかわかりません。助けが必要です。
ありがとう