Beispiel #1
0
        // dnahash.c (185, 1)
        // l_dnaHashGetCount(dahash) as int
        // l_dnaHashGetCount(L_DNAHASH *) as l_int32
        ///  <summary>
        /// l_dnaHashGetCount()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaHashGetCount/*"/>
        ///  <param name="dahash">[in] - </param>
        ///   <returns>nbuckets allocated, or 0 on error</returns>
        public static int l_dnaHashGetCount(
            L_DnaHash dahash)
        {
            if (dahash == null)
            {
                throw new ArgumentNullException("dahash cannot be Nothing");
            }

            int _Result = Natives.l_dnaHashGetCount(dahash.Pointer);

            return(_Result);
        }
Beispiel #2
0
        // dnahash.c (267, 1)
        // l_dnaHashAdd(dahash, key, value) as int
        // l_dnaHashAdd(L_DNAHASH *, l_uint64, l_float64) as l_ok
        ///  <summary>
        /// l_dnaHashAdd()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaHashAdd/*"/>
        ///  <param name="dahash">[in] - </param>
        ///  <param name="key">[in] - key to be hashed into a bucket number</param>
        ///  <param name="value">[in] - float value to be appended to the specific dna</param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int l_dnaHashAdd(
            L_DnaHash dahash,
            ulong key,
            double value)
        {
            if (dahash == null)
            {
                throw new ArgumentNullException("dahash cannot be Nothing");
            }

            int _Result = Natives.l_dnaHashAdd(dahash.Pointer, key, value);

            return(_Result);
        }
Beispiel #3
0
        // dnahash.c (152, 1)
        // l_dnaHashDestroy(pdahash) as Object
        // l_dnaHashDestroy(L_DNAHASH **) as void
        ///  <summary>
        /// l_dnaHashDestroy()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaHashDestroy/*"/>
        ///  <param name="pdahash">[in,out] - to be nulled, if it exists</param>
        public static void l_dnaHashDestroy(
            ref L_DnaHash pdahash)
        {
            IntPtr pdahashPtr = IntPtr.Zero;        if (pdahash != null)

            {
                pdahashPtr = pdahash.Pointer;
            }

            Natives.l_dnaHashDestroy(ref pdahashPtr);
            if (pdahashPtr == IntPtr.Zero)
            {
                pdahash = null;
            }
            else
            {
                pdahash = new L_DnaHash(pdahashPtr);
            };
        }
Beispiel #4
0
        // dnahash.c (421, 1)
        // l_dnaMakeHistoByHash(das, pdahash, pdav, pdac) as int
        // l_dnaMakeHistoByHash(L_DNA *, L_DNAHASH **, L_DNA **, L_DNA **) as l_ok
        ///  <summary>
        /// (1) Generates and returns a dna of occurrences (histogram),
        /// an aligned dna of values, and an associated hashmap.
        /// The hashmap takes %dav and a value, and points into the
        /// histogram in %dac.<para/>
        ///
        /// (2) The dna of values, %dav, is aligned with the histogram %dac,
        /// and is needed for fast lookup.  It is a hash set, because
        /// the values are unique.<para/>
        ///
        /// (3) Lookup is simple:
        /// l_dnaFindValByHash(dav, dahash, val, [and]index)
        /// if (index greater or equal 0)
        /// l_dnaGetIValue(dac, index, [and]icount)
        /// else
        /// icount = 0
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaMakeHistoByHash/*"/>
        ///  <param name="das">[in] - </param>
        ///  <param name="pdahash">[out] - hash map: val to index</param>
        ///  <param name="pdav">[out] - array of values: index to val</param>
        ///  <param name="pdac">[out] - histo array of counts: index to count</param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int l_dnaMakeHistoByHash(
            L_Dna das,
            out L_DnaHash pdahash,
            out L_Dna pdav,
            out L_Dna pdac)
        {
            if (das == null)
            {
                throw new ArgumentNullException("das cannot be Nothing");
            }

            IntPtr pdahashPtr = IntPtr.Zero;
            IntPtr pdavPtr    = IntPtr.Zero;
            IntPtr pdacPtr    = IntPtr.Zero;
            int    _Result    = Natives.l_dnaMakeHistoByHash(das.Pointer, out pdahashPtr, out pdavPtr, out pdacPtr);

            if (pdahashPtr == IntPtr.Zero)
            {
                pdahash = null;
            }
            else
            {
                pdahash = new L_DnaHash(pdahashPtr);
            };
            if (pdavPtr == IntPtr.Zero)
            {
                pdav = null;
            }
            else
            {
                pdav = new L_Dna(pdavPtr);
            };
            if (pdacPtr == IntPtr.Zero)
            {
                pdac = null;
            }
            else
            {
                pdac = new L_Dna(pdacPtr);
            };

            return(_Result);
        }
Beispiel #5
0
        // dnahash.c (232, 1)
        // l_dnaHashGetDna(dahash, key, copyflag) as L_Dna
        // l_dnaHashGetDna(L_DNAHASH *, l_uint64, l_int32) as L_DNA *
        ///  <summary>
        /// l_dnaHashGetDna()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaHashGetDna/*"/>
        ///  <param name="dahash">[in] - </param>
        ///  <param name="key">[in] - key to be hashed into a bucket number</param>
        ///  <param name="copyflag">[in] - L_NOCOPY, L_COPY, L_CLONE</param>
        ///   <returns>ptr to dna</returns>
        public static L_Dna l_dnaHashGetDna(
            L_DnaHash dahash,
            ulong key,
            int copyflag)
        {
            if (dahash == null)
            {
                throw new ArgumentNullException("dahash cannot be Nothing");
            }

            IntPtr _Result = Natives.l_dnaHashGetDna(dahash.Pointer, key, copyflag);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new L_Dna(_Result));
        }
Beispiel #6
0
        // dnahash.c (553, 1)
        // l_dnaFindValByHash(da, dahash, val, pindex) as int
        // l_dnaFindValByHash(L_DNA *, L_DNAHASH *, l_float64, l_int32 *) as l_ok
        ///  <summary>
        /// (1) Algo: hash %val into a key hash the key to get the dna
        /// in %dahash (that holds indices into %da) traverse
        /// the dna of indices looking for %val in %da.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/l_dnaFindValByHash/*"/>
        ///  <param name="da">[in] - </param>
        ///  <param name="dahash">[in] - containing indices into %da</param>
        ///  <param name="val">[in] - searching for this number in %da</param>
        ///  <param name="pindex">[out] - index into da if found -1 otherwise</param>
        ///   <returns>0 if OK 1 on error</returns>
        public static int l_dnaFindValByHash(
            L_Dna da,
            L_DnaHash dahash,
            double val,
            out int pindex)
        {
            if (da == null)
            {
                throw new ArgumentNullException("da cannot be Nothing");
            }

            if (dahash == null)
            {
                throw new ArgumentNullException("dahash cannot be Nothing");
            }

            int _Result = Natives.l_dnaFindValByHash(da.Pointer, dahash.Pointer, val, out pindex);

            return(_Result);
        }
Beispiel #7
0
        // ptafunc2.c (674, 1)
        // ptaFindPtByHash(pta, dahash, x, y, pindex) as int
        // ptaFindPtByHash(PTA *, L_DNAHASH *, l_int32, l_int32, l_int32 *) as l_ok
        ///  <summary>
        /// (1) Fast lookup in dnaHash associated with a pta, to see if a
        /// random point (x,y) is already stored in the hash table.<para/>
        ///
        /// (2) We use a strong hash function to minimize the chance that
        /// two different points hash to the same key value.<para/>
        ///
        /// (3) We select the number of buckets to be about 5% of the size
        /// of the input %pta, so that when fully populated, each
        /// bucket (dna) will have about 20 entries, each being an index
        /// into %pta.  In lookup, after hashing to the key, and then
        /// again to the bucket, we traverse the bucket (dna), using the
        /// index into %pta to check if the point (x,y) has been found before.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ptaFindPtByHash/*"/>
        ///  <param name="pta">[in] - </param>
        ///  <param name="dahash">[in] - built from pta</param>
        ///  <param name="x">[in] - arbitrary points</param>
        ///  <param name="y">[in] - arbitrary points</param>
        ///  <param name="pindex">[out] - index into pta if (x,y) is in pta -1 otherwise</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ptaFindPtByHash(
            Pta pta,
            L_DnaHash dahash,
            int x,
            int y,
            out int pindex)
        {
            if (pta == null)
            {
                throw new ArgumentNullException("pta cannot be Nothing");
            }

            if (dahash == null)
            {
                throw new ArgumentNullException("dahash cannot be Nothing");
            }

            int _Result = Natives.ptaFindPtByHash(pta.Pointer, dahash.Pointer, x, y, out pindex);

            return(_Result);
        }