[cig-commits] commit: Add T3ch(i,N0,N1) and tests
Mercurial
hg at geodynamics.org
Sat Mar 10 15:07:07 PST 2012
changeset: 9:184dc3738c80
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Sat Mar 10 15:06:24 2012 -0800
files: Tensor3_christof/Tensor3_christof_value.hpp tests/conformance/test_T3ch.cpp
description:
Add T3ch(i,N0,N1) and tests
diff -r af762f2efe25 -r 184dc3738c80 Tensor3_christof/Tensor3_christof_value.hpp
--- a/Tensor3_christof/Tensor3_christof_value.hpp Fri Mar 09 11:11:37 2012 -0800
+++ b/Tensor3_christof/Tensor3_christof_value.hpp Sat Mar 10 15:06:24 2012 -0800
@@ -104,6 +104,39 @@ public:
{
return Tensor3_dg_Expr<const Tensor3_christof<T,Tensor_Dim0,Tensor_Dim12>,
T,Dim12,Dim0,i,j,k>(*this);
+ }
+
+ /* This is for expressions where a number is used for two slots, and
+ an Index for the other, yielding a Tensor1_Expr. The non-const
+ versions don't actually create a Tensor3_dg_number_rhs_* object,
+ while the const versions do create a Tensor3_dg_number_*. */
+
+ /* Index in first slot. */
+
+ template<char i, int N1, int N2, int Dim>
+ Tensor1_Expr<Tensor3_dg_number_rhs_12<Tensor3_christof<T,Tensor_Dim0,
+ Tensor_Dim12>,
+ T,N1,N2>,T,Dim,i>
+ operator()(const Index<i,Dim> index, const Number<N1> n1,
+ const Number<N2> n2)
+ {
+ typedef Tensor3_dg_number_rhs_12<Tensor3_christof<T,Tensor_Dim0,
+ Tensor_Dim12>,
+ T,N1,N2> TensorExpr;
+ return Tensor1_Expr<TensorExpr,T,Dim,i>(*this);
+ }
+
+ template<char i, int N1, int N2, int Dim>
+ const Tensor1_Expr<const Tensor3_dg_number_12<const Tensor3_christof
+ <T,Tensor_Dim0,Tensor_Dim12>,
+ T,N1,N2>,T,Dim,i>
+ operator()(const Index<i,Dim> index, const Number<N1> n1,
+ const Number<N2> n2) const
+ {
+ typedef const Tensor3_dg_number_12<const Tensor3_christof
+ <T,Tensor_Dim0,Tensor_Dim12>,
+ T,N1,N2> TensorExpr;
+ return Tensor1_Expr<TensorExpr,T,Dim,i>(TensorExpr(*this));
}
/* These operators are for internal contractions. Some of them are
diff -r af762f2efe25 -r 184dc3738c80 tests/conformance/test_T3ch.cpp
--- a/tests/conformance/test_T3ch.cpp Fri Mar 09 11:11:37 2012 -0800
+++ b/tests/conformance/test_T3ch.cpp Sat Mar 10 15:06:24 2012 -0800
@@ -30,6 +30,8 @@ void test_T3ch(const int &T, Tensor0<dou
Number<2> N2;
/* Tensor3_ch tests */
+
+ /* Number in one slot */
t2s_1(i,j)=t3ch_1(N0,i,j);
test_for_zero(t3ch_1(0,0,0)-t2s_1(0,0)
@@ -70,6 +72,72 @@ void test_T3ch(const int &T, Tensor0<dou
,"T3ch(N,i,j)(2,1,2)");
test_for_zero(t3ch_1(2,2,2)-t2s_1(2,2)
,"T3ch(N,i,j)(2,2,2)");
+
+ /* Number in two slots */
+
+ t1_1(i)=t3ch_1(i,N0,N0);
+ test_for_zero(t3ch_1(0,0,0)-t1_1(0)
+ ,"T3ch(i,N,N)(0,0,0)");
+ test_for_zero(t3ch_1(1,0,0)-t1_1(1)
+ ,"T3ch(i,N,N)(0,0,0)");
+ test_for_zero(t3ch_1(2,0,0)-t1_1(2)
+ ,"T3ch(i,N,N)(2,0,0)");
+ t1_1(i)=t3ch_1(i,N0,N1);
+ test_for_zero(t3ch_1(0,0,1)-t1_1(0)
+ ,"T3ch(i,N,N)(0,0,1)");
+ test_for_zero(t3ch_1(1,0,1)-t1_1(1)
+ ,"T3ch(i,N,N)(0,0,1)");
+ test_for_zero(t3ch_1(2,0,1)-t1_1(2)
+ ,"T3ch(i,N,N)(2,0,1)");
+ t1_1(i)=t3ch_1(i,N0,N2);
+ test_for_zero(t3ch_1(0,0,2)-t1_1(0)
+ ,"T3ch(i,N,N)(0,0,2)");
+ test_for_zero(t3ch_1(1,0,2)-t1_1(1)
+ ,"T3ch(i,N,N)(0,0,2)");
+ test_for_zero(t3ch_1(2,0,2)-t1_1(2)
+ ,"T3ch(i,N,N)(2,0,2)");
+ t1_1(i)=t3ch_1(i,N1,N0);
+ test_for_zero(t3ch_1(0,1,0)-t1_1(0)
+ ,"T3ch(i,N,N)(0,1,0)");
+ test_for_zero(t3ch_1(1,1,0)-t1_1(1)
+ ,"T3ch(i,N,N)(0,1,0)");
+ test_for_zero(t3ch_1(2,1,0)-t1_1(2)
+ ,"T3ch(i,N,N)(2,1,0)");
+ t1_1(i)=t3ch_1(i,N1,N1);
+ test_for_zero(t3ch_1(0,1,1)-t1_1(0)
+ ,"T3ch(i,N,N)(0,1,1)");
+ test_for_zero(t3ch_1(1,1,1)-t1_1(1)
+ ,"T3ch(i,N,N)(0,1,1)");
+ test_for_zero(t3ch_1(2,1,1)-t1_1(2)
+ ,"T3ch(i,N,N)(2,1,1)");
+ t1_1(i)=t3ch_1(i,N1,N2);
+ test_for_zero(t3ch_1(0,1,2)-t1_1(0)
+ ,"T3ch(i,N,N)(0,1,2)");
+ test_for_zero(t3ch_1(1,1,2)-t1_1(1)
+ ,"T3ch(i,N,N)(0,1,2)");
+ test_for_zero(t3ch_1(2,1,2)-t1_1(2)
+ ,"T3ch(i,N,N)(2,1,2)");
+ t1_1(i)=t3ch_1(i,N2,N0);
+ test_for_zero(t3ch_1(0,2,0)-t1_1(0)
+ ,"T3ch(i,N,N)(0,2,0)");
+ test_for_zero(t3ch_1(1,2,0)-t1_1(1)
+ ,"T3ch(i,N,N)(0,2,0)");
+ test_for_zero(t3ch_1(2,2,0)-t1_1(2)
+ ,"T3ch(i,N,N)(2,2,0)");
+ t1_1(i)=t3ch_1(i,N2,N1);
+ test_for_zero(t3ch_1(0,2,1)-t1_1(0)
+ ,"T3ch(i,N,N)(0,2,1)");
+ test_for_zero(t3ch_1(1,2,1)-t1_1(1)
+ ,"T3ch(i,N,N)(0,2,1)");
+ test_for_zero(t3ch_1(2,2,1)-t1_1(2)
+ ,"T3ch(i,N,N)(2,2,1)");
+ t1_1(i)=t3ch_1(i,N2,N2);
+ test_for_zero(t3ch_1(0,2,2)-t1_1(0)
+ ,"T3ch(i,N,N)(0,2,2)");
+ test_for_zero(t3ch_1(1,2,2)-t1_1(1)
+ ,"T3ch(i,N,N)(0,2,2)");
+ test_for_zero(t3ch_1(2,2,2)-t1_1(2)
+ ,"T3ch(i,N,N)(2,2,2)");
/* Now, test with actual numbers. */
More information about the CIG-COMMITS
mailing list