Ejemplo n.º 1
0
        /// <summary>
        /// Converts matrix to a DenseAnsi. Even if the matrix is already an denseAnsi, a new one is created..
        /// </summary>
        /// <param name="matrix">The matrix to convert from</param>
        /// <param name="parallelOptions">A ParallelOptions instance that configures the multithreaded behavior of this operation.</param>
        /// <returns>A denseAnsi version of the matrix</returns>
        public static DenseAnsi ToDenseAnsi(this Matrix <string, string, char> matrix, ParallelOptions parallelOptions)
        {
            var denseAnsi = DenseAnsi.CreateEmptyInstance(matrix.RowKeys, matrix.ColKeys, DenseAnsi.StaticMissingValue);

            //Console.WriteLine("Convert no more than {0} values", matrix.RowCount * matrix.ColCount);
            //CounterWithMessages counterWithMessages = new CounterWithMessages("adding value #{0}", 100000, null);
            Parallel.ForEach(matrix.RowKeyColKeyValues, parallelOptions, triple =>
            {
                //counterWithMessages.Increment();
                denseAnsi[triple.RowKey, triple.ColKey] = triple.Value;
            });
            return(denseAnsi);
        }