HybridVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_HYBRIDVECTOR_H_
36 #define _BLAZE_MATH_HYBRIDVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/math/DenseVector.h>
47 #include <blaze/util/Random.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // RAND SPECIALIZATION
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
65 template< typename Type // Data type of the vector
66  , size_t N // Number of elements
67  , bool TF > // Transpose flag
68 class Rand< HybridVector<Type,N,TF> >
69 {
70  public:
71  //**Generate functions**************************************************************************
74  inline const HybridVector<Type,N,TF> generate( size_t n ) const;
75 
76  template< typename Arg >
77  inline const HybridVector<Type,N,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
79  //**********************************************************************************************
80 
81  //**Randomize functions*************************************************************************
84  inline void randomize( HybridVector<Type,N,TF>& vector ) const;
85 
86  template< typename Arg >
87  inline void randomize( HybridVector<Type,N,TF>& vector, const Arg& min, const Arg& max ) const;
89  //**********************************************************************************************
90 };
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
102 template< typename Type // Data type of the vector
103  , size_t N // Number of elements
104  , bool TF > // Transpose flag
105 inline const HybridVector<Type,N,TF> Rand< HybridVector<Type,N,TF> >::generate( size_t n ) const
106 {
107  HybridVector<Type,N,TF> vector( n );
108  randomize( vector );
109  return vector;
110 }
112 //*************************************************************************************************
113 
114 
115 //*************************************************************************************************
124 template< typename Type // Data type of the vector
125  , size_t N // Number of elements
126  , bool TF > // Transpose flag
127 template< typename Arg > // Min/max argument type
128 inline const HybridVector<Type,N,TF>
129  Rand< HybridVector<Type,N,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
130 {
131  HybridVector<Type,N,TF> vector( n );
132  randomize( vector, min, max );
133  return vector;
134 }
136 //*************************************************************************************************
137 
138 
139 //*************************************************************************************************
146 template< typename Type // Data type of the vector
147  , size_t N // Number of elements
148  , bool TF > // Transpose flag
149 inline void Rand< HybridVector<Type,N,TF> >::randomize( HybridVector<Type,N,TF>& vector ) const
150 {
151  using blaze::randomize;
152 
153  for( size_t i=0UL; i<vector.size(); ++i ) {
154  randomize( vector[i] );
155  }
156 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
170 template< typename Type // Data type of the vector
171  , size_t N // Number of elements
172  , bool TF > // Transpose flag
173 template< typename Arg > // Min/max argument type
174 inline void Rand< HybridVector<Type,N,TF> >::randomize( HybridVector<Type,N,TF>& vector,
175  const Arg& min, const Arg& max ) const
176 {
177  using blaze::randomize;
178 
179  for( size_t i=0UL; i<vector.size(); ++i ) {
180  randomize( vector[i], min, max );
181  }
182 }
184 //*************************************************************************************************
185 
186 } // namespace blaze
187 
188 #endif
Header file for the implementation of a fixed-size vector.
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Implementation of a random number generator.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the complete DynamicMatrix implementation.
Header file for all basic DenseVector functionality.
T generate() const
Generation of a random value in the range .
Definition: Random.h:220
Header file for the HybridVector class template.