コード例 #1
0
        public void CorrelateSimulationCube(MathNet.Numerics.LinearAlgebra.Matrix <double> Rho)
        {
            Matrix <double> cholesky = Rho.Cholesky().Factor;

            Action <UInt64, UInt64> pfunc = (i, k) =>
            {
                double[] s = new double[number_of_dims];
                for (UInt64 j = 0; j < number_of_dims; ++j)
                {
                    s[j] = this[i, j, k];
                }

                s = (cholesky * Vector <double> .Build.Dense(s)).ToArray();

                for (UInt64 j = 0; j < number_of_dims; ++j)
                {
                    this[i, j, k] = s[j];
                }
            };

            using (WorkConsumer consumer = new utils.WorkConsumer(System.Environment.ProcessorCount - 1))//
            {
                for (UInt64 i = 0; i < number_of_sims; ++i)
                {
                    for (UInt64 k = 0; k < number_of_steps; ++k)
                    {
                        UInt64 locali = i;
                        UInt64 localk = k;
                        consumer.Enqueue(() => pfunc(locali, localk));
                    }
                }
                consumer.waitforEmptyQueue();
            }
        }
コード例 #2
0
 static double Train(Network network, MathNet.Numerics.LinearAlgebra.Matrix <double> inputActivationValues, int expectedResult, Func <Matrix <double>, int, double> errorFunction)
 {
     network.Layers.First.Value.ActivationMatrix = inputActivationValues;
     network.FeedForward();
     return(errorFunction(network.Layers.Last.Value.ActivationMatrix, expectedResult));
 }
コード例 #3
0
ファイル: Ranker.cs プロジェクト: barshaison/Search-Engine
        /// <summary>
        /// ranks a given document using semantic algorithem and BM25 algorithem
        /// </summary>
        /// <param name="R"></param>
        /// <param name="N"></param>
        /// <param name="k1"></param>
        /// <param name="k2"></param>
        /// <param name="b"></param>
        /// <param name="queryWordsData"></param>
        /// <param name="dl"></param>
        /// <param name="avdl"></param>
        /// <param name="docId"></param>
        /// <param name="q"></param>
        /// <param name="Dk_T"></param>
        /// <param name="docsMap"></param>
        /// <returns></returns>
        public static double rankDoc(int R, int N, double k1, double k2, double b, Dictionary <string /*word in query*/, queryWordData /*struct of data*/> queryWordsData, double dl, double avdl, string docId, MathNet.Numerics.LinearAlgebra.Vector <double> q, MathNet.Numerics.LinearAlgebra.Matrix <double> Dk_T, Dictionary <string, int> docsMap)
        {
            double rank;

            rank = BM25(R, N, k1, k2, b, queryWordsData, dl, avdl, docId);/*LSI(docId,q, Dk_T, docsMap);*/
            return(rank);
        }