# Tag Info

9

FTensor is a lightweight, header only, fully templated library that includes ergonomic summation notation. It has been tested extensively in 2, 3, and 4 dimensions, but should work fine for any number of dimensions.

9

The equation is not correct as stated, but needs to be interpreted in the variational sense when multiplied by a test function. To this end, consider the operator $$L(\phi) = |\nabla \phi|^2.$$ Here, $\phi=\phi(x)$ is a function. Now, imagine what its derivative would be. Derivatives of operators are most commonly considered in certain directions $v(x)$. ...

8

There are two main ways to write stress/strain tensors as 6 components vectors: Voigt notation, that is the most common; and Mandel-Kelvin notation, that has the advantage of writing stress and strains in the same way, so their rotations are done via the same $6\times 6$ matrices. A reference that I consider good for Voigt's notation is Auld's book (Vol. ...

7

Nick Alger gives a nice explanation. Here is another one, possibly slightly simpler because it avoids the "should stay roughly the same" part. Let's say you want to compute the derivative of any matrix function $X=X(C)$ with regard to entry $C_{ij}$: $$\frac{\partial X}{\partial C_{ij}}.$$ In other words, you ask how the matrix $X$ changes as you change ...

6

For what its worth, Eigen does have a Tensor class as an unsupported module. http://eigen.tuxfamily.org/dox-devel/unsupported/group_CXX11_Tensor__Module.html I haven't used it myself so can't say more about it. The Armadillo class library has a 3rd-order tensor class. http://arma.sourceforge.net/ I haven't used the tensor capabilities of Armadillo ...

6

In Matlab you can do these operations in a vectorized way using the commands reshape, shiftdim, and permute. The essential idea is that contraction of a tensor with a vector is equivalent to matrix multiplication of that vector with an unfolded version of the tensor. For the first example in the question, the command is: a = z*reshape(y*reshape(shiftdim(T,1)...

6

XTensor is a modern approach and is getting more and more popular. https://github.com/QuantStack/xtensor

6

I think this new taco lib is really good too. The Tensor Algebra Compiler (taco) is a C++ library that computes tensor algebra expressions on sparse and dense tensors. It uses novel compiler techniques to get performance competitive with hand-optimized kernels in widely used libraries for both sparse tensor algebra and sparse linear algebra. You can use ...

5

The deal.II library (http://www.dealii.org), while written for much larger purposes, also has a sub-library of tensor classes that likely does a lot of what you want to do. In particular, it uses templates for the dimension. (Disclaimer: I am one of the principal authors of this library.)

5

The program VisIt can do plots of tensor ellipsoids, but I don't think it has anything for hyperstreamlines. While it does make nice plots, I've found VisIt hard to install, if not impossible on some platforms; I know people who have been desperate enough to set up a virtual machine for it, but I haven't done that myself. When it does work, I have found it ...

4

I think you should look at Tammy Kolda's "Tensor Toolbox" for matlab. It has many of the kind of operations you are looking for implemented in efficient ways.

4

I did a little test with the Tensor package in Eigen C++ (release candidate 1 of version 3.3) http://eigen.tuxfamily.org/index.php?title=Main_Page The path to the Tensor include file shows this package as "unsupported" and, presumably, this will still be the case in version 3.3. I do know that this package is rapidly reaching the "supported" stage. For more ...

4

Kolda (one of the authors of the MATLAB Tensor Toolbox) also wrote a review paper in SIREV called Tensor Decompositions and Applications that provides references for algorithms that are at least related. (Without looking at the source, I can't say if they're the same.) You could try looking at Section 4, particularly Section 4.3, for useful references.

2

The library Boost.Numeric.uBlas recently added a tensor extension which is shipped with Boost version 1.70. Please have a look at https://github.com/boostorg/ublas. It provides standard matrix and tensor operations with runtime-variable order (number of dimensions), dimensions for the first- and last-order storage formats (column- and row-major). You can ...

2

Besides fixing the second invariant, you need to know that repeated indicies imply summation. So $A_{ii}=\sum_{k=1}^d [A]_{kk}$. This is known as the Einstein Summation Convention. Each of the second-order statistics is a rank 3 tensor that you can sum up at each point of your domain using this convention in order to compute the invariants at those locations....

2

First, an important distinction must be done. A Tucker decomposition of a third-order tensor $\mathcal{T}$ is any decomposition of the form $$\mathcal{T} = \mathcal{G} \times_1 \mathbf{A} \times_2 \mathbf{B} \times_3 \mathbf{C},$$ where $\mathcal{G}$ is also a third-order tensor called core and $\mathbf{A}$, $\mathbf{B}$ and $\mathbf{C}$ are the matrix ...

2

We know that $$C C^{-1} = I$$ If we perturb C a little bit, by a matrix $X$, and recompute the inverse, the result should stay roughly the same. In symbols: $$(C + X) \left(C^{-1} + \underbrace{\frac{\partial C^{-1}}{\partial C}\cdot X}_{\text{matrix}}\right) \approx I,$$ where "$\frac{\partial C^{-1}}{\partial C}\cdot X$" is the first order correction to $C^... 2 I would suggest Paraview, that is similar to VisIt, since both are based on VTK. You can use Python Calculator and scripts (both based on Python), and are described in the manual. You can also directly use VTK that has a Python interface. It already has implemented hyperstreamlines and the other algorithms can be implemented as simple scripts. 2$\def\p{\partial_{p}}The linked paper has not been peer-reviewed and the result is clearly wrong. Expanding the expression in index notation yields \eqalign{ {\cal H} &= \nabla(A\cdot B) \\ {\cal H}_{pik} &= \p(A_{ij}B_{jk}) \\ &= (\p A_{ij})B_{jk} + A_{ij}(\p B_{jk}) \\ &= (\p A_{ij})B_{jk} + (\p B_{kj}^T)A_{ji}^T \\ {\cal H} &= (\... 2 If you are familiar with einsum, maybe this explanation does it: axes[0] and axes[1] specify the locations of the repeated letters in the parameters of einsum. For instance, np.tensordot(a, b, axes=[(0,2),(3,1)]) corresponds to np.einsum('ijkl,mkni', a, b) Indeed, 'ijkl'[(0,2)] == 'ik' == 'mkni'[(3,1)], and all the other letters are distinct. 2 This is going to be an IO-bound operation, so there is little practical advantage in looking for alternative formulations. There are two things you can do to speed that up: choose the order of indices and for loops to make sure that memory accesses are as contiguous as possible. In your case (assuming Fortran-style memory layout, which should be what Python ... 2 See the list at Wikipedia and answers to Fast, lightweight C++ tensor library for dimension-agnostic code. Especially taco seems to fit your needs. 1 For anyone interested in this problem, I found the following solution: #include "itensor/all.h" using namespace itensor; int main() { int N = 100; // // Initialize the site degrees of freedom. // auto sites = SpinHalf(N,{"ConserveQNs=",false}); //make a chain of N spin 1/2's //Transverse field Real h = 4.0; // //... 1 The symmetry condition enforces a Neumann Boundary condition on the velocity field and readsn\cdot\nabla u=0$$. These are actually two equations. In any coordinate system this is done by the contraction of the covariant derivative of the velocity field with the normal vector of the boundary:$$n^i \nabla_i u^k=n^i \left(\frac{\partial u^k}{\partial \xi^i}+... 1 For high dimensional tensor manipulations you should avoid using numpy.dot, which is very limited in scope, and instead use a combination of multiplication and summation. Although this would cost performance when used directly on Numpy arrays this is not the case in Nutils which uses a delayed execution model, and in fact uses dot or einsum under the hood. ... 1 It is mostly an academic project, but you could take a look at TEEM http://teem.sourceforge.net/download/index.html. A tutorial for using it for second order tensor visualizations maybe found at http://cg.cs.uni-bonn.de/en/people/junprof-dr-thomas-schultz/visweek-tutorial-tensors-in-visualization/ 1 Is it possible to tell in index notation whether a vector is a row or column vector, or is that supposed to be clear based on context? It seems the answer is actually lurking in your question itself here: ifu \cdot v \equiv u^T v$then that doesn't leave much wiggle room.$u^T\$ will have to be a row vector in order for the resulting product to be a ...

1

LTensor (https://code.google.com/p/ltensor/) is a VERY easy to use C++ template library for tensors up to rank 4 (based on indical notation), fast and lightweight too. You don't need to compile anything only need to include the main header file. I have used it on several projects and worked ok. It has some built-in features for rank-2 tensors like linear ...

1

this is a multidimensional array C++ library https://github.com/ContinuumIO/libdynd

1

I have not used it myself but libtensor seems to fulfill your requirements.

Only top voted, non community-wiki answers of a minimum length are eligible