MOOCHO (Single Doxygen Collection) Version of the Day
DenseLinAlgPack_DMatrixInFunc.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef GENMATRIX_IN_FUNC_H
00043 #define GENMATRIX_IN_FUNC_H
00044 
00045 #include "DenseLinAlgPack_IOBasic.hpp"
00046 
00047 namespace DenseLinAlgPack {
00048 
00049 /* * @name DMatrix/DMatrixSlice input stream functions.
00050   *
00051   * These are functions that are used to read a DMatrix or DMatrixSlice object in from a
00052   * formated input stream.
00053   *
00054   * The input format is diferent depending on the on whether the bit
00055   * #LinAlgPackIO::ignore_dim_bit# is set.
00056   * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then the input format is:
00057   *
00058   * Case 1\\
00059   * #m  n#\\
00060   * #gm(1,1) gm(1,2) gm(1,3) ... gm(1,n)#\\
00061   * #gm(2,1) gm(2,2) gm(2,3) ... gm(2,n)#\\
00062   * #   .       .       .           .#\\
00063   * #gm(m,1) gm(m,2) gm(m,3) ... gm(m,n)#\\
00064   *
00065   * If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0# then the input format is:
00066   *
00067   * Case 2\\
00068   * #gm(1,1) gm(1,2) gm(1,3) ... gm(1,n)#\\
00069   * #gm(2,1) gm(2,2) gm(2,3) ... gm(2,n)#\\
00070   * #   .       .       .           .#\\
00071   * #gm(m,1) gm(m,2) gm(m,3) ... gm(m,n)#\\
00072   *
00073   * The numbers of the input must be seperated by white space (the line breaks are
00074   * for looks only) and be valid C language numeric constants.
00075   *
00076   * In addition, comment lines may be inserted between rows of the input matrix.
00077   * These comment lines take the form of Fortan comment lines in that they start on
00078   * new lines (after a '\n' char) with a '*' char and end at the end of a line
00079   * ('\n' terminated).  After the elements for a row are read in the function
00080   * #eat_comment_lines(is,'*');# is called.
00081   *
00082   * For example, the input format for the matrix {1.1 1.2; 2.1 2.2}
00083   * with comments for case 1 is:
00084   *
00085   * #2  2#\\
00086   * #* This is the first row#\\
00087   * #1.1  1.2#\\
00088   * #* This is the second row#\\
00089   * #2.1  2.1#\\
00090   *
00091   * And for case 2 is:
00092   *
00093   * #* This is the first row#\\
00094   * #1.1  1.2#\\
00095   * #* This is the second row#\\
00096   * #2.1  2.1#\\
00097   *
00098   * It is permisible for the dimension #m# and #n# in case 1 to be 0.
00099   * In this case there will be no elements.  So to input an empty matrix you would use:
00100   *
00101   * #0  0#\\
00102   *
00103   * If one of the dimenstions is zero but not the other then a #std::length_error# 
00104   * exception will be thrown.
00105   * If any of the input operations fails then a LinAlgPackIO::InputException exception
00106   * is thrown.  In other words if #is.fail()# or #is.eof()# is true
00107   * before all of the elements have been read in then the exception is thrown.
00108   * Also if the stream becomes corrupted (#is.bad() == true#) then a #std::ios_base::failure#
00109   * exception is thrown. 
00110   */
00111 // @{
00112 
00114 /* * DMatrix input stream function.
00115   *
00116   * Inputs a DMatrix object from an input stream.
00117   * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then #gm# is resized to #m# x #n#
00118   * given in the file.  If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0#
00119   * then the number of elements read in depends on the current dimension of #gm#.
00120   */
00121 std::istream& input(std::istream& is, DMatrix* gm, LinAlgPackIO::fmtflags extra_flags);
00122 
00124 /* * DMatrixSlice input stream function.
00125   *
00126   * Inputs a DMatrixSlice object from an input stream.
00127   * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then the dimension (sized) of #gms#
00128   * is compared to the #m# and #n# given in the file and if they are not equal
00129   * then a #LinAlgPackIO::InputException# is thrown.  If #gms# is unsized then it is resized
00130   * to #m# x #n#.  If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0# then the number of
00131   * elements read in depends on the current size of #gms#.
00132   */
00133 std::istream& input(std::istream& is, DMatrixSlice* gms, LinAlgPackIO::fmtflags extra_flags);
00134 
00135 // @}
00136 
00137 } // end namespace DenseLinAlgPack
00138 
00139 #endif  // GENMATRIX_IN_FUNC_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines