public static PermutationBuilder GetSuccRL2CyclicPerms(int t) { return delegate (IList<int> perm) { var P = new SuccRL2CyclicPerms_MRRR (); P.Build (perm, t, new SuccRL2CyclicPerms_MRRR.BuildParams ()); return P; }; }
/// <summary> /// Build the specified seq, sigma and t. /// </summary> public void Build(IList<int> seq, int sigma, short t = 16, IIEncoder32 rl2_coder = null, short rl2_block_size = 127) { // A counting sort construction of the permutation var counters = new int[sigma]; foreach (var s in seq) { if (s + 1 < sigma) { counters [s + 1]++; } } for (int i = 1; i < sigma; i++) { counters [i] += counters [i - 1]; } var n = seq.Count; var P = new int[n]; for (int i = 0; i < n; i++) { var sym = seq [i]; var pos = counters [sym]; P [pos] = i; counters [sym] = pos + 1; } // the bitmap to save the lengths var lens = new BitStream32 (); int prevc = 0; foreach (var c in counters) { var len = c - prevc; prevc = c; lens.Write (true); lens.Write (false, len); } // an additional 1 to the end, to simplify source code lens.Write (true); var bb_lens = new FakeBitmap (lens); this.LENS = BitmapBuilder (bb_lens); this.PERM = new SuccRL2CyclicPerms_MRRR (); if (rl2_coder == null) { rl2_coder = new EliasGamma32 (); } var build_params = new SuccRL2CyclicPerms_MRRR.BuildParams (rl2_coder, rl2_block_size); this.PERM.Build (P, t, build_params); }
public void Load(BinaryReader Input) { this.PERM = new SuccRL2CyclicPerms_MRRR (); this.PERM.Load (Input); this.LENS = RankSelectGenericIO.Load (Input); }
public static PermutationBuilder GetSuccRL2CyclicPerms(int t, IIEncoder32 coder, short block_size) { return delegate (IList<int> perm) { var P = new SuccRL2CyclicPerms_MRRR (); P.Build (perm, t, new SuccRL2CyclicPerms_MRRR.BuildParams (coder, block_size)); return P; }; }