}
-
template <int rank_, int dim>
inline
Tensor<rank_,dim> &
}
-
template <int rank_, int dim>
inline
bool
}
-
template <int rank_, int dim>
inline
double Tensor<rank_,dim>::norm () const
}
-
template <int rank_, int dim>
inline
double Tensor<rank_,dim>::norm_square () const
}
-
template <int rank_, int dim>
inline
void Tensor<rank_,dim>::clear ()
}
-
template <int rank_, int dim>
inline
unsigned int
return sizeof(Tensor<rank_,dim>);
}
+
template <int rank_, int dim>
template <class Archive>
inline
}
-
/**
* Multiplication operator performing a contraction of the last index
* of the first argument and the first index of the second
}
-
/**
* Contract a tensor of rank 2 with a tensor of rank 1. The result is
* <tt>dest[i] = sum_j src1[i][j] src2[j]</tt>.
}
-
/**
* Multiplication operator performing a contraction of the last index
* of the first argument and the first index of the second
}
-
/**
* Contract a tensor of rank 1 with a tensor of rank 2. The result is
* <tt>dest[i] = sum_j src1[j] src2[j][i]</tt>.
}
-
/**
* Multiplication operator performing a contraction of the last index
* of the first argument and the first index of the second
}
-
/**
* Contract a tensor of rank 2 with a tensor of rank 2. The result is
* <tt>dest[i][k] = sum_j src1[i][j] src2[j][k]</tt>.
}
-
/**
* Multiplication operator performing a contraction of the last index
* of the first argument and the first index of the second
}
-
/**
* Contract a tensor of rank 2 with a tensor of rank 2. The
* contraction is performed over index <tt>index1</tt> of the first tensor,
}
-
/**
* Contract a tensor of rank 3 with a tensor of rank 1. The
* contraction is performed over index <tt>index1</tt> of the first
}
-
/**
* Contract a tensor of rank 3 with a tensor of rank 2. The result is
* <tt>dest[i][j][l] = sum_k src1[i][j][k] src2[k][l]</tt>.
}
-
/**
* Contract a tensor of rank 3 with a tensor of rank 2. The
* contraction is performed over index <tt>index1</tt> of the first tensor,
}
}
-
/**
* Multiplication operator performing a contraction of the last index
}
-
/**
* Contract a tensor of rank 2 with a tensor of rank 3. The result is
* <tt>dest[i][j][l] = sum_k src1[i][k] src2[k][j][l]</tt>.
}
-
/**
* Multiplication operator performing a contraction of the last index
* of the first argument and the first index of the second
}
-
/**
* Contract three tensors, corresponding to the matrix vector product
* <i>u<sup>T</sup> A v</i>.
/**
- * Compute the contraction of three tensors $s=\sum_{i,j,k,l}
- * a_{ij}b_{ijkl}c_{kl}$.
+ * Compute the contraction of three tensors $s=\sum_{i,j,k}
+ * a_{i}b_{ijk}c_{jk}$.
*
* @relates Tensor
+ * @author Toby D. Young, 2011
*/
template <int dim>
inline
double
-contract3 (const Tensor<2,dim> &t1,
- const Tensor<4,dim> &t2,
+contract3 (const Tensor<1,dim> &t1,
+ const Tensor<3,dim> &t2,
const Tensor<2,dim> &t3)
{
double s = 0;
for (unsigned int i=0; i<dim; ++i)
for (unsigned int j=0; j<dim; ++j)
for (unsigned int k=0; k<dim; ++k)
- for (unsigned int l=0; l<dim; ++l)
- s += t1[i][j] * t2[i][j][k][l] * t3[k][l];
+ s += t1[i] * t2[i][j][k] * t3[j][k];
return s;
}
/**
- * Compute the contraction of three tensors $s=\sum_{i,j,k,l}
- * a_{i}b_{ijk}c_{kl}$.
+ * Compute the contraction of three tensors $s=\sum_{i,j,k}
+ * a_{ij}b_{ijk}c_{k}$.
*
* @relates Tensor
+ * @author Toby D. Young, 2011
*/
template <int dim>
inline
double
-contract3 (const Tensor<1,dim> &t1,
+contract3 (const Tensor<2,dim> &t1,
const Tensor<3,dim> &t2,
+ const Tensor<1,dim> &t3)
+{
+ double s = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ for (unsigned int k=0; k<dim; ++k)
+ s += t1[i][j] * t2[i][j][k] * t3[k];
+ return s;
+}
+
+
+/**
+ * Compute the contraction of three tensors $s=\sum_{i,j,k,l}
+ * a_{ij}b_{ijkl}c_{kl}$.
+ *
+ * @relates Tensor
+ * @author Toby D. Young, 2011
+ */
+template <int dim>
+inline
+double
+contract3 (const Tensor<2,dim> &t1,
+ const Tensor<4,dim> &t2,
const Tensor<2,dim> &t3)
{
double s = 0;
for (unsigned int j=0; j<dim; ++j)
for (unsigned int k=0; k<dim; ++k)
for (unsigned int l=0; l<dim; ++l)
- s += t1[i] * t2[i][j][k] * t3[k][l];
+ s += t1[i][j] * t2[i][j][k][l] * t3[k][l];
return s;
}
}
-
/**
* Form the outer product of two tensors of rank 1 and 2, i.e.
* <tt>dst[i][j][k] = src1[i] * src2[j][k]</tt>.
}
-
/**
* Form the outer product of two tensors of rank 2 and 1, i.e.
* <tt>dst[i][j][k] = src1[i][j] * src2[k]</tt>.
}
-
/**
* Form the outer product of two tensors of rank 0 and 1, i.e.
* <tt>dst[i] = src1 * src2[i]</tt>. Of course, this is only a scaling of
}
-
/**
* Cross-product in 2d. This is just a rotation by 90 degrees
* clockwise to compute the outer normal from a tangential
}
-
/**
* Cross-product of 2 vectors in 3d. This function is defined for all
* space dimensions to allow for dimension independent programming
}
-
/**
* Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
* tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
}
-
/**
* Compute the determinant of a tensor of rank two and dimension
* one. Since this is a number, the return value is, of course, the
}
-
-
/**
* Compute the determinant of a tensor or rank 2, here for <tt>dim==3</tt>.
*
}
-
/**
* Compute the determinant of a tensor or rank 2, here for all dimensions for
* which no explicit specialization is available above.