public static void r8st_header_read(string input_filename, ref int i_min, ref int i_max, ref int j_min, ref int j_max, ref int m, ref int n, ref int nst) //****************************************************************************80 // // Purpose: // // R8ST_HEADER_READ reads the header of an R8ST file. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 25 January 2014 // // Author: // // John Burkardt // // Parameters: // // Input, string INPUT_FILENAME, the name of the file. // // Output, int &I_MIN, &I_MAX, the minimum and maximum row indices. // // Output, int &J_MIN, &J_MAX, the minimum and maximum column indices. // // Output, int &M, the number of rows. // // Output, int &N, the number of columns . // // Output, int &NST, the number of nonzeros. // { try { string[] input = File.ReadAllLines(input_filename); nst = 0; i_min = +i4_huge(); i_max = -i4_huge(); j_min = +i4_huge(); j_max = -i4_huge(); for (;;) { string[] tokens = Helpers.splitStringByWhitespace(input[nst]); i4 ti = s_to_i4(tokens[0]); i4 tj = s_to_i4(tokens[1]); int i = ti.val; int j = tj.val; nst += 1; i_min = Math.Min(i_min, i); i_max = Math.Max(i_max, i); j_min = Math.Min(j_min, j); j_max = Math.Max(j_max, j); if (nst == input.Length) { break; } } } catch (Exception) { } m = i_max - i_min + 1; n = j_max - j_min + 1; }
public static void r8st_data_read(string input_filename, int m, int n, int nst, ref int[] ist, ref int[] jst, ref double[] ast) //****************************************************************************80 // // Purpose: // // R8ST_DATA_READ reads the data of an R8ST file. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 25 January 2014 // // Author: // // John Burkardt // // Parameters: // // Input, string INPUT_FILENAME, the name of the file. // // Input, int M, the number of rows. // // Input, int N, the number of columns . // // Input, int NST, the number of nonzeros . // // Output, int IST[NST], JST[NST], the row and column indices. // // Output, double AST[NST], the nonzero values. // { int k = 0; try { string[] input = File.ReadAllLines(input_filename); for (k = 0; k < nst; k++) { string[] tokens = Helpers.splitStringByWhitespace(input[k]); i4 ti = s_to_i4(tokens[0]); i4 tj = s_to_i4(tokens[1]); r8 taij = s_to_r8(tokens[2]); int i = ti.val; int j = tj.val; double aij = taij.val; ist[k] = i; jst[k] = j; ast[k] = aij; } } catch (Exception) { Console.WriteLine(""); Console.WriteLine("R8ST_DATA_READ - Fatal error!"); Console.WriteLine(" I/O error reading data index " + k + ""); } }