Changeset 783 for trunk/yat/utility/vector.cc
 Timestamp:
 Mar 5, 2007, 10:45:32 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/vector.cc
r782 r783 30 30 #include "utility.h" 31 31 32 #include <cassert> 32 33 #include <iostream> 33 34 #include <sstream> 35 #include <utility> 34 36 #include <vector> 35 #include <utility>36 37 37 38 namespace theplu { … … 211 212 void vector::div(const vector& other) 212 213 { 214 assert(v_); assert(other.v_); 213 215 int status=gsl_vector_div(v_,other.v_); 214 216 if (status) … … 237 239 void vector::mul(const vector& other) 238 240 { 241 assert(v_); assert(other.v_); 239 242 int status=gsl_vector_mul(v_,other.v_); 240 243 if (status) … … 245 248 void vector::reverse(void) 246 249 { 250 assert(v_); 247 251 gsl_vector_reverse(v_); 248 252 } … … 251 255 void vector::set(const vector& vec) 252 256 { 257 assert(v_); assert(vec.v_); 253 258 if (gsl_vector_memcpy(v_,vec.v_)) 254 259 throw utility::GSL_error("vector::set dimension mismatch"); … … 258 263 void vector::set_all(const double& value) 259 264 { 265 assert(v_); 260 266 gsl_vector_set_all(v_,value); 261 267 } … … 272 278 void vector::swap(size_t i, size_t j) 273 279 { 280 assert(v_); 274 281 int status=gsl_vector_swap_elements(v_, i, j); 275 282 if (status) … … 280 287 double& vector::operator()(size_t i) 281 288 { 289 assert(v_); 282 290 double* d=gsl_vector_ptr(v_, i); 283 291 if (!d) … … 348 356 const vector& vector::operator+=(const vector& other) 349 357 { 350 int status=gsl_vector_add(v_,other. v_); 358 assert(v_); 359 int status=gsl_vector_add(v_, other.v_); 351 360 if (status) 352 361 throw utility::GSL_error(std::string("vector::add", status)); … … 357 366 const vector& vector::operator+=(double d) 358 367 { 368 assert(v_); 359 369 gsl_vector_add_constant(v_, d); 360 370 return *this; … … 364 374 const vector& vector::operator=(const vector& other) 365 375 { 376 assert(v_); 366 377 int status=gsl_vector_sub(v_, other.v_); 367 378 if (status) … … 373 384 const vector& vector::operator*=(const double d) 374 385 { 386 assert(v_); 375 387 gsl_vector_scale(v_, d); 376 388 return *this; … … 426 438 void set_basis(vector& v, size_t i) 427 439 { 440 assert(v.gsl_vector_p()); 428 441 gsl_vector_set_basis(v.gsl_vector_p(),i); 429 442 } … … 432 445 void sort(vector& v) 433 446 { 447 assert(v.gsl_vector_p()); 434 448 gsl_sort_vector(v.gsl_vector_p()); 435 449 } … … 448 462 void swap(vector& v, vector& w) 449 463 { 464 assert(v.gsl_vector_p()); assert(w.gsl_vector_p()); 450 465 int status=gsl_vector_swap(v.gsl_vector_p(),w.gsl_vector_p()); 451 466 if (status)
Note: See TracChangeset
for help on using the changeset viewer.