From: Wolfgang Bangerth Date: Fri, 10 Jul 1998 16:39:41 +0000 (+0000) Subject: More performance tweaks. X-Git-Tag: v8.0.0~22813 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34704cc0067c145c1862c92a2d9730dd6d8046d1;p=dealii.git More performance tweaks. git-svn-id: https://svn.dealii.org/trunk@441 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/dfmatrix.cc b/deal.II/lac/source/dfmatrix.cc index def3ec4c2c..2f50134288 100644 --- a/deal.II/lac/source/dfmatrix.cc +++ b/deal.II/lac/source/dfmatrix.cc @@ -126,9 +126,9 @@ void dFMatrix::vmult (dVector& dst, const dVector& src, { double s0,s1,s2,s3; s = src(0); - s0 = s*val[0]; s1 = s*val[4]; s2 = s*val[8]; s3 = s*val[12]; + s0 = s*val[0]; s1 = s*val[4]; s2 = s*val[8]; s3 = s*val[12]; s = src(1); - s0 += s*val[1]; s1 += s*val[5]; s2 += s*val[9]; s3 += s*val[13]; + s0 += s*val[1]; s1 += s*val[5]; s2 += s*val[9]; s3 += s*val[13]; s = src(2); s0 += s*val[2]; s1 += s*val[6]; s2 += s*val[10]; s3 += s*val[14]; s = src(3); @@ -367,7 +367,7 @@ void dFMatrix::Tvmult (dVector& dst, const dVector& src, const bool adding) cons } double dFMatrix::residual (dVector& dst, const dVector& src, - const dVector& right) const + const dVector& right) const { Assert(dst.size() == m(), ExcDimensionMismatch(dst.size(), m())); Assert(src.size() == n(), ExcDimensionMismatch(src.size(), n())); diff --git a/deal.II/lac/source/dsmatrix.cc b/deal.II/lac/source/dsmatrix.cc index e1c2da1bff..51097ecf5e 100644 --- a/deal.II/lac/source/dsmatrix.cc +++ b/deal.II/lac/source/dsmatrix.cc @@ -447,9 +447,13 @@ dSMatrix::copy_from (const dSMatrix &matrix) { Assert (val != 0, ExcMatrixNotInitialized()); Assert (cols == matrix.cols, ExcDifferentSparsityPatterns()); - for (unsigned int i = 0 ; ivec_len; ++i) - val[i] = matrix.val[i]; + double *val_ptr = &val[0]; + const double *matrix_ptr = &matrix.val[0]; + const double *const end_ptr = &val[cols->vec_len]; + while (val_ptr != end_ptr) + *val_ptr++ = *matrix_ptr++; + return *this; }; @@ -461,8 +465,12 @@ dSMatrix::add_scaled (const double factor, const dSMatrix &matrix) { Assert (val != 0, ExcMatrixNotInitialized()); Assert (cols == matrix.cols, ExcDifferentSparsityPatterns()); - for (unsigned int i = 0 ; ivec_len; ++i) - val[i] += factor*matrix.val[i]; + double *val_ptr = &val[0]; + const double *matrix_ptr = &matrix.val[0]; + const double *const end_ptr = &val[cols->vec_len]; + + while (val_ptr != end_ptr) + *val_ptr++ += factor * *matrix_ptr++; }; @@ -478,15 +486,16 @@ dSMatrix::vmult (dVector& dst, const dVector& src) const const unsigned int n_rows = m(); const double *val_ptr = &val[cols->rowstart[0]]; const int *colnum_ptr = &cols->colnums[cols->rowstart[0]]; + double *dst_ptr = &dst(0); for (unsigned int row=0; rowrowstart[row+1]]; + const double *const val_end_of_row = &val[cols->rowstart[row+1]]; while (val_ptr != val_end_of_row) s += *val_ptr++ * src(*colnum_ptr++); - dst(row) = s; - } -} + *dst_ptr++ = s; + }; +}; void @@ -530,11 +539,11 @@ dSMatrix::matrix_norm (const dVector& v) const while (val_ptr != val_end_of_row) s += *val_ptr++ * v(*colnum_ptr++); - sum += s*v(row); + sum += s* v(row); }; return sum; -} +};