public void Build(string sa_name, ListIBuilder list_builder = null) { using (var Input = new BinaryReader (File.OpenRead (sa_name + ".structs"))) { this.newF = GenericIO<Bitmap>.Load (Input); int len = this.newF.Count1; this.charT = new int[len]; // Console.WriteLine ("*****>> charT => {0} bytes", this.charT.Length * 4); PrimitiveIO<int>.LoadVector (Input, len, this.charT); } using (var Input = new BinaryReader (File.OpenRead (sa_name + ".psi"))) { var seq = PrimitiveIO<int>.LoadVector(Input, this.N+1, null); if (list_builder == null) { list_builder = ListIBuilders.GetListIDiffs(63); } this.Psi = list_builder(seq, seq.Count-1); } using (var Input = new BinaryReader (File.OpenRead (sa_name + ".samples"))) { this.SA_sample_step = Input.ReadInt16 (); this.SA_marked = GenericIO<Bitmap>.Load (Input); var _samples = new ListIFS (); _samples.Load (Input); var _invsamples = new ListIFS (); _invsamples.Load (Input); this.SA_samples = _samples; this.SA_invsamples = _invsamples; } }
public static PermutationBuilder GetCyclicPerms(int t, ListIBuilder listperm_builder = null, ListIBuilder listback_builder = null) { return delegate (IList<int> perm) { var P = new CyclicPerms_MRRR (); P.Build (perm, t, listperm_builder, listback_builder); return P; }; }
public void Build(IList<int> seq, int sigma, short B = 0, ListIBuilder list_builder = null, BitmapFromBitStream bitmap_builder = null) { if (list_builder == null) { list_builder = ListIBuilders.GetListIFS (); } if (bitmap_builder == null) { bitmap_builder = BitmapBuilders.GetGGMN_wt (16); } if (B <= 0) { B = (short)sigma; } this.sigma = sigma; this.B = B; var S = new BitStream32[sigma]; int n = seq.Count; // Console.WriteLine ("===== building"); // bool show_more = false; for (int i = 0; i < n; ++i) { if (i % this.B == 0) { for (int c = 0; c < sigma; ++c) { if (i == 0) { S [c] = new BitStream32 (); } S [c].Write (true); } } var sym = seq [i]; // if (i < 128 && sym == 14) { // Console.WriteLine ("i: {0}, sym: {1}", i, sym); // show_more = true; // } S [sym].Write (false); } var ostream = S [0]; for (int c = 1; c < sigma; ++c) { var istream = S [c]; for (int i = 0; i < istream.CountBits; ++i) { ostream.Write (istream [i]); } } this.X = bitmap_builder (new FakeBitmap (ostream)); // if (show_more) { // Console.WriteLine ("=== STREAM: {0}", S [14]); // Console.WriteLine ("=== BUILD n: {0}, X.Count: {1}, X.Count1: {2}", n, this.X.Count, this.X.Count1); // } this.SEQ = list_builder(seq, sigma); }
public virtual void Build(LAESA idx, int num_pivs, int num_rings, ListIBuilder list_builder = null) { // setting up MAX_SYMBOL and alpha_stddev values { num_rings = Math.Max (8, num_rings); num_rings = 1 << ((int)Math.Ceiling (Math.Log (num_rings, 2))); this.MAX_SYMBOL = num_rings - 1; this.alpha_stddev = 8.0 / num_rings; } this.DB = idx.DB; var P = (idx.PIVS as SampleSpace); var S = new int[num_pivs]; int n = this.DB.Count; this.STDDEV = new float[num_pivs]; this.MEAN = new float[num_pivs]; this.DIST = new IList<int>[num_pivs]; int I = 0; Action<int> build_one_pivot = delegate(int p) { S [p] = P.SAMPLE [p]; var D = new List<double>(idx.DIST[p]); this.ComputeStats(D, p); var stddev = this.STDDEV[p]; var mean = this.MEAN[p]; var L = new ListIFS(ListIFS.GetNumBits(this.MAX_SYMBOL)); for (int i = 0; i < n; ++i) { var d = D[i]; var sym = this.Discretize(d, stddev, mean); L.Add (sym); } if (list_builder == null) { this.DIST[p] = L; } else { this.DIST[p] = list_builder(L, this.MAX_SYMBOL); } if (I % 10 == 0 ) { Console.Write ("== advance: {0}/{1}, ", I, num_pivs); if (I % 50 == 0) { Console.WriteLine (); } } I++; }; Parallel.For(0, num_pivs, build_one_pivot); this.PIVS = new SampleSpace ("", P.DB, S); Console.WriteLine ("=== done Build CompactPivotsLRANS"); }
public void Build(string outname, IList<int> text, int sigma, int q, bool copy_on_access = true, bool parse_integers = false, ListIBuilder list_builder = null) { this.Name = outname; this.Q = q; this.CopyQGramsOnAccess = copy_on_access; this.ParseIntegers = parse_integers; if (list_builder == null) { list_builder = ListIBuilders.GetListIFS (); } var N = (int)(Math.Ceiling (text.Count * 1.0 / q)) * q; Console.WriteLine ("=== sigma: {0}, q: {1}, N: {2}", sigma, q, N); if (N == text.Count) { this.TEXT = list_builder (text, sigma); } else { this.TEXT = list_builder (new ListPaddingToN<int> (text, N, sigma), sigma); } }
public static SequenceBuilder GetSeqPlain(short B = 0, ListIBuilder list_builder = null, BitmapFromBitStream bitmap_builder = null, bool CopyOnUnravel = false) { return delegate (IList<int> seq, int sigma) { if (CopyOnUnravel) { var s = new SeqPlainCopyOnUnravel(); s.Build(seq, sigma, B, list_builder, bitmap_builder); return s; } else { var s = new SeqPlain(); s.Build(seq, sigma, B, list_builder, bitmap_builder); return s; } }; }
public KnrSeqSearch GetSortedByPrefix(SequenceBuilder seq_builder = null, ListIBuilder list_builder = null) { int n = this.DB.Count; var seqs = new int[n][]; var perm = new int[n]; for (int i = 0; i < n; ++i) { seqs [i] = this.GetStoredKnr (i); perm [i] = i; } // please speed up this method using another sorting method // Sorting.Sort<int> (perm, (x,y) => StringSpace<int>.LexicographicCompare (seqs [x], seqs [y])); Sorting.Sort<int[],int> (seqs, perm, (x,y) => StringSpace<int>.LexicographicCompare (x, y)); var S = new ListGen<int> ((int i) => seqs [i / this.K] [i % this.K], n * this.K); if (list_builder == null) { list_builder = ListIBuilders.GetListIFS(); } if (seq_builder == null) { seq_builder = SequenceBuilders.GetSeqXLB_DiffSet64(24, 63); } var knr = new KnrSeqSearch(); knr.DB = new SampleSpace("", this.DB, list_builder(perm, n-1)); knr.K = this.K; knr.MAXCAND = this.MAXCAND; knr.R = this.R; knr.SEQ = seq_builder(S, this.R.DB.Count); return knr; }
public override void Build(LAESA idx, int num_pivs, int num_rings, ListIBuilder list_builder) { throw new NotSupportedException("This method should not be used on this specilized class"); }