# ifdef ANSI_HEADERS # include # include # include # else # include # include # include # endif # include # include # include using namespace std; # include "fsu.hpp" int main ( int argc, char *argv[] ); void latinize_handle ( string input_filename ); //****************************************************************************80 int main ( int argc, char *argv[] ) //****************************************************************************80 // // Purpose: // // FSU_LATINIZE_STANDALONE "latinizes" a dataset. // // License: // // Copyright (C) 2004 John Burkardt and Max Gunzburger // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Modified: // // 10 November 2006 // // Author: // // John Burkardt // // Usage: // // fsu_latinize_standalone input_filename // { int i; string input_filename; timestamp ( ); cout << "\n"; cout << "FSU_LATINIZE_STANDALONE (C++ version)\n"; cout << " Read a dataset of N points in M dimensions,\n"; cout << " modify it into a Latin hypercube,\n"; cout << " write the modified dataset to a file.\n"; cout << "\n"; cout << " Compiled on " << __DATE__ << " at " << __TIME__ << ".\n"; if ( argc <= 1 ) { cout << "\n"; cout << "FSU_LATINIZE_STANDALONE:\n"; cout << " Please enter the name of a file to be analyzed.\n"; cin >> input_filename; } else { for ( i = 1; i < argc; i++ ) { input_filename = argv[i]; latinize_handle ( input_filename ); } } // // Terminate. // cout << "\n"; cout << "FSU_LATINIZE_STANDALONE\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void latinize_handle ( string input_filename ) //****************************************************************************80 // // Purpose: // // LATINIZE_HANDLE handles a single file. // // License: // // Copyright (C) 2004 John Burkardt and Max Gunzburger // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Modified: // // 10 November 2006 // // Author: // // John Burkardt // // Parameters: // // Input, char *INPUT_FILENAME, the name of the input file. // // Local parameters: // // Local, int DIM_NUM, the spatial dimension of the point set. // // Local, int N, the number of points. // // Local, double Z[DIM_NUM*N], the point set. // // Local, int NS, the number of sample points. // { int dim_num; int n; ofstream output; string output_filename; double *table; // // Need to create the output file name from the input filename. // output_filename = file_name_ext_swap ( input_filename, "latin.txt" ); r8mat_header_read ( input_filename, dim_num, n ); cout << "\n"; cout << " Read the header of \"" << input_filename << "\".\n"; cout << "\n"; cout << " Spatial dimension DIM_NUM = " << dim_num << "\n"; cout << " Number of points N = " << n << "\n"; table = r8mat_data_read ( input_filename, dim_num, n ); cout << "\n"; cout << " Read the data in \"" << input_filename << "\".\n"; r8mat_transpose_print_some ( dim_num, n, table, 1, 1, 5, 5, " Small portion of data read from file:" ); fsu_latinize ( dim_num, n, table ); cout << "\n"; cout << " Latinized the data.\n"; r8mat_transpose_print_some ( dim_num, n, table, 1, 1, 5, 5, " Small portion of Latinized data:" ); // // Write the data to a file. // r8mat_write ( output_filename, dim_num, n, table ); cout << "\n"; cout << " Wrote the latinized data to \"" << output_filename << "\".\n"; delete [] table; return; }