/// <summary> /// Writes the matrix (including all zeros) into a text file (for debugging purposes). /// Basically, it uses a tabulator separated format (which can e.g. be /// imported into Matlab via <code>matrix = dlmread(path)</code> /// </summary> /// <remarks> /// The content of the file specified via <paramref name="path"/> will /// be overwritten.<br/> /// If running on more than one process, multiple files are written /// (they can be concatenated e.g. by 'cat' or directly in Matlab). /// </remarks> /// <param name="path">Path to the text file</param> /// <param name="tis"> /// the matrix to save /// </param> static public void SaveToTextFile(this IMutableMatrixEx tis, string path) { int Rank, Size; csMPI.Raw.Comm_Size(csMPI.Raw._COMM.WORLD, out Size); csMPI.Raw.Comm_Rank(csMPI.Raw._COMM.WORLD, out Rank); string append = ""; if (Size > 1) { append = "_" + (Rank + 1) + "of" + Size; } StreamWriter writer = new StreamWriter(path + append); writer.Write(tis.ToStringDense()); writer.Close(); }