Changeset 830 for trunk/yat/utility
- Timestamp:
- Mar 24, 2007, 3:54:42 PM (16 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/matrix.cc
r813 r830 54 54 if (!m_) 55 55 throw utility::GSL_error("matrix::matrix failed to allocate memory"); 56 set_all(init_value);56 all(init_value); 57 57 } 58 58 … … 276 276 if (!m_) 277 277 throw utility::GSL_error("matrix::matrix failed to allocate memory"); 278 set_all(init_value);278 all(init_value); 279 279 280 280 // no need to delete blas_result_ if the number of rows fit, it … … 295 295 296 296 297 void matrix::set(const matrix& other) 298 { 299 assert(m_); 300 if (gsl_matrix_memcpy(m_, other.gsl_matrix_p())) 301 throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match"); 302 } 303 304 305 void matrix::set_all(const double value) 297 void matrix::all(const double value) 306 298 { 307 299 assert(m_); … … 310 302 311 303 312 void matrix:: set_column(const size_t column, const vector& vec)304 void matrix::column(const size_t column, const vector& vec) 313 305 { 314 306 assert(m_); … … 319 311 320 312 321 void matrix:: set_row(const size_t row, const vector& vec)313 void matrix::row(const size_t row, const vector& vec) 322 314 { 323 315 assert(m_); … … 413 405 const matrix& matrix::operator=( const matrix& other ) 414 406 { 415 set(other); 407 assert(m_); 408 if (gsl_matrix_memcpy(m_, other.gsl_matrix_p())) 409 throw utility::GSL_error("matrix::create_gsl_matrix_copy dimension mis-match"); 416 410 return *this; 417 411 } … … 517 511 flag.clone(matrix(rows,columns,1.0)); 518 512 else 519 flag. set_all(1.0);513 flag.all(1.0); 520 514 bool nan=false; 521 515 for (size_t i=0; i<rows; i++) -
trunk/yat/utility/matrix.h
r811 r830 217 217 size_t rows(void) const; 218 218 219 /**220 \brief Set element values to values in \a mat.221 222 This function is needed for assignment of viewed elements.223 224 \see const matrix& operator=(const matrix&)225 226 \throw GSL_error if dimensions mis-match.227 */228 void set(const matrix& mat);229 230 219 /// 231 220 /// Set all elements to \a value. 232 221 /// 233 void set_all(const double value);222 void all(const double value); 234 223 235 224 /** … … 241 230 sizes. 242 231 */ 243 void set_column(const size_t column, const vector& vec);232 void column(const size_t column, const vector& vec); 244 233 245 234 /** … … 251 240 sizes. 252 241 */ 253 void set_row(const size_t row, const vector& vec);242 void row(const size_t row, const vector& vec); 254 243 255 244 /** -
trunk/yat/utility/vector.cc
r825 r830 55 55 throw utility::GSL_error("vector::vector failed to allocate memory"); 56 56 57 set_all(init_value);57 all(init_value); 58 58 } 59 59 … … 300 300 if (!v_) 301 301 throw utility::GSL_error("vector::vector failed to allocate memory"); 302 set_all(init_value);302 all(init_value); 303 303 } 304 304 … … 311 311 312 312 313 void vector::set(const vector& vec) 314 { 315 assert(v_); 316 if (gsl_vector_memcpy(v_,vec.gsl_vector_p())) 317 throw utility::GSL_error("vector::set dimension mis-match"); 318 } 319 320 321 void vector::set_all(const double& value) 313 void vector::all(const double& value) 322 314 { 323 315 assert(v_); … … 397 389 const vector& vector::operator=( const vector& other ) 398 390 { 399 set(other); 391 assert(v_); 392 if (gsl_vector_memcpy(v_,other.gsl_vector_p())) 393 throw utility::GSL_error("vector::set dimension mis-match"); 400 394 return *this; 401 395 } … … 478 472 bool nan(const vector& templat, vector& flag) 479 473 { 480 size_t rows=templat.size();481 if ( rows!=flag.size())482 flag.clone(vector( rows,1.0));474 size_t vsize=templat.size(); 475 if (vsize!=flag.size()) 476 flag.clone(vector(vsize,1.0)); 483 477 else 484 flag. set_all(1.0);478 flag.all(1.0); 485 479 bool nan=false; 486 for (size_t i=0; i< rows; i++)480 for (size_t i=0; i<vsize; i++) 487 481 if (std::isnan(templat(i))) { 488 482 flag(i)=0; -
trunk/yat/utility/vector.h
r825 r830 282 282 void reverse(void); 283 283 284 /**285 \brief Set element values to values in \a vec.286 287 This function is needed for assignment of viewed elements.288 289 \see const vector& operator=(const vector&)290 291 \throw GSL_error if dimensions mis-match.292 */293 void set(const vector& vec);294 295 284 /// 296 285 /// Set all elements to \a value. 297 286 /// 298 void set_all(const double& value);287 void all(const double& value); 299 288 300 289 ///
Note: See TracChangeset
for help on using the changeset viewer.