- Timestamp:
- Feb 18, 2007, 1:01:39 AM (16 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/matrix.cc
r754 r755 191 191 192 192 193 int matrix::div_elements(const matrix& b) 194 { 195 return gsl_matrix_div_elements(m_, b.m_); 193 void matrix::div_elements(const matrix& b) 194 { 195 int status=gsl_matrix_div_elements(m_, b.m_); 196 if (status) 197 throw utility::GSL_error(std::string("matrix::div_elements",status)); 196 198 } 197 199 … … 269 271 270 272 271 int matrix::mul_elements(const matrix& b) 272 { 273 return gsl_matrix_mul_elements(m_, b.m_); 273 void matrix::mul_elements(const matrix& b) 274 { 275 int status=gsl_matrix_mul_elements(m_, b.m_); 276 if (status) 277 throw utility::GSL_error(std::string("matrix::mul_elements",status)); 278 274 279 } 275 280 … … 326 331 327 332 328 int matrix::swap(matrix& other) 329 { 330 return gsl_matrix_swap(m_, other.m_); 331 } 332 333 334 int matrix::swap_columns(const size_t i, const size_t j) 335 { 336 return gsl_matrix_swap_columns(m_, i, j); 337 } 338 339 340 int matrix::swap_rowcol(const size_t i, const size_t j) 341 { 342 return gsl_matrix_swap_rowcol(m_, i, j); 343 } 344 345 346 int matrix::swap_rows(const size_t i, const size_t j) 347 { 348 return gsl_matrix_swap_rows(m_, i, j); 333 void matrix::swap(matrix& other) 334 { 335 int status=gsl_matrix_swap(m_, other.m_); 336 if (status) 337 throw utility::GSL_error(std::string("matrix::swap",status)); 338 } 339 340 341 void matrix::swap_columns(const size_t i, const size_t j) 342 { 343 int status=gsl_matrix_swap_columns(m_, i, j); 344 if (status) 345 throw utility::GSL_error(std::string("matrix::swap_columns",status)); 346 } 347 348 349 void matrix::swap_rowcol(const size_t i, const size_t j) 350 { 351 int status=gsl_matrix_swap_rowcol(m_, i, j); 352 if (status) 353 throw utility::GSL_error(std::string("matrix::swap_rowcol",status)); 354 } 355 356 357 void matrix::swap_rows(const size_t i, const size_t j) 358 { 359 int status=gsl_matrix_swap_rows(m_, i, j); 360 if (status) 361 throw utility::GSL_error(std::string("matrix::swap_rows",status)); 349 362 } 350 363 … … 368 381 double& matrix::operator()(size_t row, size_t column) 369 382 { 370 return (*gsl_matrix_ptr(m_, row, column)); 383 double* d=gsl_matrix_ptr(m_, row, column); 384 if (!d) 385 throw utility::GSL_error("matrix::operator()",GSL_EINVAL); 386 return *d; 371 387 } 372 388 … … 374 390 const double& matrix::operator()(size_t row, size_t column) const 375 391 { 376 return (*gsl_matrix_const_ptr(m_, row, column)); 392 const double* d=gsl_matrix_const_ptr(m_, row, column); 393 if (!d) 394 throw utility::GSL_error("matrix::operator()",GSL_EINVAL); 395 return *d; 377 396 } 378 397 -
trunk/yat/utility/matrix.h
r754 r755 168 168 size_t columns(void) const; 169 169 170 / //171 ///Elementwise division of the elemnts of the calling matrix by172 ///the elements of matrix \a b, \f$ a_{ij} = a_{ij} / b_{ij} \;173 ///\forall i,j \f$. The result is stored into the calling matrix.174 /// 175 /// @return Whatever GSL returns.176 ///177 intdiv_elements(const matrix& b);170 /** 171 Elementwise division of the elemnts of the calling matrix by 172 the elements of matrix \a b, \f$ a_{ij} = a_{ij} / b_{ij} \; 173 \forall i,j \f$. The result is stored into the calling matrix. 174 175 \throw GSL_error if dimensions mis-match. 176 */ 177 void div_elements(const matrix& b); 178 178 179 179 /// … … 238 238 bool nan(matrix&) const; 239 239 240 /// 241 /// Multiply the elements of matrix \a b with the elements of the 242 /// calling matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall 243 /// i,j \f$. The result is stored into the calling matrix. 244 /// 245 /// @return Whatever GSL returns. 246 /// 247 int 248 mul_elements(const matrix& b); 240 /** 241 Multiply the elements of matrix \a b with the elements of the 242 calling matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j 243 \f$. The result is stored into the calling matrix. 244 245 \throw GSL_error if dimensions mis-match. 246 */ 247 void mul_elements(const matrix& b); 249 248 250 249 /// … … 305 304 void sub(const matrix& b); 306 305 307 /// 308 /// Exchange the elements of the this and \a other by copying. The 309 /// two matrices must have the same size. 310 /// 311 /// @return Whatever GSL returns. 312 /// 313 int swap(matrix& other); 314 315 /// 316 /// @brief Swap columns \a i and \a j. 317 /// 318 int swap_columns(const size_t i,const size_t j); 319 320 /// 321 /// @brief Swap row \a i and column \a j. 322 /// 323 int swap_rowcol(const size_t i,const size_t j); 324 325 /// 326 /// @brief Swap rows \a i and \a j. 327 /// 328 int swap_rows(const size_t i, const size_t j); 306 /** 307 \brief Exchange the elements of the this and \a other by copying. 308 309 The two matrices must have the same size. 310 311 \throw GSL_error if either index is out of bounds. 312 */ 313 void swap(matrix& other); 314 315 /** 316 \brief Swap columns \a i and \a j. 317 318 \throw GSL_error if either index is out of bounds. 319 */ 320 void swap_columns(const size_t i,const size_t j); 321 322 /** 323 \brief Swap row \a i and column \a j. 324 325 \throw GSL_error if either index is out of bounds, or if matrix 326 is not square. 327 */ 328 void swap_rowcol(const size_t i,const size_t j); 329 330 /** 331 \brief Swap rows \a i and \a j. 332 333 \throw GSL_error if either index is out of bounds. 334 */ 335 void swap_rows(const size_t i, const size_t j); 329 336 330 337 /** … … 336 343 void transpose(void); 337 344 338 /// 339 /// @return Reference to the element position (\a row, \a column). 340 /// 345 /** 346 \brief Element access operator. 347 348 \return Reference to the element position (\a row, \a column). 349 350 \throw If GSL range checks are enabled in the underlying GSL 351 library a GSL_error exception is thrown if either index is out 352 of range. 353 */ 341 354 double& operator()(size_t row,size_t column); 342 355 343 /// 344 /// @return Const reference to the element position (\a row, \a 345 /// column). 346 /// 356 /** 357 \brief Element access operator. 358 359 \return Const reference to the element position (\a row, \a 360 column). 361 362 \throw If GSL range checks are enabled in the underlying GSL 363 library a GSL_error exception is thrown if either index is out 364 of range. 365 */ 347 366 const double& operator()(size_t row,size_t column) const; 348 367 -
trunk/yat/utility/vector.cc
r754 r755 219 219 220 220 221 int vector::div(const vector& other) 222 { 223 return gsl_vector_div(v_,other.v_); 221 void vector::div(const vector& other) 222 { 223 int status=gsl_vector_div(v_,other.v_); 224 if (status) 225 throw utility::GSL_error(std::string("vector::div",status)); 224 226 } 225 227 … … 289 291 290 292 291 int vector::mul(const vector& other) 292 { 293 return gsl_vector_mul(v_,other.v_); 294 } 295 296 297 int vector::reverse(void) 298 { 299 return gsl_vector_reverse(v_); 293 void vector::mul(const vector& other) 294 { 295 int status=gsl_vector_mul(v_,other.v_); 296 if (status) 297 throw utility::GSL_error(std::string("vector::mul",status)); 298 } 299 300 301 void vector::reverse(void) 302 { 303 gsl_vector_reverse(v_); 300 304 } 301 305 … … 363 367 364 368 365 int vector::swap(vector& other) 366 { 367 return gsl_vector_swap(v_,other.v_); 368 } 369 370 371 int vector::swap_elements(size_t i, size_t j) 372 { 373 return gsl_vector_swap_elements(v_,i,j); 369 void vector::swap(vector& other) 370 { 371 int status=gsl_vector_swap(v_,other.v_); 372 if (status) 373 throw utility::GSL_error(std::string("vector::swap",status)); 374 } 375 376 377 void vector::swap_elements(size_t i, size_t j) 378 { 379 int status=gsl_vector_swap_elements(v_, i, j); 380 if (status) 381 throw utility::GSL_error(std::string("vector::swap_elements",status)); 374 382 } 375 383 … … 377 385 double& vector::operator()(size_t i) 378 386 { 379 return *gsl_vector_ptr(v_,i); 387 double* d=gsl_vector_ptr(v_, i); 388 if (!d) 389 throw utility::GSL_error("vector::operator()",GSL_EINVAL); 390 return *d; 380 391 } 381 392 … … 383 394 const double& vector::operator()(size_t i) const 384 395 { 385 return *gsl_vector_const_ptr(proxy_v_,i); 396 const double* d=gsl_vector_const_ptr(proxy_v_, i); 397 if (!d) 398 throw utility::GSL_error("vector::operator()",GSL_EINVAL); 399 return *d; 386 400 } 387 401 -
trunk/yat/utility/vector.h
r754 r755 228 228 void add(double term); 229 229 230 /// 231 /// This function performs element-wise division, \f$ this_i = 232 /// this_i/other_i \; \forall i \f$. 233 /// 234 /// @return GSL_SUCCESS on normal exit. 235 /// 236 // Jari, doxygen group as Vector operators 237 int div(const vector& other); 230 /** 231 \brief This function performs element-wise division, \f$ this_i = 232 this_i/other_i \; \forall i \f$. 233 234 \throw GSL_error if dimensions mis-match. 235 */ 236 void div(const vector& other); 238 237 239 238 /// … … 303 302 std::pair<size_t,size_t> minmax_index(void) const; 304 303 305 /// 306 /// This function performs element-wise multiplication, \f$ this_i = 307 /// this_i * other_i \; \forall i \f$. 308 /// 309 /// @return GSL_SUCCESS on normal exit. 310 /// 311 // Jari, doxygen group as Vector operators 312 int mul(const vector& other); 313 314 /// 315 /// Reverse the order of elements in the vector. 316 /// 317 /// @return GSL_SUCCESS on normal exit. 318 /// 319 // Jari, doxygen group as Exchanging elements 320 int reverse(void); 304 /** 305 \brief This function performs element-wise multiplication, \f$ 306 this_i = this_i * other_i \; \forall i \f$. 307 308 \throw GSL_error if dimensions mis-match. 309 */ 310 void mul(const vector& other); 311 312 /** 313 \brief Reverse the order of elements in the vector. 314 */ 315 void reverse(void); 321 316 322 317 /** … … 384 379 double sum(void) const; 385 380 386 /// 387 /// Swap vector elements by copying. The two vectors must have the 388 /// same length. 389 /// 390 /// @return GSL_SUCCESS on normal exit. 391 /// 392 int swap(vector& other); 393 394 /// 395 /// Exchange elements \a i and \a j. 396 /// 397 /// @return GSL_SUCCESS on normal exit. 398 /// 399 // Jari, doxygen group as Exchanging elements 400 int swap_elements(size_t i,size_t j); 401 402 /// 403 /// Element access operator. 404 /// 405 /// @return Reference to element \a i. 406 /// 407 // Jari, doxygen group as Accessing vector elements 381 /** 382 \brief Swap vector elements by copying. 383 384 The two vectors must have the same length. 385 386 \throw GSL_error if vector lengths differs. 387 */ 388 void swap(vector& other); 389 390 /** 391 \brief Exchange elements \a i and \a j. 392 393 \throw GSL_error if vector lengths differs. 394 */ 395 void swap_elements(size_t i, size_t j); 396 397 /** 398 \brief Element access operator. 399 400 \return Reference to element \a i. 401 402 \throw If GSL range checks are enabled in the underlying GSL 403 library a GSL_error exception is thrown if either index is out 404 of range. 405 */ 408 406 double& operator()(size_t i); 409 407 410 /// 411 /// Const element access operator. 412 /// 413 /// @return The value of element \a i. 414 /// 415 // Jari, doxygen group as Accessing vector elements 408 /** 409 \brief Element access operator. 410 411 \return Const reference to element \a i. 412 413 \throw If GSL range checks are enabled in the underlying GSL 414 library a GSL_error exception is thrown if either index is out 415 of range. 416 */ 416 417 const double& operator()(size_t i) const; 417 418
Note: See TracChangeset
for help on using the changeset viewer.