mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-10-13 00:21:29 +08:00

Add a symCoeff() method to the Tensor class template that allows the user of the class to set multiple elements of a tensor at once if they are connected by a symmetry operation with respect to the tensor's indices (symmetry/antisymmetry/hermiticity/antihermiticity under echange of two indices and combination thereof for different pairs of indices). A compile-time resolution of the required symmetry groups via meta templates is also implemented. For small enough groups this is used to unroll the loop that goes through all the elements of the Tensor that are connected by this group. For larger groups or groups where the symmetries are defined at run time, a standard run-time implementation of the same algorithm is provided. For example, the following code completely initializes all elements of the totally antisymmetric tensor in three dimensions ('epsilon tensor'): SGroup<3, AntiSymmetry<0,1>, AntiSymmetry<1,2>> sym; Eigen::Tensor<double, 3> epsilon(3,3,3); epsilon.setZero(); epsilon.symCoeff(sym, 0, 1, 2) = 1;
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
// This file is part of Eigen, a lightweight C++ template library
|
|
// for linear algebra.
|
|
//
|
|
// Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
|
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
#ifndef EIGEN_CXX11_TENSORSYMMETRY_MODULE
|
|
#define EIGEN_CXX11_TENSORSYMMETRY_MODULE
|
|
|
|
#include <Eigen/CXX11/Tensor>
|
|
|
|
#include <Eigen/src/Core/util/DisableStupidWarnings.h>
|
|
|
|
/** \defgroup CXX11_TensorSymmetry_Module Tensor Symmetry Module
|
|
*
|
|
* This module provides a classes that allow for the definition of
|
|
* symmetries w.r.t. tensor indices.
|
|
*
|
|
* Including this module will implicitly include the Tensor module.
|
|
*
|
|
* \code
|
|
* #include <Eigen/TensorSymmetry>
|
|
* \endcode
|
|
*/
|
|
|
|
#include "src/TensorSymmetry/util/TemplateGroupTheory.h"
|
|
#include "src/TensorSymmetry/Symmetry.h"
|
|
#include "src/TensorSymmetry/StaticSymmetry.h"
|
|
#include "src/TensorSymmetry/DynamicSymmetry.h"
|
|
|
|
#include <Eigen/src/Core/util/ReenableStupidWarnings.h>
|
|
|
|
#endif // EIGEN_CXX11_TENSORSYMMETRY_MODULE
|
|
|
|
/*
|
|
* kate: space-indent on; indent-width 2; mixedindent off; indent-mode cstyle;
|
|
*/
|