From: Daniel Arndt Date: Wed, 23 May 2018 12:42:30 +0000 (+0200) Subject: Avoid using one-dimensional arrays in place of multi-dimensional ones X-Git-Tag: v9.1.0-rc1~1107^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6654%2Fhead;p=dealii.git Avoid using one-dimensional arrays in place of multi-dimensional ones --- diff --git a/examples/doxygen/block_matrix_array.cc b/examples/doxygen/block_matrix_array.cc index e561c1085d..a374d44bd0 100644 --- a/examples/doxygen/block_matrix_array.cc +++ b/examples/doxygen/block_matrix_array.cc @@ -30,32 +30,32 @@ using namespace dealii; -double Adata[] = +double Adata[4][4] = { - 4., .5, .1, 0., - .5, 4., .5, .1, - .1, .5, 4., .5, - 0., .1, .5, 4. + {4., .5, .1, 0.}, + {.5, 4., .5, .1}, + {.1, .5, 4., .5}, + {0., .1, .5, 4.} }; -double B1data[] = +double B1data[4][2] = { - .5, .1, - .4, .2, - .3, .3, - .2, .4 + {.5, .1}, + {.4, .2}, + {.3, .3}, + {.2, .4} }; -double B2data[] = +double B2data[2][4] = { - .3, 0., -.3, 0., - -.3, 0., .3, 0. + {.3, 0., -.3, 0.}, + {-.3, 0., .3, 0.} }; -double Cdata[] = +double Cdata[2][2] = { - 8., 1., - 1., 8. + {8., 1.}, + {1., 8.} }; int main () @@ -65,10 +65,10 @@ int main () FullMatrix B2(2,4); FullMatrix C(2,2); - A.fill(Adata); - B1.fill(B1data); - B2.fill(B2data); - C.fill(Cdata); + A.fill(&Adata[0][0]); + B1.fill(&B1data[0][0]); + B2.fill(&B2data[0][0]); + C.fill(&Cdata[0][0]); BlockMatrixArray matrix(2, 2); diff --git a/tests/lac/householder.cc b/tests/lac/householder.cc index 25df1c1f87..5ef1aaf6fb 100644 --- a/tests/lac/householder.cc +++ b/tests/lac/householder.cc @@ -22,11 +22,11 @@ #include -const double rect[] = +const double rect[3][4] = { - 4., 3., 2., 1., - 5., 8., 1., -2., - 11., 13., -4., -5 + {4., 3., 2., 1.}, + {5., 8., 1., -2.}, + {11., 13., -4., -5} }; @@ -36,7 +36,7 @@ int main() deallog << std::setprecision(3); deallog.attach(logfile); - FullMatrix A(4,3,rect); + FullMatrix A(4,3,&rect[0][0]); Householder H(A); Vector u(4); diff --git a/tests/lapack/full_matrix_01.cc b/tests/lapack/full_matrix_01.cc index 42a8af0c94..28a89aae48 100644 --- a/tests/lapack/full_matrix_01.cc +++ b/tests/lapack/full_matrix_01.cc @@ -30,19 +30,19 @@ * lambda = 5 v = (0, 1,-1, 0) * lambda = 5 v = (0, 0, 1,-1) */ -const double symm[] = +const double symm[4][4] = { - 4., -1., -1., -1., - -1., 4., -1., -1., - -1., -1., 4., -1., - -1., -1., -1., 4. + {4., -1., -1., -1.}, + {-1., 4., -1., -1.}, + {-1., -1., 4., -1.}, + {-1., -1., -1., 4.} }; -const double rect[] = +const double rect[3][4] = { - 4., 3., 2., 1., - 5., 8., 1., -2., - 11., 13., -4., -5 + {4., 3., 2., 1.}, + {5., 8., 1., -2.}, + {11., 13., -4., -5} }; @@ -100,14 +100,13 @@ int main() logfile.precision(3); deallog.attach(logfile); - test_rect(3,4,rect); - test_rect(4,3,rect); - test_rect(4,4,symm); + test_rect(3,4,&rect[0][0]); + test_rect(4,3,&rect[0][0]); + test_rect(4,4,&symm[0][0]); // Test symmetric system - FullMatrix A(4,4,symm); + FullMatrix A(4,4,&symm[0][0]); LAPACKFullMatrix LA(4,4); - A.fill(symm); LA = A; LA.compute_eigenvalues(); for (unsigned int i=0; i A(4,4,symm); + FullMatrix A(4,4,&symm[0][0]); LAPACKFullMatrix LA(4,4); - A.fill(symm); LA = A; LA.compute_eigenvalues(); for (unsigned int i=0; i #include -const double left[] = +const double left[4][4] = { - 4., -1., -1., -1., - -1., 4., -1., -1., - -1., -1., 4., -1., - -1., -1., -1., 4. + {4., -1., -1., -1.}, + {-1., 4., -1., -1.}, + {-1., -1., 4., -1.}, + {-1., -1., -1., 4.} }; -const double right[] = +const double right[4][4] = { - 4., -1., -1., -1., - -1., 5., -1., -1., - -1., -1., 6., -1., - -1., -1., -1., 7. + {4., -1., -1., -1.}, + {-1., 5., -1., -1.}, + {-1., -1., 6., -1.}, + {-1., -1., -1., 7.} }; @@ -49,8 +49,8 @@ int main() logfile.precision(1); deallog.attach(logfile); - FullMatrix A(4,4,left), - B(4,4,right); + FullMatrix A(4,4,&left[0][0]), + B(4,4,&right[0][0]); LAPACKFullMatrix LA(4,4), LB(4,4); for (unsigned int itype=1; itype<=3; ++itype) diff --git a/tests/lapack/full_matrix_06.cc b/tests/lapack/full_matrix_06.cc index 2b3885732f..5e1de7ea9e 100644 --- a/tests/lapack/full_matrix_06.cc +++ b/tests/lapack/full_matrix_06.cc @@ -25,20 +25,20 @@ #include #include -const double left[] = +const double left[4][4] = { - 4., -1., -1., -1., - -1., 4., -1., -1., - -1., -1., 4., -1., - -1., -1., -1., 4. + {4., -1., -1., -1.}, + {-1., 4., -1., -1.}, + {-1., -1., 4., -1.}, + {-1., -1., -1., 4.} }; -const double right[] = +const double right[4][4] = { - 4., -1., -1., -1., - -1., 5., -1., -1., - -1., -1., 6., -1., - -1., -1., -1., 7. + {4., -1., -1., -1.}, + {-1., 5., -1., -1.}, + {-1., -1., 6., -1.}, + {-1., -1., -1., 7.} }; @@ -50,8 +50,8 @@ int main() logfile.precision(1); deallog.attach(logfile); - FullMatrix A(4,4,left), - B(4,4,right); + FullMatrix A(4,4,&left[0][0]), + B(4,4,&right[0][0]); LAPACKFullMatrix LA(4,4), LB(4,4); for (unsigned int itype=1; itype<=3; ++itype) diff --git a/tests/lapack/full_matrix_07.cc b/tests/lapack/full_matrix_07.cc index ee4f24ca17..37db40fdb9 100644 --- a/tests/lapack/full_matrix_07.cc +++ b/tests/lapack/full_matrix_07.cc @@ -25,13 +25,12 @@ #include #include -const double left[] = +const double left[4][4] = { - - 1.75, -0.433012701892219, 0.0, 0.0, - -0.433012701892219, 1.25, 0.0, 0.0, - 0.0, 0.0, 3.5, -0.5, - 0.0, 0.0, -0.5, 3.5 + {1.75, -0.433012701892219, 0.0, 0.0}, + {-0.433012701892219, 1.25, 0.0, 0.0}, + {0.0, 0.0, 3.5, -0.5}, + {0.0, 0.0, -0.5, 3.5} }; @@ -43,7 +42,7 @@ int main() logfile.precision(1); deallog.attach(logfile); - FullMatrix A(4,4,left); + FullMatrix A(4,4,&left[0][0]); LAPACKFullMatrix LA(4,4); LA = A; FullMatrix eigenvectors; diff --git a/tests/quick_tests/lapack.cc b/tests/quick_tests/lapack.cc index 24403c7c34..2223720985 100644 --- a/tests/quick_tests/lapack.cc +++ b/tests/quick_tests/lapack.cc @@ -33,19 +33,19 @@ * lambda = 5 v = (0, 1,-1, 0) * lambda = 5 v = (0, 0, 1,-1) */ -const double symm[] = +const double symm[4][4] = { - 4., -1., -1., -1., - -1., 4., -1., -1., - -1., -1., 4., -1., - -1., -1., -1., 4. + {4., -1., -1., -1.}, + {-1., 4., -1., -1.}, + {-1., -1., 4., -1.}, + {-1., -1., -1., 4.} }; -const double rect[] = +const double rect[3][4] = { - 4., 3., 2., 1., - 5., 8., 1., -2., - 11., 13., -4., -5 + {4., 3., 2., 1.}, + {5., 8., 1., -2.}, + {11., 13., -4., -5} }; using namespace dealii; @@ -104,14 +104,13 @@ int main() logfile.precision(3); deallog.attach(logfile); - test_rect(3,4,rect); - test_rect(4,3,rect); - test_rect(4,4,symm); + test_rect(3,4,&rect[0][0]); + test_rect(4,3,&rect[0][0]); + test_rect(4,4,&symm[0][0]); // Test symmetric system - FullMatrix A(4,4,symm); + FullMatrix A(4,4,&symm[0][0]); LAPACKFullMatrix LA(4,4); - A.fill(symm); LA = A; LA.compute_eigenvalues(); for (unsigned int i=0; i