All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseElement.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_SPARSE_SPARSEELEMENT_H_
23 #define _BLAZE_MATH_SPARSE_SPARSEELEMENT_H_
24 
25 
26 namespace blaze {
27 
28 //=================================================================================================
29 //
30 // CLASS DEFINITION
31 //
32 //=================================================================================================
33 
34 //*************************************************************************************************
41 template< typename Type > // Type of the data element
43 {
44  public:
45  //**Constructors********************************************************************************
46  inline SparseElement();
47  inline SparseElement( const Type& v, size_t i );
48  // No explicitly declared copy constructor.
49  //**********************************************************************************************
50 
51  //**Destructor**********************************************************************************
52  // No explicitly declared destructor.
53  //**********************************************************************************************
54 
55  //**Operators***********************************************************************************
58  // No explicitly declared copy assignment operator.
59  template< typename Other > SparseElement& operator=( const SparseElement<Other>& rhs );
60 
61  inline SparseElement& operator=( const Type& v );
63  //**********************************************************************************************
64 
65  //**Acess functions*****************************************************************************
68  inline Type& value();
69  inline const Type& value() const;
70  inline size_t index() const;
72  //**********************************************************************************************
73 
74  protected:
75  //**Member variables****************************************************************************
78  Type value_;
79  size_t index_;
80 
81  //**********************************************************************************************
82 
83  private:
84  //**Friend declarations*************************************************************************
86  template< typename Other > friend class SparseElement;
88  //**********************************************************************************************
89 };
90 //*************************************************************************************************
91 
92 
93 
94 
95 //=================================================================================================
96 //
97 // CONSTRUCTORS
98 //
99 //=================================================================================================
100 
101 //*************************************************************************************************
104 template< typename Type > // Data type of the sparse element
106  : value_() // Value of the sparse element
107  , index_() // Index of the sparse element
108 {}
109 //*************************************************************************************************
110 
111 
112 //*************************************************************************************************
118 template< typename Type > // Data type of the sparse element
119 inline SparseElement<Type>::SparseElement( const Type& v, size_t i )
120  : value_( v ) // Value of the sparse element
121  , index_( i ) // Index of the sparse element
122 {}
123 //*************************************************************************************************
124 
125 
126 
127 
128 //=================================================================================================
129 //
130 // OPERATORS
131 //
132 //=================================================================================================
133 
134 //*************************************************************************************************
140 template< typename Type > // Data type of the sparse element
141 template< typename Other > // Data type of the right-hand side sparse element
143 {
144  value_ = rhs.value_;
145  index_ = rhs.index_;
146  return *this;
147 }
148 //*************************************************************************************************
149 
150 
151 //*************************************************************************************************
157 template< typename Type > // Data type of the sparse element
159 {
160  value_ = v;
161  return *this;
162 }
163 //*************************************************************************************************
164 
165 
166 
167 
168 //=================================================================================================
169 //
170 // ACCESS FUNCTIONS
171 //
172 //=================================================================================================
173 
174 //*************************************************************************************************
179 template< typename Type > // Data type of the sparse element
181 {
182  return value_;
183 }
184 //*************************************************************************************************
185 
186 
187 //*************************************************************************************************
192 template< typename Type > // Data type of the sparse element
193 inline const Type& SparseElement<Type>::value() const
194 {
195  return value_;
196 }
197 //*************************************************************************************************
198 
199 
200 //*************************************************************************************************
205 template< typename Type > // Data type of the sparse element
206 inline size_t SparseElement<Type>::index() const
207 {
208  return index_;
209 }
210 //*************************************************************************************************
211 
212 } // namespace blaze
213 
214 #endif