Blaze  3.6
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/math/ZeroVector.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 } // 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
Implementation of a random number generator.
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
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Header file for the complete ZeroVector implementation.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
Header file for the complete DynamicMatrix implementation.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Header file for all basic DenseVector functionality.
T generate() const
Generation of a random value in the range .
Definition: Random.h:252