MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseLinAlgPack_IVector.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 IVECTOR_H
43 #define IVECTOR_H
44 
45 #include <assert.h>
46 
47 #include <valarray>
48 
50 #include "Teuchos_Assert.hpp"
51 
52 namespace DenseLinAlgPack {
54 /* * Fortran compatable integer vector for holding the pivot information for
55  * the elements of a vector, or the rows or columns of a matrix.
56  */
57 class IVector : public std::valarray<DenseLinAlgPack::size_type> {
58 public:
59 
60  // STL typedefs
64  typedef const value_type& const_reference;
65  typedef value_type* iterator;
66  typedef const value_type* const_iterator;
67  typedef std::valarray<size_type> valarray;
68 
69  // constructors
70 
72  IVector();
74  IVector(size_type n);
76  IVector(const value_type& val, size_type n);
78  IVector(const value_type* p, size_type n);
79 
81  IVector& operator=(const IVector&);
82 
87 
89  iterator begin();
91  const_iterator begin() const;
93  iterator end();
95  const_iterator end() const;
96 
97 }; // end class IVector
98 
99 // Inline definitions
100 
102 {}
103 
105 {}
106 
107 inline IVector::IVector(const value_type& val, size_type n) : std::valarray<size_type>(val,n)
108 {}
109 
110 inline IVector::IVector(const value_type* p, size_type n) : std::valarray<size_type>(p,n)
111 {}
112 
114 {
115  this->resize(iv.size());
116  std::valarray<DenseLinAlgPack::size_type>::operator=(iv);
117  return *this;
118 }
119 
121 {
122 #ifdef TEUCHOS_DEBUG
123  TEUCHOS_TEST_FOR_EXCEPT( !( 1 <= i && i <= static_cast<size_type>(size()) ) );
124 #endif
125  return operator[](i-1);
126 }
127 
129 {
130 #ifdef TEUCHOS_DEBUG
131  TEUCHOS_TEST_FOR_EXCEPT( !( 1 <= i && i <= static_cast<size_type>(size()) ) );
132 #endif
133  return const_cast<IVector*>(this)->operator[](i-1);
134 }
135 
137 { return &operator[](0); }
138 
140 { return &(const_cast<IVector*>(this)->operator[](0)); }
141 
143 { return begin() + size(); }
144 
146 { return begin() + size(); }
147 
148 } // end namespace DenseLinAlgPack
149 
150 #endif // IVECTOR_H
Teuchos::Ordinal size_type
Typedef for the size type of elements that are used by the library.
Teuchos::Ordinal index_type
Typedef for the index type of elements that are used by the library.
iterator end()
STL iterator.
DenseLinAlgPack::size_type size_type
IVector & operator=(const IVector &)
Resize on assignment.
std::valarray< size_type > valarray
iterator begin()
STL iterator.
DenseLinAlgPack::index_type value_type
reference operator()(size_type i)
1-based element access (range checked if TEUCHOS_DEBUG is defined)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)