/// <summary> /// Writes a matrix with char values in DenseAnsi format to a textWriter. Does not need to convert to DenseAnsi format. /// </summary> /// <param name="matrix">The matrix to write</param> /// <param name="textWriter">The stream to write to</param> /// <param name="parallelOptions">A ParallelOptions instance that configures the multithreaded behavior of this operation.</param> public static void WriteDenseAnsi(this Matrix <string, string, char> matrix, TextWriter textWriter, ParallelOptions parallelOptions) { textWriter.WriteLine("var\t{0}", matrix.ColKeys.StringJoin("\t")); foreach (string rowKey in matrix.RowKeys) { textWriter.Write(rowKey); textWriter.Write("\t"); int rowIndex = matrix.IndexOfRowKey[rowKey]; List <byte> storeList = new List <byte>(matrix.ColCount); for (int colIndex = 0; colIndex < matrix.ColCount; ++colIndex) { char value; byte store; if (matrix.TryGetValue(rowIndex, colIndex, out value)) { store = DenseAnsi.StaticValueToStore(value); } else { store = DenseAnsi.StaticStoreMissingValue; } storeList.Add(store); } Helper.CheckCondition(storeList.Count == matrix.ColCount, Properties.Resource.ExpectedStoreListCountToEqualColCount, storeList.Count, matrix.ColCount); string s = DenseAnsi.StoreListToString(storeList, matrix.ColCount); textWriter.WriteLine(s); } }
private static string CreateLine(Matrix <string, string, char> matrix, string rowKey, CounterWithMessages counterWithMessages) { int rowIndex = matrix.IndexOfRowKey[rowKey]; List <byte> storeList = new List <byte>(matrix.ColCount); for (int colIndex = 0; colIndex < matrix.ColCount; ++colIndex) { char value; byte store; if (matrix.TryGetValue(rowIndex, colIndex, out value)) { store = DenseAnsi.StaticValueToStore(value); } else { store = DenseAnsi.StaticStoreMissingValue; } storeList.Add(store); } Helper.CheckCondition(storeList.Count == matrix.ColCount, "Assert"); string s = rowKey + "\t" + DenseAnsi.StoreListToString(storeList, matrix.ColCount); counterWithMessages.Increment(); return(s); }