MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseLinAlgPack_DMatrixInFunc.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef GENMATRIX_IN_FUNC_H
43 #define GENMATRIX_IN_FUNC_H
44 
46 
47 namespace DenseLinAlgPack {
48 
49 /* * @name DMatrix/DMatrixSlice input stream functions.
50  *
51  * These are functions that are used to read a DMatrix or DMatrixSlice object in from a
52  * formated input stream.
53  *
54  * The input format is diferent depending on the on whether the bit
55  * #LinAlgPackIO::ignore_dim_bit# is set.
56  * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then the input format is:
57  *
58  * Case 1\\
59  * #m n#\\
60  * #gm(1,1) gm(1,2) gm(1,3) ... gm(1,n)#\\
61  * #gm(2,1) gm(2,2) gm(2,3) ... gm(2,n)#\\
62  * # . . . .#\\
63  * #gm(m,1) gm(m,2) gm(m,3) ... gm(m,n)#\\
64  *
65  * If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0# then the input format is:
66  *
67  * Case 2\\
68  * #gm(1,1) gm(1,2) gm(1,3) ... gm(1,n)#\\
69  * #gm(2,1) gm(2,2) gm(2,3) ... gm(2,n)#\\
70  * # . . . .#\\
71  * #gm(m,1) gm(m,2) gm(m,3) ... gm(m,n)#\\
72  *
73  * The numbers of the input must be seperated by white space (the line breaks are
74  * for looks only) and be valid C language numeric constants.
75  *
76  * In addition, comment lines may be inserted between rows of the input matrix.
77  * These comment lines take the form of Fortan comment lines in that they start on
78  * new lines (after a '\n' char) with a '*' char and end at the end of a line
79  * ('\n' terminated). After the elements for a row are read in the function
80  * #eat_comment_lines(is,'*');# is called.
81  *
82  * For example, the input format for the matrix {1.1 1.2; 2.1 2.2}
83  * with comments for case 1 is:
84  *
85  * #2 2#\\
86  * #* This is the first row#\\
87  * #1.1 1.2#\\
88  * #* This is the second row#\\
89  * #2.1 2.1#\\
90  *
91  * And for case 2 is:
92  *
93  * #* This is the first row#\\
94  * #1.1 1.2#\\
95  * #* This is the second row#\\
96  * #2.1 2.1#\\
97  *
98  * It is permisible for the dimension #m# and #n# in case 1 to be 0.
99  * In this case there will be no elements. So to input an empty matrix you would use:
100  *
101  * #0 0#\\
102  *
103  * If one of the dimenstions is zero but not the other then a #std::length_error#
104  * exception will be thrown.
105  * If any of the input operations fails then a LinAlgPackIO::InputException exception
106  * is thrown. In other words if #is.fail()# or #is.eof()# is true
107  * before all of the elements have been read in then the exception is thrown.
108  * Also if the stream becomes corrupted (#is.bad() == true#) then a #std::ios_base::failure#
109  * exception is thrown.
110  */
111 // @{
112 
114 /* * DMatrix input stream function.
115  *
116  * Inputs a DMatrix object from an input stream.
117  * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then #gm# is resized to #m# x #n#
118  * given in the file. If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0#
119  * then the number of elements read in depends on the current dimension of #gm#.
120  */
121 std::istream& input(std::istream& is, DMatrix* gm, LinAlgPackIO::fmtflags extra_flags);
122 
124 /* * DMatrixSlice input stream function.
125  *
126  * Inputs a DMatrixSlice object from an input stream.
127  * If #exta_flags & LinAlgPackIO::ignore_dim_bit != 0# then the dimension (sized) of #gms#
128  * is compared to the #m# and #n# given in the file and if they are not equal
129  * then a #LinAlgPackIO::InputException# is thrown. If #gms# is unsized then it is resized
130  * to #m# x #n#. If #exta_flags & LinAlgPackIO::ignore_dim_bit == 0# then the number of
131  * elements read in depends on the current size of #gms#.
132  */
133 std::istream& input(std::istream& is, DMatrixSlice* gms, LinAlgPackIO::fmtflags extra_flags);
134 
135 // @}
136 
137 } // end namespace DenseLinAlgPack
138 
139 #endif // GENMATRIX_IN_FUNC_H
std::istream & input(std::istream &is, DMatrix *gm, LinAlgPackIO::fmtflags extra_flags)
DenseLinAlgPack::DMatrixSlice DMatrixSlice