Changeset 1015 for trunk/yat/utility/VectorBase.h
 Timestamp:
 Feb 1, 2008, 5:35:32 PM (15 years ago)
 File:

 1 moved
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/VectorBase.h
r1013 r1015 86 86 */ 87 87 88 class vectorBase88 class VectorBase 89 89 { 90 90 public: 91 91 92 /// \brief vectorBase::iterator93 typedef Iterator<double&, vectorBase> iterator;94 95 /// \brief vectorBase::const_iterator96 typedef Iterator<const double, const vectorBase> const_iterator;92 /// \brief VectorBase::iterator 93 typedef Iterator<double&, VectorBase> iterator; 94 95 /// \brief VectorBase::const_iterator 96 typedef Iterator<const double, const VectorBase> const_iterator; 97 97 98 98 /** 99 99 \brief default constructor 100 100 */ 101 vectorBase(void);101 VectorBase(void); 102 102 103 103 /** 104 104 \brief Constructor. 105 105 */ 106 vectorBase(gsl_vector*);106 VectorBase(gsl_vector*); 107 107 108 108 /** 109 109 \brief Constructor. 110 110 */ 111 vectorBase(const gsl_vector*);111 VectorBase(const gsl_vector*); 112 112 113 113 /// 114 114 /// The destructor. 115 115 /// 116 virtual ~ vectorBase(void);116 virtual ~VectorBase(void); 117 117 118 118 /// … … 122 122 123 123 /** 124 \return mutable iterator to start of vectorBase124 \return mutable iterator to start of VectorBase 125 125 */ 126 126 iterator begin(void); 127 127 128 128 /** 129 \return readonly iterator to start of vectorBase129 \return readonly iterator to start of VectorBase 130 130 */ 131 131 const_iterator begin(void) const; … … 137 137 \throw GSL_error if dimensions mismatch. 138 138 */ 139 void div(const vectorBase& other);140 141 /** 142 \return mutable iterator to end of vectorBase139 void div(const VectorBase& other); 140 141 /** 142 \return mutable iterator to end of VectorBase 143 143 */ 144 144 iterator end(void); 145 145 146 146 /** 147 \return readonly iterator to end of vectorBase147 \return readonly iterator to end of VectorBase 148 148 */ 149 149 const_iterator end(void) const; 150 150 151 151 /** 152 \brief Check whether vectorBases are equal within a user defined152 \brief Check whether VectorBases are equal within a user defined 153 153 precision, set by \a precision. 154 154 155 155 \return True if each element deviates less or equal than \a 156 d. If any vectorBase contain a NaN, false is always returned.156 d. If any VectorBase contain a NaN, false is always returned. 157 157 158 158 \see operator== and operator!= 159 159 */ 160 bool equal(const vectorBase&, const double precision=0) const;160 bool equal(const VectorBase&, const double precision=0) const; 161 161 162 162 /// … … 186 186 \throw GSL_error if dimensions mismatch. 187 187 */ 188 void mul(const vectorBase& other);189 190 /** 191 \brief Reverse the order of elements in the vectorBase.188 void mul(const VectorBase& other); 189 190 /** 191 \brief Reverse the order of elements in the VectorBase. 192 192 */ 193 193 void reverse(void); 194 194 195 195 /// 196 /// @return the number of elements in the vectorBase.196 /// @return the number of elements in the VectorBase. 197 197 /// 198 198 size_t size(void) const; … … 201 201 \brief Exchange elements \a i and \a j. 202 202 203 \throw GSL_error if vectorBase lengths differs.203 \throw GSL_error if VectorBase lengths differs. 204 204 */ 205 205 void swap(size_t i, size_t j); … … 240 240 \return True if all elements are equal otherwise false. 241 241 242 \see equal(const vectorBase&, const double precision=0)243 */ 244 bool operator==(const vectorBase&) const;242 \see equal(const VectorBase&, const double precision=0) 243 */ 244 bool operator==(const VectorBase&) const; 245 245 246 246 /** … … 253 253 \return False if all elements are equal otherwise true. 254 254 255 \see equal(const vectorBase&, const double precision=0)256 */ 257 bool operator!=(const vectorBase&) const;255 \see equal(const VectorBase&, const double precision=0) 256 */ 257 bool operator!=(const VectorBase&) const; 258 258 259 259 /// 260 260 /// @return The dot product. 261 261 /// 262 double operator*(const vectorBase&) const;262 double operator*(const VectorBase&) const; 263 263 264 264 /** 265 265 \brief The assignment operator. 266 266 267 Dimensions of the vectorBases must match. If the LHS vectorBase is a267 Dimensions of the VectorBases must match. If the LHS VectorBase is a 268 268 view, the underlying data will be changed. 269 269 270 \return A const reference to the resulting vectorBase.271 272 \see void set(const vectorBase&).270 \return A const reference to the resulting VectorBase. 271 272 \see void set(const VectorBase&). 273 273 274 274 \throw GSL_error if dimensions mismatch. 275 275 */ 276 //const vectorBase& operator=(vectorBase&);276 //const VectorBase& operator=(VectorBase&); 277 277 278 278 /** … … 280 280 this_i = this_i + other_i \; \forall i \f$. 281 281 282 \return A const reference to the resulting vectorBase.282 \return A const reference to the resulting VectorBase. 283 283 284 284 \throw GSL_error if dimensions mismatch. 285 285 */ 286 const vectorBase& operator+=(const vectorBase&);287 288 /** 289 \brief Add a constant to a vectorBase, \f$ this_i = this_i + d \;286 const VectorBase& operator+=(const VectorBase&); 287 288 /** 289 \brief Add a constant to a VectorBase, \f$ this_i = this_i + d \; 290 290 \forall i \f$. 291 291 292 \return A const reference to the resulting vectorBase.293 */ 294 const vectorBase& operator+=(double d);292 \return A const reference to the resulting VectorBase. 293 */ 294 const VectorBase& operator+=(double d); 295 295 296 296 /** … … 298 298 this_i = this_i  other_i \; \forall i \f$. 299 299 300 \return A const reference to the resulting vectorBase.300 \return A const reference to the resulting VectorBase. 301 301 302 302 \throw GSL_error if dimensions mismatch. 303 303 */ 304 const vectorBase& operator=(const vectorBase&);305 306 /** 307 \brief Subtract a constant to a vectorBase, \f$ this_i = this_i  d304 const VectorBase& operator=(const VectorBase&); 305 306 /** 307 \brief Subtract a constant to a VectorBase, \f$ this_i = this_i  d 308 308 \; \forall i \f$. 309 309 310 \return A const reference to the resulting vectorBase.311 */ 312 const vectorBase& operator=(double d);310 \return A const reference to the resulting VectorBase. 311 */ 312 const VectorBase& operator=(double d); 313 313 314 314 /** … … 316 316 this_i * d \; \forall i \f$. 317 317 318 \return A const reference to the resulting vectorBase.319 */ 320 const vectorBase& operator*=(double d);318 \return A const reference to the resulting VectorBase. 319 */ 320 const VectorBase& operator*=(double d); 321 321 322 322 … … 335 335 private: 336 336 // copy assignment no allowed 337 const vectorBase& operator=(const vectorBase&);337 const VectorBase& operator=(const VectorBase&); 338 338 public: 339 339 /** … … 344 344 345 345 /** 346 \brief Check if all elements of the vectorBase are zero.347 348 \return True if all elements in the vectorBase is zero, false346 \brief Check if all elements of the VectorBase are zero. 347 348 \return True if all elements in the VectorBase is zero, false 349 349 othwerwise. 350 350 */ 351 bool isnull(const vectorBase&);352 353 /** 354 \brief Get the maximum value of the vectorBase.355 356 \return The maximum value of the vectorBase.357 */ 358 double max(const vectorBase&);359 360 /** 361 \brief Locate the maximum value in the vectorBase.362 363 \return The index to the maximum value of the vectorBase.351 bool isnull(const VectorBase&); 352 353 /** 354 \brief Get the maximum value of the VectorBase. 355 356 \return The maximum value of the VectorBase. 357 */ 358 double max(const VectorBase&); 359 360 /** 361 \brief Locate the maximum value in the VectorBase. 362 363 \return The index to the maximum value of the VectorBase. 364 364 365 365 \note Lower index has precedence. 366 366 */ 367 size_t max_index(const vectorBase&);368 369 /** 370 \brief Get the minimum value of the vectorBase.371 372 \return The minimum value of the vectorBase.373 */ 374 double min(const vectorBase&);375 376 /** 377 \brief Locate the minimum value in the vectorBase.378 379 \return The index to the minimum value of the vectorBase.367 size_t max_index(const VectorBase&); 368 369 /** 370 \brief Get the minimum value of the VectorBase. 371 372 \return The minimum value of the VectorBase. 373 */ 374 double min(const VectorBase&); 375 376 /** 377 \brief Locate the minimum value in the VectorBase. 378 379 \return The index to the minimum value of the VectorBase. 380 380 381 381 \note Lower index has precedence. 382 382 */ 383 size_t min_index(const vectorBase&);384 385 /** 386 \brief Create a vectorBase \a flag indicating NaN's in another vectorBase383 size_t min_index(const VectorBase&); 384 385 /** 386 \brief Create a VectorBase \a flag indicating NaN's in another VectorBase 387 387 \a templat. 388 388 389 The \a flag vectorBase is changed to contain 1's and 0's only. A 1390 means that the corresponding element in the \a templat vectorBase is389 The \a flag VectorBase is changed to contain 1's and 0's only. A 1 390 means that the corresponding element in the \a templat VectorBase is 391 391 valid and a zero means that the corresponding element is a NaN. 392 392 393 \note Space for vectorBase \a flag is reallocated to fit the size of394 vectorBase \a templat if sizes mismatch.395 396 \return True if the \a templat vectorBase contains at least one NaN.397 */ 398 bool nan(const vectorBase& templat, vector& flag);399 400 /** 401 Randomly shuffles the elements in vectorBase \a invec402 */ 403 void shuffle( vectorBase& invec);404 405 /** 406 Sort the elements in the vectorBase.407 */ 408 void sort( vectorBase&);393 \note Space for VectorBase \a flag is reallocated to fit the size of 394 VectorBase \a templat if sizes mismatch. 395 396 \return True if the \a templat VectorBase contains at least one NaN. 397 */ 398 bool nan(const VectorBase& templat, vector& flag); 399 400 /** 401 Randomly shuffles the elements in VectorBase \a invec 402 */ 403 void shuffle(VectorBase& invec); 404 405 /** 406 Sort the elements in the VectorBase. 407 */ 408 void sort(VectorBase&); 409 409 410 410 /** 411 411 Create a vector \a sort_index containing the indeces of 412 elements in a another vectorBase \a invec. The elements of \a413 sort_index give the index of the vectorBase element which would414 have been stored in that position if the vectorBase had been sorted412 elements in a another VectorBase \a invec. The elements of \a 413 sort_index give the index of the VectorBase element which would 414 have been stored in that position if the VectorBase had been sorted 415 415 in place. The first element of \a sort_index gives the index of the least 416 416 element in \a invec, and the last element of \a sort_index gives the 417 index of the greatest element in \a invec . The vectorBase \a invec417 index of the greatest element in \a invec . The VectorBase \a invec 418 418 is not changed. 419 419 */ 420 void sort_index(std::vector<size_t>& sort_index, const vectorBase& invec);420 void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec); 421 421 422 422 /** 423 Similar to sort_index but creates a vectorBase with indices to the \a k423 Similar to sort_index but creates a VectorBase with indices to the \a k 424 424 smallest elements in \a invec. 425 425 */ 426 426 void sort_smallest_index(std::vector<size_t>& sort_index, size_t k, 427 const vectorBase& invec);427 const VectorBase& invec); 428 428 429 429 /** 430 Similar to sort_index but creates a vectorBase with indices to the \a k430 Similar to sort_index but creates a VectorBase with indices to the \a k 431 431 largest elements in \a invec. 432 432 */ 433 433 void sort_largest_index(std::vector<size_t>& sort_index, size_t k, 434 const vectorBase& invec);435 436 /** 437 \brief Calculate the sum of all vectorBase elements.434 const VectorBase& invec); 435 436 /** 437 \brief Calculate the sum of all VectorBase elements. 438 438 439 439 \return The sum. 440 440 */ 441 double sum(const vectorBase&);441 double sum(const VectorBase&); 442 442 443 443 /** … … 451 451 452 452 /** 453 \brief The output operator for the vectorBase class.454 */ 455 std::ostream& operator<<(std::ostream&, const vectorBase&);453 \brief The output operator for the VectorBase class. 454 */ 455 std::ostream& operator<<(std::ostream&, const VectorBase&); 456 456 457 457 }}} // of namespace utility, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.