コード例 #1
0
    public static TableHeader r8mat_header_read(string input_filename)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    R8MAT_HEADER_READ reads the header from an R8MAT file.
    //
    //  Discussion:
    //
    //    An R8MAT is an array of R8's.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 February 2009
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, string INPUT_FILENAME, the name of the input file.
    //
    //    Output, int &M, the number of spatial dimensions.
    //
    //    Output, int &N, the number of points.
    //
    {
        TableHeader ret = TableMisc.readHeader(input_filename);

        switch (ret.m)
        {
        case <= 0:
            Console.WriteLine();
            Console.WriteLine("R8MAT_HEADER_READ - Fatal error!");
            Console.WriteLine("  FILE_COLUMN_COUNT failed.");
            ret.code = 1;
            break;
        }

        switch (ret.n)
        {
        case <= 0:
            Console.WriteLine();
            Console.WriteLine("R8MAT_HEADER_READ - Fatal error!");
            Console.WriteLine("  FILE_ROW_COUNT failed.");
            ret.code = 1;
            break;
        }

        return(ret);
    }
コード例 #2
0
    public static TableHeader dtable_header_read(string input_filename)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    DTABLE_HEADER_READ reads the header from a real TABLE file.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    04 June 2004
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, char *INPUT_FILENAME, the name of the input file.
    //
    //    Output, int *M, the number of spatial dimensions.
    //
    //    Output, int *N, the number of points
    //
    {
        TableHeader h = new()
        {
            m = TableMisc.file_column_count(input_filename)
        };

        switch (h.m)
        {
        case <= 0:
            Console.WriteLine("");
            Console.WriteLine("DTABLE_HEADER_READ - Fatal error!");
            Console.WriteLine("  FILE_COLUMN_COUNT failed.");
            h.n = -1;
            return(h);
        }

        h.n = TableMisc.file_row_count(input_filename);

        switch (h.n)
        {
        case <= 0:
            Console.WriteLine("");
            Console.WriteLine("DTABLE_HEADER_READ - Fatal error!");
            Console.WriteLine("  FILE_ROW_COUNT failed.");
            break;
        }

        return(h);
    }
コード例 #3
0
    public static void ccs_header_read(string prefix, ref int ncc, ref int n)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    ccs_HEADER_READ reads header information about a sparse matrix in CCS format.
    //
    //  Discussion:
    //
    //    Three files are presumed to exist:
    //    * prefix_icc.txt contains NCC ICC values;
    //    * prefix_ccc.txt contains N+1 CCC values;
    //    * prefix_acc.txt contains NCC ACC values.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    18 July 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, string PREFIX, a common prefix for the filenames.
    //
    //    Output, int &NCC, the number of CCS elements.
    //
    //    Output, int &N, the number of columns in the matrix.
    //
    {
        string filename_icc = prefix + "_icc.txt";

        ncc = TableMisc.file_row_count(filename_icc);

        string filename_ccc = prefix + "_ccc.txt";

        n = TableMisc.file_row_count(filename_ccc) - 1;
    }
コード例 #4
0
    private static void test01(string input_filename)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LATINIZE_TEST tests the LATINIZE routines.
    //
    //  Discussion:
    //
    //    The dataset is presumed to be an M by N array of real numbers,
    //    where M is the spatial dimension, and N is the number of sample points.
    //
    //    The dataset is presumed to be stored in a file, with N records,
    //    one per each sample point.  (Comment records may be included,
    //    which begin with '#'.)
    //
    //    The program reads the data file, "latinizes" the data, and writes
    //    the latinized data to a new file.
    //
    //  Modified:
    //
    //    08 October 2004
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        //
        //  Need to create the output file name from the input filename.
        //
        string output_filename = TableMisc.file_name_ext_swap(input_filename, "latin.txt");

        TableHeader header = typeMethods.r8mat_header_read(input_filename);

        Console.WriteLine();
        Console.WriteLine("  Read the header of \"" + input_filename + "\".");
        Console.WriteLine();
        Console.WriteLine("  Spatial dimension M = " + header.m);
        Console.WriteLine("  Number of points N  = " + header.n);

        double[] table = typeMethods.r8mat_data_read(input_filename, header.m, header.n);

        Console.WriteLine();
        Console.WriteLine("  Read the data in \"" + input_filename + "\".");

        typeMethods.r8mat_transpose_print_some(header.m, header.n, table, 1, 1, 5, 5,
                                               "  Small portion of data read from file:");

        double[] latTable = Latinize.r8mat_latinize(header.m, header.n, table);

        Console.WriteLine();
        Console.WriteLine("  Latinized the data.\n");

        typeMethods.r8mat_transpose_print_some(header.m, header.n, latTable, 1, 1, 5, 5,
                                               "  Small portion of Latinized data:");
        //
        //  Write the data to a file.
        //
        typeMethods.r8mat_write(output_filename, header.m, header.n, latTable);

        Console.WriteLine();
        Console.WriteLine("  Wrote the latinized data to \"" + output_filename + "\".");
    }
コード例 #5
0
    private static void Main(string[] args)
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAIN is the main program for MESH_BANDWIDTH.
    //
    //  Discussion:
    //
    //    MESH_BANDWIDTH determines the geometric bandwidth of a mesh of elements.
    //
    //    The user supplies an element file, listing the indices of the nodes that
    //    make up each element.
    //
    //    The program computes the geometric bandwidth associated with the mesh.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    12 September 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Usage:
    //
    //    mesh_bandwidth element_filename
    //
    {
        string element_filename;
        int    element_num   = 0;
        int    element_order = 0;
        int    m             = 0;
        int    ml            = 0;
        int    mu            = 0;

        Console.WriteLine("");
        Console.WriteLine("MESH_BANDWIDTH");
        Console.WriteLine("  Read a mesh file which defines");
        Console.WriteLine("  a \"triangulation\" of a region in the plane,");
        Console.WriteLine("  or a \"tetrahedronization\" of a region in space,");
        Console.WriteLine("  or any division of a regino in ND space into elements,");
        Console.WriteLine("  using a mesh of elements of uniform order.");
        Console.WriteLine("");
        Console.WriteLine("  Determine the geometric mesh bandwidth.");
        Console.WriteLine("");
        Console.WriteLine("    M = ML + 1 + MU.");
        Console.WriteLine("");
        Console.WriteLine("  which is the bandwidth of the vertex connectivity");
        Console.WriteLine("  matrix.");
        Console.WriteLine("");
        Console.WriteLine("  Note that a matrix associated with variables defined");
        Console.WriteLine("  at the  nodes could have a greater bandwidth than M,");
        Console.WriteLine("  since you might have multiple variables at a vertex,");
        Console.WriteLine("  or the variable might be a vector quantity,");
        Console.WriteLine("  or physical effects might link two variables that are");
        Console.WriteLine("  not associated with vertices that are connected.");
        //
        //  If at least one command line argument, it's the element file.
        //
        try
        {
            element_filename = args[0];
        }
        catch
        {
            Console.WriteLine("");
            Console.WriteLine("MESH_BANDWIDTH:");
            Console.WriteLine("  Please enter the name of the element file.");

            element_filename = Console.ReadLine();
        }

        //
        //  Read the triangulation data.
        //
        TableMisc.readHeader(element_filename, ref element_order, ref element_num);

        Console.WriteLine("");
        Console.WriteLine("  Read the header of \"" + element_filename + "\".");
        Console.WriteLine("");
        Console.WriteLine("  Element order ELEMENT_ORDER =    " + element_order + "");
        Console.WriteLine("  Number of element ELEMENT_NUM  = " + element_num + "");

        int[] element_node = typeMethods.i4mat_data_read(element_filename, element_order,
                                                         element_num);

        Console.WriteLine("");
        Console.WriteLine("  Read the data in \"" + element_filename + "\".");

        typeMethods.i4mat_transpose_print_some(element_order, element_num, element_node, 1, 1,
                                               element_order, 10, "  Portion of data read from file:");
        //
        //  Compute the bandwidth.
        //
        Mesh.bandwidth_mesh(element_order, element_num, element_node, ref ml, ref mu, ref m);

        Console.WriteLine("");
        Console.WriteLine("  Lower bandwidth ML = " + ml + "");
        Console.WriteLine("  Upper bandwidth MU = " + mu + "");
        Console.WriteLine("  Total bandwidth M  = " + m + "");

        Console.WriteLine("");
        Console.WriteLine("MESH_BANDWIDTH");
        Console.WriteLine("  Normal end of execution.");
        Console.WriteLine("");
    }