From 774682ff8d2958cacf4ae039739031731042fdc9 Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 31 Dec 2012 21:45:52 +0000 Subject: [PATCH] Avoid use of the deprecated Table::data() function by making use of the fact that FullMatrix and LapackFullMatrix are derived from Table and are therefore able to access the (protected) member variable that stores the actual data. git-svn-id: https://svn.dealii.org/branches/branch_deprecated@27886 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/full_matrix.templates.h | 16 +++---- deal.II/source/lac/lapack_full_matrix.cc | 48 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/deal.II/include/deal.II/lac/full_matrix.templates.h b/deal.II/include/deal.II/lac/full_matrix.templates.h index e4a7099bff..d7adfc766f 100644 --- a/deal.II/include/deal.II/lac/full_matrix.templates.h +++ b/deal.II/include/deal.II/lac/full_matrix.templates.h @@ -130,8 +130,8 @@ FullMatrix::all_zero () const { Assert (!this->empty(), ExcEmptyMatrix()); - const number *p = this->data(); - const number *const e = this->data() + this->n_elements(); + const number *p = &this->values[0]; + const number *const e = &this->values[0] + this->n_elements(); while (p!=e) if (*p++ != number(0.0)) return false; @@ -194,7 +194,7 @@ FullMatrix::vmult (Vector &dst, Assert (&src != &dst, ExcSourceEqualsDestination()); - const number *e = this->data(); + const number *e = &this->values[0]; // get access to the data in order to // avoid copying it when using the () // operator @@ -224,7 +224,7 @@ void FullMatrix::Tvmult (Vector &dst, Assert (&src != &dst, ExcSourceEqualsDestination()); - const number *e = this->data(); + const number *e = &this->values[0]; number2 *dst_ptr = &dst(0); const unsigned int size_m = m(), size_n = n(); @@ -370,7 +370,7 @@ void FullMatrix::fill_permutation (const FullMatrix &src, /* void FullMatrix::fill (const number2* entries) */ /* { */ /* if (n_cols()*n_rows() != 0) */ -/* std::copy (entries, entries+n_rows()*n_cols(), this->data()); */ +/* std::copy (entries, entries+n_rows()*n_cols(), &this->values[0]); */ /* } */ @@ -949,7 +949,7 @@ FullMatrix::matrix_norm_square (const Vector &v) const number2 sum = 0.; const unsigned int n_rows = m(); - const number *val_ptr = this->data(); + const number *val_ptr = &this->values[0]; const number2 *v_ptr; for (unsigned int row=0; row::matrix_scalar_product (const Vector &u, number2 sum = 0.; const unsigned int n_rows = m(); const unsigned int n_cols = n(); - const number *val_ptr = this->data(); + const number *val_ptr = &this->values[0]; const number2 *v_ptr; for (unsigned int row=0; row::frobenius_norm () const real_type s = 0.; for (unsigned int i=0; in_rows()*this->n_cols(); ++i) - s += numbers::NumberTraits::abs_square(this->data()[i]); + s += numbers::NumberTraits::abs_square(this->values[i]); return std::sqrt(s); } diff --git a/deal.II/source/lac/lapack_full_matrix.cc b/deal.II/source/lac/lapack_full_matrix.cc index 2cbcc23c67..5582ef2b5a 100644 --- a/deal.II/source/lac/lapack_full_matrix.cc +++ b/deal.II/source/lac/lapack_full_matrix.cc @@ -112,7 +112,7 @@ LAPACKFullMatrix::vmult ( AssertDimension(v.size(), this->n_cols()); AssertDimension(w.size(), this->n_rows()); - gemv("N", &mm, &nn, &alpha, this->data(), &mm, v.val, &one, &beta, w.val, &one); + gemv("N", &mm, &nn, &alpha, &this->values[0], &mm, v.val, &one, &beta, w.val, &one); break; } case svd: @@ -121,12 +121,12 @@ LAPACKFullMatrix::vmult ( AssertDimension(w.size(), this->n_rows()); // Compute V^T v work.resize(std::max(mm,nn)); - gemv("N", &nn, &nn, &alpha, svd_vt->data(), &nn, v.val, &one, &null, &work[0], &one); + gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one); // Multiply by singular values for (unsigned int i=0; idata(), &mm, &work[0], &one, &beta, w.val, &one); + gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, &work[0], &one, &beta, w.val, &one); break; } case inverse_svd: @@ -135,12 +135,12 @@ LAPACKFullMatrix::vmult ( AssertDimension(v.size(), this->n_rows()); // Compute U^T v work.resize(std::max(mm,nn)); - gemv("T", &mm, &mm, &alpha, svd_u->data(), &mm, v.val, &one, &null, &work[0], &one); + gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, &work[0], &one); // Multiply by singular values for (unsigned int i=0; idata(), &nn, &work[0], &one, &beta, w.val, &one); + gemv("T", &nn, &nn, &alpha, &svd_vt->values[0], &nn, &work[0], &one, &beta, w.val, &one); break; } default: @@ -170,7 +170,7 @@ LAPACKFullMatrix::Tvmult ( AssertDimension(w.size(), this->n_cols()); AssertDimension(v.size(), this->n_rows()); - gemv("T", &mm, &nn, &alpha, this->data(), &mm, v.val, &one, &beta, w.val, &one); + gemv("T", &mm, &nn, &alpha, &this->values[0], &mm, v.val, &one, &beta, w.val, &one); break; } case svd: @@ -180,12 +180,12 @@ LAPACKFullMatrix::Tvmult ( // Compute U^T v work.resize(std::max(mm,nn)); - gemv("T", &mm, &mm, &alpha, svd_u->data(), &mm, v.val, &one, &null, &work[0], &one); + gemv("T", &mm, &mm, &alpha, &svd_u->values[0], &mm, v.val, &one, &null, &work[0], &one); // Multiply by singular values for (unsigned int i=0; idata(), &nn, &work[0], &one, &beta, w.val, &one); + gemv("T", &nn, &nn, &alpha, &svd_vt->values[0], &nn, &work[0], &one, &beta, w.val, &one); break; case inverse_svd: { @@ -194,12 +194,12 @@ LAPACKFullMatrix::Tvmult ( // Compute V^T v work.resize(std::max(mm,nn)); - gemv("N", &nn, &nn, &alpha, svd_vt->data(), &nn, v.val, &one, &null, &work[0], &one); + gemv("N", &nn, &nn, &alpha, &svd_vt->values[0], &nn, v.val, &one, &null, &work[0], &one); // Multiply by singular values for (unsigned int i=0; idata(), &mm, &work[0], &one, &beta, w.val, &one); + gemv("N", &mm, &mm, &alpha, &svd_u->values[0], &mm, &work[0], &one, &beta, w.val, &one); break; } } @@ -216,7 +216,7 @@ LAPACKFullMatrix::compute_lu_factorization() Assert(state == matrix, ExcState(state)); const int mm = this->n_rows(); const int nn = this->n_cols(); - number *values = const_cast (this->data()); + number *values = const_cast (&this->values[0]); ipiv.resize(mm); int info = 0; getrf(&mm, &nn, values, &mm, &ipiv[0], &info); @@ -237,15 +237,15 @@ LAPACKFullMatrix::compute_svd() const int mm = this->n_rows(); const int nn = this->n_cols(); - number *values = const_cast (this->data()); + number *values = const_cast (&this->values[0]); wr.resize(std::max(mm,nn)); std::fill(wr.begin(), wr.end(), 0.); ipiv.resize(8*mm); svd_u.reset (new LAPACKFullMatrix(mm,mm)); svd_vt.reset (new LAPACKFullMatrix(nn,nn)); - number *mu = const_cast (svd_u->data()); - number *mvt = const_cast (svd_vt->data()); + number *mu = const_cast (&svd_u->values[0]); + number *mvt = const_cast (&svd_vt->values[0]); int info = 0; // see comment on this #if @@ -311,7 +311,7 @@ LAPACKFullMatrix::invert() const int nn = this->n_cols(); Assert (nn == mm, ExcNotQuadratic()); - number *values = const_cast (this->data()); + number *values = const_cast (&this->values[0]); ipiv.resize(mm); int info = 0; @@ -344,7 +344,7 @@ LAPACKFullMatrix::apply_lu_factorization(Vector &v, const char *trans = transposed ? &T : &N; const int nn = this->n_cols(); - const number *values = this->data(); + const number *values = &this->values[0]; int info = 0; getrs(trans, &nn, &one, values, &nn, &ipiv[0], @@ -367,7 +367,7 @@ LAPACKFullMatrix::compute_eigenvalues( if (right) vr.resize(nn*nn); if (left) vl.resize(nn*nn); - number *values = const_cast (this->data()); + number *values = const_cast (&this->values[0]); int info = 0; int lwork = 1; @@ -450,8 +450,8 @@ LAPACKFullMatrix::compute_eigenvalues_symmetric( wr.resize(nn); LAPACKFullMatrix matrix_eigenvectors(nn, nn); - number *values_A = const_cast (this->data()); - number *values_eigenvectors = const_cast (matrix_eigenvectors.data()); + number *values_A = const_cast (&this->values[0]); + number *values_eigenvectors = const_cast (&matrix_eigenvectors.values[0]); int info(0), lwork(1), @@ -562,9 +562,9 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric( wr.resize(nn); LAPACKFullMatrix matrix_eigenvectors(nn, nn); - number *values_A = const_cast (this->data()); - number *values_B = const_cast (B.data()); - number *values_eigenvectors = const_cast (matrix_eigenvectors.data()); + number *values_A = const_cast (&this->values[0]); + number *values_B = const_cast (&B.values[0]); + number *values_eigenvectors = const_cast (&matrix_eigenvectors.values[0]); int info(0), lwork(1), @@ -672,8 +672,8 @@ LAPACKFullMatrix::compute_generalized_eigenvalues_symmetric ( wi.resize(nn); //This is set purley for consistency reasons with the //eigenvalues() function. - number *values_A = const_cast (this->data()); - number *values_B = const_cast (B.data()); + number *values_A = const_cast (&this->values[0]); + number *values_B = const_cast (&B.values[0]); int info = 0; int lwork = 1; -- 2.39.5