All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynamicVector.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_DYNAMICVECTOR_H_
23 #define _BLAZE_MATH_DYNAMICVECTOR_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
31 #include <blaze/math/DenseVector.h>
33 #include <blaze/system/Precision.h>
34 #include <blaze/util/Random.h>
35 
36 
37 namespace blaze {
38 
39 //=================================================================================================
40 //
41 // RAND SPECIALIZATION
42 //
43 //=================================================================================================
44 
45 //*************************************************************************************************
52 template< typename Type // Data type of the vector
53  , bool TF > // Transpose flag
54 class Rand< DynamicVector<Type,TF> >
55 {
56  public:
57  //**Generate functions**************************************************************************
60  inline const DynamicVector<Type,TF> generate( size_t n ) const;
61 
62  template< typename Arg >
63  inline const DynamicVector<Type,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
65  //**********************************************************************************************
66 
67  //**Randomize functions*************************************************************************
70  inline void randomize( DynamicVector<Type,TF>& vector ) const;
71 
72  template< typename Arg >
73  inline void randomize( DynamicVector<Type,TF>& vector, const Arg& min, const Arg& max ) const;
75  //**********************************************************************************************
76 };
78 //*************************************************************************************************
79 
80 
81 //*************************************************************************************************
88 template< typename Type // Data type of the vector
89  , bool TF > // Transpose flag
90 inline const DynamicVector<Type,TF> Rand< DynamicVector<Type,TF> >::generate( size_t n ) const
91 {
92  DynamicVector<Type,TF> vector( n );
93  randomize( vector );
94  return vector;
95 }
97 //*************************************************************************************************
98 
99 
100 //*************************************************************************************************
109 template< typename Type // Data type of the vector
110  , bool TF > // Transpose flag
111 template< typename Arg > // Min/max argument type
112 inline const DynamicVector<Type,TF>
113  Rand< DynamicVector<Type,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
114 {
115  DynamicVector<Type,TF> vector( n );
116  randomize( vector, min, max );
117  return vector;
118 }
120 //*************************************************************************************************
121 
122 
123 //*************************************************************************************************
130 template< typename Type // Data type of the vector
131  , bool TF > // Transpose flag
132 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector ) const
133 {
134  using blaze::randomize;
135 
136  const size_t size( vector.size() );
137  for( size_t i=0UL; i<size; ++i ) {
138  randomize( vector[i] );
139  }
140 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
154 template< typename Type // Data type of the vector
155  , bool TF > // Transpose flag
156 template< typename Arg > // Min/max argument type
157 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector,
158  const Arg& min, const Arg& max ) const
159 {
160  using blaze::randomize;
161 
162  const size_t size( vector.size() );
163  for( size_t i=0UL; i<size; ++i ) {
164  randomize( vector[i], min, max );
165  }
166 }
168 //*************************************************************************************************
169 
170 
171 
172 
173 //=================================================================================================
174 //
175 // TYPE DEFINITIONS
176 //
177 //=================================================================================================
178 
179 //*************************************************************************************************
184 //*************************************************************************************************
185 
186 
187 //*************************************************************************************************
192 //*************************************************************************************************
193 
194 
195 //*************************************************************************************************
200 //*************************************************************************************************
201 
202 } // namespace blaze
203 
204 #endif