DynamicVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DYNAMICVECTOR_H_
36 #define _BLAZE_MATH_DYNAMICVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/math/DenseVector.h>
47 #include <blaze/system/Precision.h>
48 #include <blaze/util/Random.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // RAND SPECIALIZATION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
66 template< typename Type // Data type of the vector
67  , bool TF > // Transpose flag
68 class Rand< DynamicVector<Type,TF> >
69 {
70  public:
71  //**Generate functions**************************************************************************
74  inline const DynamicVector<Type,TF> generate( size_t n ) const;
75 
76  template< typename Arg >
77  inline const DynamicVector<Type,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
79  //**********************************************************************************************
80 
81  //**Randomize functions*************************************************************************
84  inline void randomize( DynamicVector<Type,TF>& vector ) const;
85 
86  template< typename Arg >
87  inline void randomize( DynamicVector<Type,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  , bool TF > // Transpose flag
104 inline const DynamicVector<Type,TF> Rand< DynamicVector<Type,TF> >::generate( size_t n ) const
105 {
106  DynamicVector<Type,TF> vector( n );
107  randomize( vector );
108  return vector;
109 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
123 template< typename Type // Data type of the vector
124  , bool TF > // Transpose flag
125 template< typename Arg > // Min/max argument type
126 inline const DynamicVector<Type,TF>
127  Rand< DynamicVector<Type,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
128 {
129  DynamicVector<Type,TF> vector( n );
130  randomize( vector, min, max );
131  return vector;
132 }
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
144 template< typename Type // Data type of the vector
145  , bool TF > // Transpose flag
146 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector ) const
147 {
148  using blaze::randomize;
149 
150  const size_t size( vector.size() );
151  for( size_t i=0UL; i<size; ++i ) {
152  randomize( vector[i] );
153  }
154 }
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
168 template< typename Type // Data type of the vector
169  , bool TF > // Transpose flag
170 template< typename Arg > // Min/max argument type
171 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector,
172  const Arg& min, const Arg& max ) const
173 {
174  using blaze::randomize;
175 
176  const size_t size( vector.size() );
177  for( size_t i=0UL; i<size; ++i ) {
178  randomize( vector[i], min, max );
179  }
180 }
182 //*************************************************************************************************
183 
184 
185 
186 
187 //=================================================================================================
188 //
189 // TYPE DEFINITIONS
190 //
191 //=================================================================================================
192 
193 //*************************************************************************************************
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
214 //*************************************************************************************************
215 
216 } // namespace blaze
217 
218 #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
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Implementation of a random number generator.
Efficient implementation of an arbitrary sized vector.The DynamicVector class template is the represe...
Definition: DynamicVector.h:168
DynamicVector< real_t, false > VecN
N-dimensional vector with system-specific precision.
Definition: DynamicVector.h:213
Header file for the implementation of an arbitrarily sized vector.
DynamicVector< float, false > VecNf
N-dimensional single precision vector.
Definition: DynamicVector.h:197
Header file for the floating point precision of the Blaze library.
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
DynamicVector< double, false > VecNd
N-dimensional double precision vector.
Definition: DynamicVector.h:205
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