Intrepid
/usr/src/RPM/BUILD/trilinos-11.12.1/packages/intrepid/src/Shared/MiniTensor/Intrepid_MiniTensor_Vector.h
00001 // @HEADER
00002 // ************************************************************************
00003 //
00004 //                           Intrepid Package
00005 //                 Copyright (2007) 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: Alejandro Mota (amota@sandia.gov)
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 
00042 #if !defined(Intrepid_MiniTensor_Vector_h)
00043 #define Intrepid_MiniTensor_Vector_h
00044 
00045 #include <algorithm>
00046 #include <cassert>
00047 #include <iostream>
00048 #include <vector>
00049 
00050 #include "Intrepid_MiniTensor_TensorBase.h"
00051 
00052 namespace Intrepid {
00053 
00054 template<typename T, Index N>
00055 struct vector_store
00056 {
00057   typedef Storage<T, dimension_power<N, 1>::value> type;
00058 };
00059 
00063 template<typename T, Index N = DYNAMIC>
00064 class Vector : public TensorBase<T, typename vector_store<T, N>::type>
00065 {
00066 public:
00067 
00071   static
00072   Index const
00073   ORDER = 1;
00074 
00078   static
00079   bool const
00080   IS_DYNAMIC = N == DYNAMIC;
00081 
00085   typedef typename vector_store<T, N>::type
00086   Store;
00087 
00091   static
00092   Index
00093   get_order() {return ORDER;}
00094 
00099   explicit
00100   Vector();
00101 
00102   explicit
00103   Vector(Index const dimension);
00104 
00110   explicit
00111   Vector(ComponentValue const value);
00112 
00113   explicit
00114   Vector(Index const dimension, ComponentValue const value);
00115 
00121   Vector(T const * data_ptr);
00122 
00123   Vector(Index const dimension, T const * data_ptr);
00124 
00128   Vector(Vector<T, N> const & v);
00129 
00134   Vector(T const & s0, T const & s1);
00135 
00141   Vector(T const & s0, T const & s1, T const & s2);
00142 
00146   ~Vector();
00147 
00152   T const &
00153   operator()(Index const i) const;
00154 
00159   T &
00160   operator()(Index const i);
00161 
00165   Index
00166   get_dimension() const;
00167 
00171   void
00172   set_dimension(Index const dimension);
00173 
00174 };
00175 
00180 template<typename S, typename T, Index N>
00181 Vector<typename Promote<S, T>::type, N>
00182 operator+(Vector<S, N> const & u, Vector<T, N> const & v);
00183 
00188 template<typename S, typename T, Index N>
00189 Vector<typename Promote<S, T>::type, N>
00190 operator-(Vector<S, N> const & u, Vector<T, N> const & v);
00191 
00196 template<typename T, Index N>
00197 Vector<T, N>
00198 operator-(Vector<T, N> const & u);
00199 
00204 template<typename S, typename T, Index N>
00205 typename Promote<S, T>::type
00206 operator*(Vector<S, N> const & u, Vector<T, N> const & v);
00207 
00212 template<typename T, Index N>
00213 bool
00214 operator==(Vector<T, N> const & u, Vector<T, N> const & v);
00215 
00220 template<typename T, Index N>
00221 bool
00222 operator!=(Vector<T, N> const & u, Vector<T, N> const & v);
00223 
00230 template<typename S, typename T, Index N>
00231 typename lazy_disable_if< order_1234<S>, apply_vector< Promote<S,T>, N > >::type
00232 operator*(S const & s, Vector<T, N> const & u);
00233 
00240 template<typename S, typename T, Index N>
00241 typename lazy_disable_if< order_1234<S>, apply_vector< Promote<S,T>, N > >::type
00242 operator*(Vector<T, N> const & u, S const & s);
00243 
00250 template<typename S, typename T, Index N>
00251 Vector<typename Promote<S, T>::type, N>
00252 operator/(Vector<T, N> const & u, S const & s);
00253 
00260 template<typename S, typename T, Index N>
00261 Vector<typename Promote<S, T>::type, N>
00262 operator/(S const & s, Vector<T, N> const & u);
00263 
00268 template<typename S, typename T, Index N>
00269 typename Promote<S, T>::type
00270 dot(Vector<S, N> const & u, Vector<T, N> const & v);
00271 
00277 template<typename S, typename T, Index N>
00278 Vector<typename Promote<S, T>::type, N>
00279 cross(Vector<S, N> const & u, Vector<T, N> const & v);
00280 
00285 template<typename T, Index N>
00286 T
00287 norm(Vector<T, N> const & u);
00288 
00293 template<typename T, Index N>
00294 T
00295 norm_square(Vector<T, N> const & u);
00296 
00301 template<typename T, Index N>
00302 T
00303 norm_1(Vector<T, N> const & u);
00304 
00309 template<typename T, Index N>
00310 T
00311 norm_infinity(Vector<T, N> const & u);
00312 
00316 template<typename T, Index N>
00317 Vector<T, N>
00318 unit(Vector<T, N> const & u);
00319 
00326 template<typename T, Index N>
00327 std::pair<Vector<T, N>, T>
00328 house(Vector<T, N> const & x);
00329 
00336 template<typename T, Index N>
00337 std::istream &
00338 operator>>(std::istream & is, Vector<T, N> & u);
00339 
00346 template<typename T, Index N>
00347 std::ostream &
00348 operator<<(std::ostream & os, Vector<T, N> const & u);
00349 
00350 } // namespace Intrepid
00351 
00352 #include "Intrepid_MiniTensor_Vector.i.h"
00353 #include "Intrepid_MiniTensor_Vector.t.h"
00354 
00355 #endif //Intrepid_MiniTensor_Vector_h