--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2006 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// check generic contract variants tha allow to specifiy the indices which
+// will be contracted.
+
+#include "../tests.h"
+#include <deal.II/base/tensor.h>
+
+int main ()
+{
+ initlog();
+
+ Tensor<1, 3, int> rank1;
+ rank1[0] = 1;
+ rank1[1] = 2;
+ rank1[2] = 4;
+
+ Tensor<2, 3, int> rank2;
+ rank2[0] = 4 * rank1;
+ rank2[1] = 2 * rank1;
+ rank2[2] = 1 * rank1;
+
+ Tensor<3, 3, int> rank3;
+ rank3[0] = 7 * rank2;
+ rank3[1] = 6 * rank2;
+ rank3[2] = 9 * rank2;
+
+ Tensor<4, 3, int> rank4;
+ rank4[0] = 4 * rank3;
+ rank4[1] = 3 * rank3;
+ rank4[2] = 2 * rank3;
+
+
+ // rank3 * rank1 over all possible indices:
+ {
+ Tensor<2, 3, int> result;
+
+ deallog << contract<0, 0>(rank3, rank1) << std::endl;
+ contract(result, rank3, 1, rank1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<1, 0>(rank3, rank1) << std::endl;
+ contract(result, rank3, 2, rank1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<2, 0>(rank3, rank1) << std::endl;
+ contract(result, rank3, 3, rank1);
+ deallog << result << std::endl << std::endl;
+ }
+
+
+ // rank2 * rank2 over all possible indices:
+ {
+ Tensor<2, 3, int> result;
+
+ deallog << contract<0, 0>(rank2, rank2) << std::endl;
+ contract(result, rank2, 1, rank2, 1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<1, 0>(rank2, rank2) << std::endl;
+ contract(result, rank2, 2, rank2, 1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<0, 1>(rank2, rank2) << std::endl;
+ contract(result, rank2, 1, rank2, 2);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<1, 1>(rank2, rank2) << std::endl;
+ contract(result, rank2, 2, rank2, 2);
+ deallog << result << std::endl << std::endl;
+ }
+
+
+ // rank3 * rank2 over all possible indices:
+ {
+ Tensor<3, 3, int> result;
+
+ deallog << contract<0, 0>(rank3, rank2) << std::endl;
+ contract(result, rank3, 1, rank2, 1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<1, 0>(rank3, rank2) << std::endl;
+ contract(result, rank3, 2, rank2, 1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<2, 0>(rank3, rank2) << std::endl;
+ contract(result, rank3, 3, rank2, 1);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<0, 1>(rank3, rank2) << std::endl;
+ contract(result, rank3, 1, rank2, 2);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<1, 1>(rank3, rank2) << std::endl;
+ contract(result, rank3, 2, rank2, 2);
+ deallog << result << std::endl << std::endl;
+
+ deallog << contract<2, 1>(rank3, rank2) << std::endl;
+ contract(result, rank3, 3, rank2, 2);
+ deallog << result << std::endl << std::endl;
+ }
+
+
+ // rank4 ** rank2, double contraction:
+ {
+ Tensor<2, 3, int> result;
+
+ deallog << contract<2, 0, 3, 1>(rank4, rank2) << std::endl;
+ deallog << contract<3, 1, 2, 0>(rank4, rank2) << std::endl;
+ deallog << contract<0, 2, 1, 3>(rank2, rank4) << std::endl;
+ deallog << contract<1, 3, 0, 2>(rank2, rank4) << std::endl;
+
+ double_contract(result, rank4, rank2);
+ deallog << result << std::endl << std::endl;
+ }
+}
--- /dev/null
+
+DEAL::220 440 880 110 220 440 55 110 220
+DEAL::220 440 880 110 220 440 55 110 220
+DEAL::
+DEAL::84 168 336 72 144 288 108 216 432
+DEAL::84 168 336 72 144 288 108 216 432
+DEAL::
+DEAL::588 294 147 504 252 126 756 378 189
+DEAL::588 294 147 504 252 126 756 378 189
+DEAL::
+DEAL::21 42 84 42 84 168 84 168 336
+DEAL::21 42 84 42 84 168 84 168 336
+DEAL::
+DEAL::48 96 192 24 48 96 12 24 48
+DEAL::48 96 192 24 48 96 12 24 48
+DEAL::
+DEAL::48 24 12 96 48 24 192 96 48
+DEAL::48 24 12 96 48 24 192 96 48
+DEAL::
+DEAL::336 168 84 168 84 42 84 42 21
+DEAL::336 168 84 168 84 42 84 42 21
+DEAL::
+DEAL::196 392 784 392 784 1568 784 1568 3136 98 196 392 196 392 784 392 784 1568 49 98 196 98 196 392 196 392 784
+DEAL::196 392 784 392 784 1568 784 1568 3136 98 196 392 196 392 784 392 784 1568 49 98 196 98 196 392 196 392 784
+DEAL::
+DEAL::147 294 588 294 588 1176 588 1176 2352 126 252 504 252 504 1008 504 1008 2016 189 378 756 378 756 1512 756 1512 3024
+DEAL::147 294 588 294 588 1176 588 1176 2352 126 252 504 252 504 1008 504 1008 2016 189 378 756 378 756 1512 756 1512 3024
+DEAL::
+DEAL::336 672 1344 168 336 672 84 168 336 288 576 1152 144 288 576 72 144 288 432 864 1728 216 432 864 108 216 432
+DEAL::336 672 1344 168 336 672 84 168 336 288 576 1152 144 288 576 72 144 288 432 864 1728 216 432 864 108 216 432
+DEAL::
+DEAL::880 440 220 1760 880 440 3520 1760 880 440 220 110 880 440 220 1760 880 440 220 110 55 440 220 110 880 440 220
+DEAL::880 440 220 1760 880 440 3520 1760 880 440 220 110 880 440 220 1760 880 440 220 110 55 440 220 110 880 440 220
+DEAL::
+DEAL::336 168 84 672 336 168 1344 672 336 288 144 72 576 288 144 1152 576 288 432 216 108 864 432 216 1728 864 432
+DEAL::336 168 84 672 336 168 1344 672 336 288 144 72 576 288 144 1152 576 288 432 216 108 864 432 216 1728 864 432
+DEAL::
+DEAL::2352 1176 588 1176 588 294 588 294 147 2016 1008 504 1008 504 252 504 252 126 3024 1512 756 1512 756 378 756 378 189
+DEAL::2352 1176 588 1176 588 294 588 294 147 2016 1008 504 1008 504 252 504 252 126 3024 1512 756 1512 756 378 756 378 189
+DEAL::
+DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938
+DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938
+DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938
+DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938
+DEAL::12348 10584 15876 9261 7938 11907 6174 5292 7938
+DEAL::