Blaze  3.6
HybridVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_HYBRIDVECTOR_H_
36 #define _BLAZE_MATH_HYBRIDVECTOR_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  , size_t N // Number of elements
68  , bool TF > // Transpose flag
69 class Rand< HybridVector<Type,N,TF> >
70 {
71  public:
72  //**Generate functions**************************************************************************
75  inline const HybridVector<Type,N,TF> generate( size_t n ) const;
76 
77  template< typename Arg >
78  inline const HybridVector<Type,N,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
80  //**********************************************************************************************
81 
82  //**Randomize functions*************************************************************************
85  inline void randomize( HybridVector<Type,N,TF>& vector ) const;
86 
87  template< typename Arg >
88  inline void randomize( HybridVector<Type,N,TF>& vector, const Arg& min, const Arg& max ) const;
90  //**********************************************************************************************
91 };
93 //*************************************************************************************************
94 
95 
96 //*************************************************************************************************
103 template< typename Type // Data type of the vector
104  , size_t N // Number of elements
105  , bool TF > // Transpose flag
106 inline const HybridVector<Type,N,TF> Rand< HybridVector<Type,N,TF> >::generate( size_t n ) const
107 {
108  HybridVector<Type,N,TF> vector( n );
109  randomize( vector );
110  return vector;
111 }
113 //*************************************************************************************************
114 
115 
116 //*************************************************************************************************
125 template< typename Type // Data type of the vector
126  , size_t N // Number of elements
127  , bool TF > // Transpose flag
128 template< typename Arg > // Min/max argument type
129 inline const HybridVector<Type,N,TF>
130  Rand< HybridVector<Type,N,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
131 {
132  HybridVector<Type,N,TF> vector( n );
133  randomize( vector, min, max );
134  return vector;
135 }
137 //*************************************************************************************************
138 
139 
140 //*************************************************************************************************
147 template< typename Type // Data type of the vector
148  , size_t N // Number of elements
149  , bool TF > // Transpose flag
150 inline void Rand< HybridVector<Type,N,TF> >::randomize( HybridVector<Type,N,TF>& vector ) const
151 {
152  using blaze::randomize;
153 
154  for( size_t i=0UL; i<vector.size(); ++i ) {
155  randomize( vector[i] );
156  }
157 }
159 //*************************************************************************************************
160 
161 
162 //*************************************************************************************************
171 template< typename Type // Data type of the vector
172  , size_t N // Number of elements
173  , bool TF > // Transpose flag
174 template< typename Arg > // Min/max argument type
175 inline void Rand< HybridVector<Type,N,TF> >::randomize( HybridVector<Type,N,TF>& vector,
176  const Arg& min, const Arg& max ) const
177 {
178  using blaze::randomize;
179 
180  for( size_t i=0UL; i<vector.size(); ++i ) {
181  randomize( vector[i], min, max );
182  }
183 }
185 //*************************************************************************************************
186 
187 } // namespace blaze
188 
189 #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.
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.
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 HybridVector class template.