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/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  , bool TF > // Transpose flag
67 class Rand< DynamicVector<Type,TF> >
68 {
69  public:
70  //**Generate functions**************************************************************************
73  inline const DynamicVector<Type,TF> generate( size_t n ) const;
74 
75  template< typename Arg >
76  inline const DynamicVector<Type,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
78  //**********************************************************************************************
79 
80  //**Randomize functions*************************************************************************
83  inline void randomize( DynamicVector<Type,TF>& vector ) const;
84 
85  template< typename Arg >
86  inline void randomize( DynamicVector<Type,TF>& vector, const Arg& min, const Arg& max ) const;
88  //**********************************************************************************************
89 };
91 //*************************************************************************************************
92 
93 
94 //*************************************************************************************************
101 template< typename Type // Data type of the vector
102  , bool TF > // Transpose flag
103 inline const DynamicVector<Type,TF> Rand< DynamicVector<Type,TF> >::generate( size_t n ) const
104 {
105  DynamicVector<Type,TF> vector( n );
106  randomize( vector );
107  return vector;
108 }
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
122 template< typename Type // Data type of the vector
123  , bool TF > // Transpose flag
124 template< typename Arg > // Min/max argument type
125 inline const DynamicVector<Type,TF>
126  Rand< DynamicVector<Type,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
127 {
128  DynamicVector<Type,TF> vector( n );
129  randomize( vector, min, max );
130  return vector;
131 }
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
143 template< typename Type // Data type of the vector
144  , bool TF > // Transpose flag
145 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector ) const
146 {
147  using blaze::randomize;
148 
149  const size_t size( vector.size() );
150  for( size_t i=0UL; i<size; ++i ) {
151  randomize( vector[i] );
152  }
153 }
155 //*************************************************************************************************
156 
157 
158 //*************************************************************************************************
167 template< typename Type // Data type of the vector
168  , bool TF > // Transpose flag
169 template< typename Arg > // Min/max argument type
170 inline void Rand< DynamicVector<Type,TF> >::randomize( DynamicVector<Type,TF>& vector,
171  const Arg& min, const Arg& max ) const
172 {
173  using blaze::randomize;
174 
175  const size_t size( vector.size() );
176  for( size_t i=0UL; i<size; ++i ) {
177  randomize( vector[i], min, max );
178  }
179 }
181 //*************************************************************************************************
182 
183 } // namespace blaze
184 
185 #endif
Header file for the implementation of a fixed-size vector.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Implementation of a random number generator.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Header file for the implementation of an arbitrarily sized vector.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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:252