Skip to main content

Questions tagged [tensor]

For questions involving computational modeling with tensors. The most common definitions of a tensor are a multilinear map or simply a multilinear array.

Filter by
Sorted by
Tagged with
0 votes
0 answers
38 views

Mathematica Package for validating effective string theory solution

I am asking for Mathematica package that given an input of: symmetric matrix $G_{\mu\nu}$, antisymmetric matrix $B_{\mu\nu}$ and a scalar function $\Phi$ will check whether it is a solution to the one-...
Daniel Vainshtein's user avatar
1 vote
1 answer
46 views

Difference of tensors to construct a higher dimensional tensor in pytorch

Suppose I have two tensors $A_{i_1,\ldots,i_M}$ and $B_{j_1,\ldots,j_N}$ where $M \neq N$ in general. We can define a tensor $C_{i_1,\ldots,i_M,j_1,\ldots,j_N}$ by $$ C_{i_1,\ldots,i_M,j_1,\ldots,j_N} ...
user8469759's user avatar
3 votes
3 answers
97 views

How to implement the following operation in pytorch (tensor by equating indices)

I wasn't sure if I should post this on stackoverflow rather than here, but because I have to construct a specific tensor I think here is more suitable. I have 2 tensors, $x \in \mathbb{R}^{M \times N \...
user8469759's user avatar
0 votes
0 answers
36 views

Numerical Divergence of a Tensor Field in Spherical Coordinates

I want to calculate the divergence of a rank-2 tensor field $$\nabla \cdot T$$ defined on the surface of a sphere in spherical coordinates. As an example, let the field be given as follows : ...
haricash's user avatar
11 votes
1 answer
340 views

Is it possible to express an arbitrary tensor contraction in terms of BLAS routines?

I noticed that libraries like numpy and pytorch are able to perform arbitrary tensor contractions at speeds similar to comparably sized matrix multiplications. This leads me to believe that underneath ...
ilya's user avatar
  • 121
3 votes
1 answer
92 views

Apply 3D Operator to Matrix and get new Matrix

Hopefully this question makes sense. I know I can formulate an operator for a vector as a matrix, then apply that matrix to my vector to get a new vector. For example, if I define a left shift ...
Nukesub's user avatar
  • 163
3 votes
0 answers
148 views

Numerical integration in Fourier space over 3D grid

I am attempting to implement a model outlined in this paper: General magnetostatic shape–shape interactions Background This model allows the calculation of magnetostatic interaction energies between ...
JasonC's user avatar
  • 43
0 votes
2 answers
166 views

Rotation of Higher order Tensors

I have a $D$-way tensor of dimensions $n\times n \times \dots \times n$ $(D)$- times. I want to sum the First vectors in all directions. For example, let $\boldsymbol{H}$ is 3-way tensor of dimensions ...
Neuling's user avatar
  • 23
1 vote
0 answers
33 views

Normalisation in tensor networks

I am trying to implement the iTEBD algorithm for the $PXP$ model, i.e, the hamiltonian is $$H = \sum_iP_{i-1}X_iP_{i+1}.$$ Here $P$ is the projector onto the ground state and $X$ is the usual pauli x ...
Souroy's user avatar
  • 11
1 vote
1 answer
66 views

Computing material derivated of tensor quantity

I would like to compute the material derivated of a tensor quantity, in the context of the finite volume method (FVM): The equation is: $$ \frac{\mathrm{d} \textbf{T}}{\mathrm{d} t} = \frac{\partial \...
user avatar
1 vote
1 answer
109 views

Converting a 4 rank matrix to 2 rank matrix after using tensorproduct

Let's say I have a 2x2 matrix (with symbols) called 'A'. Now, if do B = sympy.tensorproduct(A,A) print(sympy.shape(B)) I get, ...
Shashank Saumya's user avatar
1 vote
1 answer
266 views

Confusion about bilinear form for elasticity equation in deal.ii tutorial

I'm learning how to solve vector-valued problems with deal.II library. In particular, I'm looking at the following introduction from the official website https://www.dealii.org/current/doxygen/deal.II/...
FEGirl's user avatar
  • 405
1 vote
0 answers
213 views

3D Matrix (Tensor) Operating On a 1D Vector

Say you have a tensor $T$ and the components are represented by a 3 by 3 by 3 matrix. And you want to use that tensor to map a vector $u$ into a new vector $s$, both of which are 3 by 1 column vectors....
Nukesub's user avatar
  • 163
2 votes
0 answers
37 views

Scaling tensor approximation by symmetric tensor decomposition with SciPy's L-BFGS-B

I am trying to approximate a symmetric tensor of which the values are in the range of [1e-7,1e-4], by a symmetric tensor decomposition of lower rank. For this I am using the L-BFGS-B method in SciPy's ...
Jules's user avatar
  • 21
7 votes
1 answer
3k views

4th order tensor rotation - sources to refer

I am trying to model a linear elastic material in Abaqus using a UMAT. For my application, I need to rotate the 6x6 compliance matrix for a given set of eigenvectors (or a rotation matrix). I came ...
Sagar Shah's user avatar
1 vote
1 answer
303 views

Gradient of dot product of two tensors

Through obtaining an alternative form for force balance equation in a fluid mechanics problem, I stopped at a point where I have to prove this identity where $A$ and $B$ are second-order matrices:$$\...
Naghi's user avatar
  • 235
-1 votes
1 answer
440 views

Numpys `tensordot` and what is happening mathematically

I've encountered a program where np.tensordot was used, so I tried looking it up but I can't really understand what this function is doing... I feel rather ...
Sito's user avatar
  • 131
4 votes
1 answer
77 views

Compute distances from a vector to a matrix of vectors

Let $\vec{a} \in \mathbb{R}^\alpha$, and let $H$ be a rank 3 tensor with dimensions $M_{[i \in \mathbb{N}]} \times N_{[j \in \mathbb{N}]} \times \alpha_{[k \in \mathbb{N}]}$ (where the subscript are ...
Lin's user avatar
  • 143
1 vote
0 answers
49 views

Second fundamental form - Maple

I would like to know the command/line in Maple 16 or similar to obtain the second fundamental form tensor for a given metric. I've managed to obtain Rienmann and Ricci tensor, even Weyl, but I can't ...
Mitsumako's user avatar
4 votes
1 answer
1k views

Is there a library that allows einstein summation on dense, sparse, and LinearOperator type tensors

Numpy's einsum only works with dense tensors. Is there an alternative that also works with sparse tensors and linear operators? For example, I might have a ...
Bananach's user avatar
  • 799
1 vote
0 answers
211 views

How to get the derivatives of the determinant and inverse of 2nd-order tensor wrt itself in SymPy?

I have a second-order tensor for which I need to compute the derivatives of its determinant and inverse w.r.t. itself. The equations are as follows: $$\frac{\partial \, det(\mathbf{F})}{\partial F_{...
Chenna K's user avatar
  • 944
0 votes
1 answer
403 views

Computing excited states using itensor (with DMRG)

I am trying to compute first few excited states of some Hamiltonian (I am using itensor and its DMRG algorithm). To do so, I am ...
brzepkowski's user avatar
0 votes
2 answers
157 views

Second derivative in coordinate invariant form

To solve stationary, incompressible, inviscid and irrotational flow around a circular cylinder, I am using general coordinates. Since the flow is symmetrical, we only consider the upper half of the ...
ronalddb89's user avatar
1 vote
1 answer
136 views

triple cross prouct of tensor

Im trying to compute a triple cross product of vectors a,b, and c in real space and integrate over the entire space. The result is a term in the hamiltonian for an electronic system so there are ...
al_j's user avatar
  • 13
1 vote
2 answers
2k views

Derivative of the inverse of the Right Cauchy-Green Deformation Tensor wrt itself

In continuum mechanics, we define the Right-Cauchy-Green Deformation Tensor as $\boldsymbol{C}=\boldsymbol{F}^T\boldsymbol{F}$ I want to compute $\frac{\partial \boldsymbol{C}^{-1}}{\partial \...
user1751434's user avatar
1 vote
0 answers
103 views

Efficient out-of-place arbitrary rank GPU transpose

Summary: Is there an efficient out-of-place GPU tensor transpose operation that scales as $O(n)$ for tensors with $n$ total elements, regardless of the rank $d$? The naive algorithm costs $O(dn)$, ...
Geoffrey Irving's user avatar
5 votes
3 answers
3k views

Efficiently computing the product of a multi-dimensional matrix (or tensor) and vectors

Update: Thank you very much for all of you who answered below. I'm studying each answer now. In the long term, I'm more interested in solutions that work for sparse tensors (sorry I should have ...
f10w's user avatar
  • 515
1 vote
1 answer
117 views

Binary tensor operations in Nutils [closed]

How does one write general tensor contractions in the Python-based finite element package Nutils? For example, how does one write the contraction of a fourth-order elasticity tensor $\boldsymbol{C}$ ...
Clemens Verhoosel's user avatar
9 votes
3 answers
1k views

Second order tensor field visualization software

Is there an overview available over tensor visualization software? My personal preference is: A software which is free, well documented, and offers visualization techniques for different physical ...
imranal's user avatar
  • 425
0 votes
2 answers
196 views

Vector and index notation equivalence

Given 2 vectors $\mathbf{u}$ and $\mathbf{v}$ the following are equivalent: $\mathbf{u}\cdot\mathbf{v}$ $\mathbf{u}^T \mathbf{v}$ $u_i v_i$ $v_i u_i$ $\mathbf{v}\cdot\mathbf{u}$ $\mathbf{v}^T\...
Lukas Bystricky's user avatar
1 vote
0 answers
53 views

Optimization of nonlocal stencil-like operator on subset of regular grid

I am trying to optimize the execution time for this particular piece of fortran code. Details: i_gc is a (ngpts, 3) array of containing (i,j,k) indices for each grid point. This is a subset of the ...
user1984528's user avatar
0 votes
2 answers
108 views

Explain this multivariate differential identity

$$ \frac{\partial|\nabla\phi|^2}{\partial\phi}=-2\nabla\cdot\nabla\phi$$ I would very appreciate that you help me . Please do it in detail, I am quite not good at such problems. There is something ...
Jimmy's user avatar
  • 11
1 vote
0 answers
214 views

What is the relation between Kruskal tensor and CP decomposition?

In Matlab Tensor Toolbox there is a tensor type called "Kruskal tensors", I found its form is similar to the CP decomposition. Wikipedia mentioned: "As such, many of the methods have been ...
CyberPlayerOne's user avatar
1 vote
0 answers
218 views

4th order tensor [closed]

I'm new with FEniCS and Python and I'm stuck with this issue: is there a way to write a 4th order tensor in an easy way to implement? I have to compute the following stiffnes tensor: $A_{ijkl}= \...
Nicola Ferro's user avatar
1 vote
1 answer
53 views

Anisotropic invariant expansion

I am trying to calculate the second and third invariants for a turbulent flow. I have the second order statistics (both transient and averaged). i.e $uu$, $vv$, $ww$, $uv$, $vw$ and $uw$. These are ...
Thangam's user avatar
  • 21
1 vote
1 answer
739 views

Any relation between the singular values of each flattening matrices and the core tensor out of Tucker decomposition?

Before I know how to do tucker decomposition, I mistakenly thought the core tensor is only from combining the singular value matrices of the flattening matrices. Yes I know it is not now. For the ...
CyberPlayerOne's user avatar
3 votes
1 answer
277 views

Is there a reference/source paper for the TUCKER_ALS() in Tensor Toolbox for MATLAB?

TUCKER_ALS computes the best rank-(R1,R2,..,Rn) approximation of tensor X, according to the specified dimensions. I am using MATLAB Tensor Toolbox Version 2.5. I am wondering if I write a paper, how ...
CyberPlayerOne's user avatar
2 votes
0 answers
419 views

finite volume for diffusion equation with anisotropic (tensor) coefficient

Consider the scalar PDE for $u$ with Dirichlet boundary conditions: $\mathrm{div}(\mathcal{K}\nabla u) = f\; \forall x\; \in \Omega \subset R^2$, $u = 0 \; \forall \; x\;\in \partial\Omega$ ...
me10240's user avatar
  • 445
29 votes
10 answers
22k views

Fast, lightweight C++ tensor library for dimension-agnostic code

I am looking for a C++ tensor library that supports dimension-agnostic code. Specifically, I need to perform operations along each dimension (up to 3), e.g. calculating a weighted sum. The dimensions ...
Michael Schlottke-Lakemper's user avatar