StaticVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_STATICVECTOR_H_
36 #define _BLAZE_MATH_STATICVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #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< StaticVector<Type,N,TF> >
69 {
70  public:
71  //**Generate functions**************************************************************************
74  inline const StaticVector<Type,N,TF> generate() const;
75 
76  template< typename Arg >
77  inline const StaticVector<Type,N,TF> generate( const Arg& min, const Arg& max ) const;
79  //**********************************************************************************************
80 
81  //**Randomize functions*************************************************************************
84  inline void randomize( StaticVector<Type,N,TF>& vector ) const;
85 
86  template< typename Arg >
87  inline void randomize( StaticVector<Type,N,TF>& vector, const Arg& min, const Arg& max ) const;
89  //**********************************************************************************************
90 };
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
101 template< typename Type // Data type of the vector
102  , size_t N // Number of elements
103  , bool TF > // Transpose flag
104 inline const StaticVector<Type,N,TF> Rand< StaticVector<Type,N,TF> >::generate() const
105 {
106  StaticVector<Type,N,TF> vector;
107  randomize( vector );
108  return vector;
109 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
122 template< typename Type // Data type of the vector
123  , size_t N // Number of elements
124  , bool TF > // Transpose flag
125 template< typename Arg > // Min/max argument type
126 inline const StaticVector<Type,N,TF>
127  Rand< StaticVector<Type,N,TF> >::generate( const Arg& min, const Arg& max ) const
128 {
129  StaticVector<Type,N,TF> vector;
130  randomize( vector, min, max );
131  return vector;
132 }
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
144 template< typename Type // Data type of the vector
145  , size_t N // Number of elements
146  , bool TF > // Transpose flag
147 inline void Rand< StaticVector<Type,N,TF> >::randomize( StaticVector<Type,N,TF>& vector ) const
148 {
149  using blaze::randomize;
150 
151  for( size_t i=0UL; i<N; ++i ) {
152  randomize( vector[i] );
153  }
154 }
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
168 template< typename Type // Data type of the vector
169  , size_t N // Number of elements
170  , bool TF > // Transpose flag
171 template< typename Arg > // Min/max argument type
172 inline void Rand< StaticVector<Type,N,TF> >::randomize( StaticVector<Type,N,TF>& vector,
173  const Arg& min, const Arg& max ) const
174 {
175  using blaze::randomize;
176 
177  for( size_t i=0UL; i<N; ++i ) {
178  randomize( vector[i], min, max );
179  }
180 }
182 //*************************************************************************************************
183 
184 } // namespace blaze
185 
186 #endif
Header file for the implementation of a fixed-size vector.
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
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 DynamicVector implementation.
Header file for all basic DenseVector functionality.
T generate() const
Generation of a random value in the range .
Definition: Random.h:252
Header file for the complete StaticMatrix implementation.