Output operator for tensors. Print the elements consecutively, with a space in between, two spaces between rank 1 subtensors, three between rank 2 and so on.
This function unwraps the underlying objects of type Number and OtherNumber that are stored within the Tensor and multiplies them. It returns an unwrapped number of product type.
Multiplication of a tensor of general rank with a scalar number from the right.
Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.
Multiplication of a tensor of general rank with a scalar number from the left.
Only multiplication with a scalar number type (i.e., a floating point number, a complex floating point number, etc.) is allowed, see the documentation of EnableIfScalar for details.
Division of a tensor of general rank with a scalar number. See the discussion on operator*() above for more information about template arguments and the return type.
The dot product (single contraction) for tensors. This function return a tensor of rank that is the contraction of the last index of a tensor src1 of rank rank_1 with the first index of a tensor src2 of rank rank_2:
Note
For the Tensor class, the multiplication operator only performs a contraction over a single pair of indices. This is in contrast to the multiplication operator for SymmetricTensor, for which the corresponding operator*() performs a double contraction. The origin of the difference in how operator*() is implemented between Tensor and SymmetricTensor is that for the former, the product between two Tensor objects of same rank and dimension results in another Tensor object – that it, operator*() corresponds to the multiplicative group action within the group of tensors. On the other hand, there is no corresponding multiplicative group action with the set of symmetric tensors because, in general, the product of two symmetric tensors is a nonsymmetric tensor. As a consequence, for a mathematician, it is clear that operator*() for symmetric tensors must have a different meaning: namely the dot or scalar product that maps two symmetric tensors of rank 2 to a scalar. This corresponds to the double-dot (colon) operator whose meaning is then extended to the product of any two even-ranked symmetric tensors.
In case the contraction yields a tensor of rank 0, that is, if rank_1==rank_2==1, then a scalar number is returned as an unwrapped number type.
Generic contraction of a pair of indices of two tensors of arbitrary rank: Return a tensor of rank that is the contraction of index index_1 of a tensor src1 of rank rank_1 with the index index_2 of a tensor src2 of rank rank_2:
If for example the first index (index_1==0) of a tensor t1 shall be contracted with the third index (index_2==2) of a tensor t2, this function should be invoked as
Generic contraction of two pairs of indices of two tensors of arbitrary rank: Return a tensor of rank that is the contraction of index index_1 with index index_2, and index index_3 with index index_4 of a tensor src1 of rank rank_1 and a tensor src2 of rank rank_2:
If for example the first index (index_1==0) shall be contracted with the third index (index_2==2), and the second index (index_3==1) with the first index (index_4==0) of a tensor t2, this function should be invoked as
The scalar product, or (generalized) Frobenius inner product of two tensors of equal rank: Return a scalar number that is the result of a full contraction of a tensor left and right:
template<template< int, int, typename > class TensorT1, template< int, int, typename > class TensorT2, template< int, int, typename > class TensorT3, int rank_1, int rank_2, int dim, typename T1, typename T2, typename T3>
ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3
(
const TensorT1< rank_1, dim, T1 > &
left,
const TensorT2< rank_1+rank_2, dim, T2 > &
middle,
const TensorT3< rank_2, dim, T3 > &
right )
related
Full contraction of three tensors: Return a scalar number that is the result of a full contraction of a tensor left of rank rank_1, a tensor middle of rank and a tensor right of rank rank_2:
Return the cross product in 2d. This is just a rotation by 90 degrees clockwise to compute the outer normal from a tangential vector. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is two (e.g. from the dim==2 case in the switch).
Return the cross product of 2 vectors in 3d. This function is defined for all space dimensions to allow for dimension independent programming (e.g. within switches over the space dimension), but may only be called if the actual dimension of the arguments is three (e.g. from the dim==3 case in the switch).
Compute and return the inverse of the given tensor. Since the compiler can perform the return value optimization, and since the size of the return object is known, it is acceptable to return the result by value, rather than by reference as a parameter.
Return the nearest orthogonal matrix by combining the products of the singular value decomposition (SVD) for a given input , effectively replacing with the identity matrix.
This is a (nonlinear) projection operation since when applied twice, we have as is easy to see. (That is because the SVD of is simply .) Furthermore, is really an orthogonal matrix because orthogonal matrices have to satisfy , which here implies that
due to the fact that the and factors that come out of the SVD are themselves orthogonal matrices.
Parameters
A
The tensor for which to find the closest orthogonal tensor.
Template Parameters
Number
The type used to store the entries of the tensor. Must be either float or double.
Precondition
In order to use this function, this program must be linked with the LAPACK library.
A must not be singular. This is because, conceptually, the problem to be solved here is trying to find a matrix that minimizes some kind of distance from while satisfying the quadratic constraint . This is not so dissimilar to the kind of problem where one wants to find a vector that minimizes the quadratic objective function for a given subject to the constraint – in other words, we are seeking the point on the unit sphere that is closest to . This problem has a solution for all except if . The corresponding condition for the problem we are considering here is that must not have a zero eigenvalue.