示例#1
0
        private IDataMatrix<ushort> EncodeFeatureValues(IDataMatrix<float> dataMatrix, CodeBook codeBook, int cThreads, bool fSparse)
        {
            //construct the matrix builder given if we want to have dense or sparse representations or not
            IDataMatrixBuilderRam<ushort> dataMatrixBuilderRam;
            if (fSparse)
            {
                dataMatrixBuilderRam = new DataMatrixBuilderRamSparse<ushort>(dataMatrix.NumRows, dataMatrix.NumCols, 0);
            }
            else
            {
                dataMatrixBuilderRam = new DataMatrixBuilderRamDense<ushort>(dataMatrix.NumRows, dataMatrix.NumCols);
            }

            MatrixEncoder matrixEncoder = new MatrixEncoder(dataMatrix, codeBook, dataMatrixBuilderRam);
            ProcessorMT processorMT = new ProcessorMT(matrixEncoder, cThreads);

#if QUANTIZER_TIMER
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
#if VERBOSE
            Console.WriteLine("Starting encoding timer...");
#endif
            timer.Start();
#endif

            processorMT.Process();

#if QUANTIZER_TIMER
            timer.Stop();
#if VERBOSE
            Console.WriteLine("Total encoding time: {0} seconds", 0.001 * timer.ElapsedMilliseconds);
#endif
#endif          
            return matrixEncoder.CodedMatrix;
        }
示例#2
0
        private CodeBook ComputeCodeBook(IDataMatrix<float> dataMatrix, int cThreads)
        {
            //perform quantization
            MatrixQuantizer matrixQuantizer = new MatrixQuantizer(dataMatrix);
            ProcessorMT processorMT = new ProcessorMT(matrixQuantizer, cThreads);

#if QUANTIZER_TIMER
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
#if VERBOSE
            Console.WriteLine("Starting codebook timer...");
#endif
            timer.Start();
#endif
            processorMT.Process();
#if QUANTIZER_TIMER
            timer.Stop();
#if VERBOSE
            Console.WriteLine("Total Codebook calculation time: {0} seconds", 0.001 * timer.ElapsedMilliseconds);
#endif
#endif

            //code book
            return matrixQuantizer.codeBook;
        }