I am writing a scientific code in c which requires numerous tensor products, and higher-order tensor operations as well, e.g. contraction, kronecker product, etc. I am planning on implementing this myself using efficient algorithms as in the literature and employing a good BLAS library. I did some looking about and haven't really found anything for c (plenty for c++, python etc.). Am I missing something or has this really not been well implemented in c?
Thanks.
Multiply two or more tensors using torch. mul() and assign the value to a new variable. You can also multiply a scalar quantity and a tensor. Multiplying the tensors using this method does not make any change in the original tensors.
Tensordot (also known as tensor contraction) sums the product of elements from a and b over the indices specified by axes . This operation corresponds to numpy. tensordot(a, b, axes) . Example 1: When a and b are matrices (order 2), the case axes=1 is equivalent to matrix multiplication.
TensorFlow multiply tensor by scaler In this section, we will discuss how to multiply tensor by scaler in Python TensorFlow. To do this task, we are going to use the tf. multiply() function and this function will help the user to multiply tensor by the scaler. In simple words, a scaler is a single value.
If you want to carry out matrix multiplication, this can be done with the function Dot and is described in the section "Matrix Multiplication". An example of element-wise multiplication is shown in the following example: Copy to clipboard.
There are many different uses of tensors in scientific computing, so this question is hard to answer without more details.
There is a related answer on SciComp that mentions Eigen, Armadillo, deal.II, libtensor and libdynd.
If you are interested in contracting large tensors in parallel, look at the Cyclops Tensor Framework (CTF), which is the back-end for multiple quantum chemistry codes. If you want to do a large number of small contractions, CTF may not help you.
Other open-source tensor libraries include libtensor and TiledArray, which are also used in quantum chemistry.
The MADNESS project has a tensor class that might meet your needs if small dimensions are of interest.
itensor is another tensor library, which aims to support DMRG computations.
FTensor is a C++ tensor library oriented at general relativity.
Because tensors operations are important to machine learning, companies like Facebook and Google have released tensor libraries such as THPP and TensorFlow, respectively.
There is a very old project called POOMA that might support small tensors to meet your needs, but this project is no longer active and you should expect no support whatsoever.
When all else fails, see Wikipedia or Google (about half of the information here was identified by searching for "tensor library" on Google, although I have historical familiarity with most of it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With