Changeset 753 for trunk/yat/utility/matrix.cc
 Timestamp:
 Feb 17, 2007, 2:33:24 PM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/matrix.cc
r737 r753 5 5 Copyright (C) 2004 Jari HÃ¤kkinen, Peter Johansson 6 6 Copyright (C) 2005, 2006 Jari HÃ¤kkinen, Peter Johansson, Markus Ringnér 7 Copyright (C) 2007 Jari HÃ¤kkinen 7 8 8 9 This file is part of the yat library, http://lev.thep.lu.se/trac/yat … … 46 47 47 48 matrix::matrix(const size_t& r, const size_t& c, double init_value) 48 : view_(NULL) 49 { 50 m_ = gsl_matrix_alloc(r,c); 49 : m_(gsl_matrix_alloc(r,c)), view_(NULL) 50 { 51 if (!m_) 52 throw utility::GSL_error("matrix::matrix failed to allocate memory"); 51 53 set_all(init_value); 52 54 } … … 54 56 55 57 matrix::matrix(const matrix& o) 56 : view_(NULL) 57 { 58 m_ = o.create_gsl_matrix_copy(); 58 : m_(o.create_gsl_matrix_copy()), view_(NULL) 59 { 59 60 } 60 61 … … 69 70 offset_row,offset_column, 70 71 n_row,n_column)); 72 if (!view_) 73 throw utility::GSL_error("matrix::matrix failed to setup view"); 71 74 m_ = &(view_>matrix); 72 75 } … … 137 140 // convert the data to a gsl matrix 138 141 m_ = gsl_matrix_alloc ( nof_rows, nof_columns ); 142 if (!m_) 143 throw utility::GSL_error("matrix::matrix failed to allocate memory"); 139 144 for(u_int i=0;i<nof_rows;i++) 140 145 for(u_int j=0;j<nof_columns;j++) … … 176 181 { 177 182 gsl_matrix* m = gsl_matrix_alloc(rows(),columns()); 183 if (!m) 184 throw utility::GSL_error("matrix::create_gsl_matrix_copy failed to allocate memory"); 178 185 gsl_matrix_memcpy(m,m_); // Jari, a GSL return value is ignored here 179 186 return m; … … 340 347 else { 341 348 gsl_matrix* transposed = gsl_matrix_alloc(columns(),rows()); 349 if (!transposed) 350 throw utility::GSL_error("matrix::transpose failed to allocate memory"); 342 351 gsl_matrix_transpose_memcpy(transposed,m_); 343 352 gsl_matrix_free(m_); … … 408 417 { 409 418 gsl_matrix* result = gsl_matrix_alloc(rows(),other.columns()); 419 if (!result) 420 throw utility::GSL_error("matrix::operator*= failed to allocate memory"); 410 421 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, m_, other.m_, 0.0, result); 411 422 gsl_matrix_free(m_);
Note: See TracChangeset
for help on using the changeset viewer.