Intrepid
Intrepid_MiniTensor_Vector.h
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) 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: Alejandro Mota (amota@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #if !defined(Intrepid_MiniTensor_Vector_h)
43 #define Intrepid_MiniTensor_Vector_h
44 
45 #include <algorithm>
46 #include <cassert>
47 #include <iostream>
48 #include <vector>
49 
50 #include "Intrepid_MiniTensor_Definitions.h"
51 #include "Intrepid_MiniTensor_Storage.h"
52 #include "Intrepid_MiniTensor_TensorBase.h"
53 #include "Intrepid_MiniTensor_Utilities.h"
54 
55 namespace Intrepid {
56 
60 template<typename T>
61 class Vector : public TensorBase<T>
62 {
63 public:
64 
68  static Index const
69  order = 1U;
70 
74  Vector();
75 
80  explicit
81  Vector(Index const dimension);
82 
88  explicit
89  Vector(Index const dimension, ComponentValue value);
90 
96  explicit
97  Vector(Index const dimension, T const & s);
98 
103  Vector(T const & s0, T const & s1);
104 
110  Vector(T const & s0, T const & s1, T const & s2);
111 
117  Vector(Index const dimension, T const * data_ptr);
118 
122  Vector(Vector<T> const & v);
123 
127  ~Vector();
128 
133  T const &
134  operator()(Index const i) const;
135 
140  T &
141  operator()(Index const i);
142 
146  Index
147  get_order() const {return order;}
148 
149 };
150 
155 template<typename S, typename T>
156 Vector<typename Promote<S, T>::type>
157 operator+(Vector<S> const & u, Vector<T> const & v);
158 
163 template<typename S, typename T>
164 Vector<typename Promote<S, T>::type>
165 operator-(Vector<S> const & u, Vector<T> const & v);
166 
171 template<typename T>
172 Vector<T>
173 operator-(Vector<T> const & u);
174 
179 template<typename S, typename T>
180 typename Promote<S, T>::type
181 operator*(Vector<S> const & u, Vector<T> const & v);
182 
187 template<typename T>
188 bool
189 operator==(Vector<T> const & u, Vector<T> const & v);
190 
195 template<typename T>
196 bool
197 operator!=(Vector<T> const & u, Vector<T> const & v);
198 
205 template<typename S, typename T>
206 typename lazy_disable_if< order_1234<S>, apply_vector< Promote<S,T> > >::type
207 operator*(S const & s, Vector<T> const & u);
208 
215 template<typename S, typename T>
216 typename lazy_disable_if< order_1234<S>, apply_vector< Promote<S,T> > >::type
217 operator*(Vector<T> const & u, S const & s);
218 
225 template<typename S, typename T>
226 Vector<typename Promote<S, T>::type>
227 operator/(Vector<T> const & u, S const & s);
228 
233 template<typename S, typename T>
234 typename Promote<S, T>::type
235 dot(Vector<S> const & u, Vector<T> const & v);
236 
242 template<typename S, typename T>
243 Vector<typename Promote<S, T>::type>
244 cross(Vector<S> const & u, Vector<T> const & v);
245 
250 template<typename T>
251 T
252 norm(Vector<T> const & u);
253 
258 template<typename T>
259 T
260 norm_square(Vector<T> const & u);
261 
266 template<typename T>
267 T
268 norm_1(Vector<T> const & u);
269 
274 template<typename T>
275 T
276 norm_infinity(Vector<T> const & u);
277 
284 template<typename T>
285 std::istream &
286 operator>>(std::istream & is, Vector<T> & u);
287 
294 template<typename T>
295 std::ostream &
296 operator<<(std::ostream & os, Vector<T> const & u);
297 
298 } // namespace Intrepid
299 
300 #include "Intrepid_MiniTensor_Vector.i.h"
301 #include "Intrepid_MiniTensor_Vector.t.h"
302 
303 #endif //Intrepid_MiniTensor_Vector_h
T const & operator()(Index const i) const
static Index const order