]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Avoid use of the deprecated Table::data() function by making use of the fact that...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Dec 2012 21:45:52 +0000 (21:45 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Dec 2012 21:45:52 +0000 (21:45 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_deprecated@27886 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/full_matrix.templates.h
deal.II/source/lac/lapack_full_matrix.cc

index e4a7099bffa1cb2a204b282c031a21ca3ec2fab2..d7adfc766f90ff7d9e9bb49052119f23b098bf68 100644 (file)
@@ -130,8 +130,8 @@ FullMatrix<number>::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<number>::vmult (Vector<number2> &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<number>::Tvmult (Vector<number2>       &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<number>::fill_permutation (const FullMatrix<number2> &src,
 /*  void FullMatrix<number>::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<number>::matrix_norm_square (const Vector<number2> &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<n_rows; ++row)
@@ -981,7 +981,7 @@ FullMatrix<number>::matrix_scalar_product (const Vector<number2> &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<n_rows; ++row)
@@ -1276,7 +1276,7 @@ FullMatrix<number>::frobenius_norm () const
 
   real_type s = 0.;
   for (unsigned int i=0; i<this->n_rows()*this->n_cols(); ++i)
-    s += numbers::NumberTraits<number>::abs_square(this->data()[i]);
+    s += numbers::NumberTraits<number>::abs_square(this->values[i]);
   return std::sqrt(s);
 }
 
index 2cbcc23c671d07d15c77cfd043d404d27cb7a0a8..5582ef2b5a83c2e4b062c781f954e7b44ce0e90b 100644 (file)
@@ -112,7 +112,7 @@ LAPACKFullMatrix<number>::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<number>::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; i<wr.size(); ++i)
         work[i] *= wr[i];
       // Multiply with U
-      gemv("N", &mm, &mm, &alpha, svd_u->data(), &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<number>::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; i<wr.size(); ++i)
         work[i] *= wr[i];
       // Multiply with V
-      gemv("T", &nn, &nn, &alpha, svd_vt->data(), &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<number>::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<number>::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; i<wr.size(); ++i)
         work[i] *= wr[i];
       // Multiply with V
-      gemv("T", &nn, &nn, &alpha, svd_vt->data(), &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<number>::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; i<wr.size(); ++i)
           work[i] *= wr[i];
         // Multiply with U
-        gemv("N", &mm, &mm, &alpha, svd_u->data(), &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<number>::compute_lu_factorization()
   Assert(state == matrix, ExcState(state));
   const int mm = this->n_rows();
   const int nn = this->n_cols();
-  number *values = const_cast<number *> (this->data());
+  number *values = const_cast<number *> (&this->values[0]);
   ipiv.resize(mm);
   int info = 0;
   getrf(&mm, &nn, values, &mm, &ipiv[0], &info);
@@ -237,15 +237,15 @@ LAPACKFullMatrix<number>::compute_svd()
 
   const int mm = this->n_rows();
   const int nn = this->n_cols();
-  number *values = const_cast<number *> (this->data());
+  number *values = const_cast<number *> (&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<number>(mm,mm));
   svd_vt.reset (new LAPACKFullMatrix<number>(nn,nn));
-  number *mu  = const_cast<number *> (svd_u->data());
-  number *mvt = const_cast<number *> (svd_vt->data());
+  number *mu  = const_cast<number *> (&svd_u->values[0]);
+  number *mvt = const_cast<number *> (&svd_vt->values[0]);
   int info = 0;
 
   // see comment on this #if
@@ -311,7 +311,7 @@ LAPACKFullMatrix<number>::invert()
   const int nn = this->n_cols();
   Assert (nn == mm, ExcNotQuadratic());
 
-  number *values = const_cast<number *> (this->data());
+  number *values = const_cast<number *> (&this->values[0]);
   ipiv.resize(mm);
   int info = 0;
 
@@ -344,7 +344,7 @@ LAPACKFullMatrix<number>::apply_lu_factorization(Vector<number> &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<number>::compute_eigenvalues(
   if (right) vr.resize(nn*nn);
   if (left)  vl.resize(nn*nn);
 
-  number *values = const_cast<number *> (this->data());
+  number *values = const_cast<number *> (&this->values[0]);
 
   int info  = 0;
   int lwork = 1;
@@ -450,8 +450,8 @@ LAPACKFullMatrix<number>::compute_eigenvalues_symmetric(
   wr.resize(nn);
   LAPACKFullMatrix<number> matrix_eigenvectors(nn, nn);
 
-  number *values_A = const_cast<number *> (this->data());
-  number *values_eigenvectors = const_cast<number *> (matrix_eigenvectors.data());
+  number *values_A = const_cast<number *> (&this->values[0]);
+  number *values_eigenvectors = const_cast<number *> (&matrix_eigenvectors.values[0]);
 
   int info(0),
       lwork(1),
@@ -562,9 +562,9 @@ LAPACKFullMatrix<number>::compute_generalized_eigenvalues_symmetric(
   wr.resize(nn);
   LAPACKFullMatrix<number> matrix_eigenvectors(nn, nn);
 
-  number *values_A = const_cast<number *> (this->data());
-  number *values_B = const_cast<number *> (B.data());
-  number *values_eigenvectors = const_cast<number *> (matrix_eigenvectors.data());
+  number *values_A = const_cast<number *> (&this->values[0]);
+  number *values_B = const_cast<number *> (&B.values[0]);
+  number *values_eigenvectors = const_cast<number *> (&matrix_eigenvectors.values[0]);
 
   int info(0),
       lwork(1),
@@ -672,8 +672,8 @@ LAPACKFullMatrix<number>::compute_generalized_eigenvalues_symmetric (
   wi.resize(nn); //This is set purley for consistency reasons with the
   //eigenvalues() function.
 
-  number *values_A = const_cast<number *> (this->data());
-  number *values_B = const_cast<number *> (B.data());
+  number *values_A = const_cast<number *> (&this->values[0]);
+  number *values_B = const_cast<number *> (&B.values[0]);
 
   int info  = 0;
   int lwork = 1;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.