diff --git a/doc/expression/expression.rst b/doc/expression/expression.rst index 3a71df0b..166f5a71 100644 --- a/doc/expression/expression.rst +++ b/doc/expression/expression.rst @@ -511,8 +511,8 @@ taken to be different on odd and even chain links. // Hamiltonian of the atomic chain expression H; - using static_indices::real::c_dag; - using static_indices::real::c; + using static_indices::c_dag; + using static_indices::c; // Length of the chain const int N = 10; diff --git a/doc/expression/factories.rst b/doc/expression/factories.rst index 4fdba7d7..da597906 100644 --- a/doc/expression/factories.rst +++ b/doc/expression/factories.rst @@ -11,9 +11,8 @@ components of spin operators. These can be further combined to build all sorts of many-body Hamiltonians and observables. The expression index types are automatically deduced from the types of arguments passed to the factories. -There are six sets of factory functions - each defined in a separate namespace - -differing in the scalar type of the created expression -(real, complex or arbitrary) and its index types being static/dynamic. +There are two sets of factory functions - each defined in a separate namespace - +differing in the index types of the created expression being static/dynamic. .. namespace:: libcommute @@ -24,19 +23,13 @@ differing in the scalar type of the created expression - Expression type * - :expr:`libcommute::static_indices` - :expr:`expression` - * - :expr:`libcommute::static_indices::real` - - :expr:`expression` - * - :expr:`libcommute::static_indices::complex` - - :expr:`expression, IndexTypes...>` * - :expr:`libcommute::dynamic_indices` - :expr:`expression` - * - :expr:`libcommute::dynamic_indices::real` - - :expr:`expression` - * - :expr:`libcommute::dynamic_indices::complex` - - :expr:`expression, dynamic_indices::dyn_indices>` -.. note:: Factory functions for spin component operators :math:`S_x` and - :math:`S_y` are defined only for the complex scalar type. +.. note:: By default, the scalar type of expressions returned by most factory + functions is ``double``. The only exceptions are factory functions + for spin component operators :math:`S_x` and :math:`S_y`, which + use the fixed scalar type ``std::complex``. .. _factories_static: @@ -45,58 +38,56 @@ Statically typed indices *Defined in * -.. rubric:: Namespace :expr:`libcommute::static_indices` - -.. function:: template \ +.. function:: template \ expression \ static_indices::c_dag(IndexTypes&&... indices) Make a fermionic creation operator :math:`c^\dagger` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::c(IndexTypes&&... indices) Make a fermionic annihilation operator :math:`c` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::n(IndexTypes&&... indices) Make a fermionic number operator :math:`n = c^\dagger c` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::a_dag(IndexTypes&&... indices) Make a bosonic creation operator :math:`a^\dagger` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::a(IndexTypes&&... indices) Make a bosonic annihilation operator :math:`a` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::S_p(IndexTypes&&... indices) Make a spin :math:`S=1/2` raising operator :math:`S_+` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::S_m(IndexTypes&&... indices) Make a spin :math:`S=1/2` lowering operator :math:`S_-` with given indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ static_indices::S_z(IndexTypes&&... indices) @@ -104,7 +95,7 @@ Statically typed indices and an arbitrary scalar type. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ static_indices::S_p(IndexTypes&&... indices) @@ -113,7 +104,7 @@ Statically typed indices equal :math:`2S+1`, where :math:`S` is the wanted spin. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ static_indices::S_m(IndexTypes&&... indices) @@ -122,7 +113,7 @@ Statically typed indices equal :math:`2S+1`, where :math:`S` is the wanted spin. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ static_indices::S_z(IndexTypes&&... indices) @@ -130,102 +121,16 @@ Statically typed indices and an arbitrary scalar type. The :expr:`Multiplicity` template parameter must equal :math:`2S+1`, where :math:`S` is the wanted spin. -.. rubric:: Namespace :expr:`libcommute::static_indices::real` - -.. function:: template \ - expression \ - static_indices::real::c_dag(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::c(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::n(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::a_dag(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::a(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_p(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_m(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_z(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_p(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_m(IndexTypes&&... indices) - template \ - expression \ - static_indices::real::S_z(IndexTypes&&... indices) - - Specializations of the factory functions from - :expr:`libcommute::static_indices` for the real expressions - (scalar type :expr:`double`). - -.. rubric:: Namespace :expr:`libcommute::static_indices::complex` - -.. function:: template \ - expression, IndexTypes...> \ - static_indices::complex::c_dag(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::c(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::n(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::a_dag(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::a(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_p(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_m(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_z(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_p(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_m(IndexTypes&&... indices) - template \ - expression, IndexTypes...> \ - static_indices::complex::S_z(IndexTypes&&... indices) - - Specializations of the factory functions from - :expr:`libcommute::static_indices` for the complex expressions - (scalar type :expr:`std::complex`). - .. function:: template \ expression, IndexTypes...> \ - static_indices::complex::S_x(IndexTypes&&... indices) + static_indices::S_x(IndexTypes&&... indices) Make a spin :math:`S=1/2` x-projection operator :math:`S_x` with given indices and the complex scalar type. .. function:: template \ expression, IndexTypes...> \ - static_indices::complex::S_y(IndexTypes&&... indices) + static_indices::S_y(IndexTypes&&... indices) Make a spin :math:`S=1/2` y-projection operator :math:`S_y` with given indices and the complex scalar type. @@ -233,7 +138,7 @@ Statically typed indices .. function:: template \ expression, IndexTypes...> \ - static_indices::complex::S_x(IndexTypes&&... indices) + static_indices::S_x(IndexTypes&&... indices) Make a general spin x-projection operator :math:`S_x` with given indices and the complex scalar type. The :expr:`Multiplicity` template parameter must @@ -242,7 +147,7 @@ Statically typed indices .. function:: template \ expression, IndexTypes...> \ - static_indices::complex::S_y(IndexTypes&&... indices) + static_indices::S_y(IndexTypes&&... indices) Make a general spin y-projection operator :math:`S_y` with given indices and the complex scalar type. The :expr:`Multiplicity` template parameter must @@ -259,58 +164,56 @@ Statically typed indices *Defined in * -.. rubric:: Namespace :expr:`libcommute::dynamic_indices` - -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::c_dag(IndexTypes&&... indices) Make a fermionic creation operator :math:`c^\dagger` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::c(IndexTypes&&... indices) Make a fermionic annihilation operator :math:`c` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::n(IndexTypes&&... indices) Make a fermionic number operator :math:`n = c^\dagger c` with given dynamically indices typed and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::a_dag(IndexTypes&&... indices) Make a bosonic creation operator :math:`a^\dagger` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::a(IndexTypes&&... indices) Make a bosonic annihilation operator :math:`a` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::S_p(IndexTypes&&... indices) Make a spin :math:`S=1/2` raising operator :math:`S_+` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::S_m(IndexTypes&&... indices) Make a spin :math:`S=1/2` lowering operator :math:`S_-` with given dynamically typed indices and an arbitrary scalar type. -.. function:: template \ +.. function:: template \ expression \ dynamic_indices::S_z(IndexTypes&&... indices) @@ -318,7 +221,7 @@ Statically typed indices dynamically typed indices and an arbitrary scalar type. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ dynamic_indices::S_p(IndexTypes&&... indices) @@ -327,7 +230,7 @@ Statically typed indices parameter must equal :math:`2S+1`, where :math:`S` is the wanted spin. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ dynamic_indices::S_m(IndexTypes&&... indices) @@ -336,7 +239,7 @@ Statically typed indices parameter must equal :math:`2S+1`, where :math:`S` is the wanted spin. .. function:: template \ + typename ScalarType = double, typename... IndexTypes> \ expression \ dynamic_indices::S_z(IndexTypes&&... indices) @@ -344,102 +247,16 @@ Statically typed indices typed indices and an arbitrary scalar type. The :expr:`Multiplicity` template parameter must equal :math:`2S+1`, where :math:`S` is the wanted spin. -.. rubric:: Namespace :expr:`libcommute::dynamic_indices::real` - -.. function:: template \ - expression \ - dynamic_indices::real::c_dag(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::c(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::n(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::a_dag(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::a(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_p(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_m(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_z(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_p(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_m(IndexTypes&&... indices) - template \ - expression \ - dynamic_indices::real::S_z(IndexTypes&&... indices) - - Specializations of the factory functions from - :expr:`libcommute::dynamic_indices` for the real expressions (scalar type - :expr:`double`). - -.. rubric:: Namespace :expr:`libcommute::dynamic_indices::complex` - -.. function:: template \ - expression, dyn_indices> \ - dynamic_indices::complex::c_dag(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::c(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::n(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::a_dag(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::a(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_p(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_m(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_z(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_p(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_m(IndexTypes&&... indices) - template \ - expression, dyn_indices> \ - dynamic_indices::complex::S_z(IndexTypes&&... indices) - - Specializations of the factory functions from - :expr:`libcommute::dynamic_indices` for the complex expressions (scalar type - :expr:`std::complex`). - .. function:: template \ expression, dyn_indices> \ - dynamic_indices::complex::S_x(IndexTypes&&... indices) + dynamic_indices::S_x(IndexTypes&&... indices) Make a spin :math:`S=1/2` x-projection operator :math:`S_x` with given dynamically typed indices and the complex scalar type. .. function:: template \ expression, dyn_indices> \ - dynamic_indices::complex::S_y(IndexTypes&&... indices) + dynamic_indices::S_y(IndexTypes&&... indices) Make a spin :math:`S=1/2` y-projection operator :math:`S_y` with given dynamically typed indices and the complex scalar type. @@ -447,7 +264,7 @@ Statically typed indices .. function:: template \ expression, dyn_indices> \ - dynamic_indices::complex::S_x(IndexTypes&&... indices) + dynamic_indices::S_x(IndexTypes&&... indices) Make a general spin x-projection operator :math:`S_x` with given dynamically typed indices and the complex scalar type. The :expr:`Multiplicity` template @@ -456,7 +273,7 @@ Statically typed indices .. function:: template \ expression, dyn_indices> \ - dynamic_indices::complex::S_y(IndexTypes&&... indices) + dynamic_indices::S_y(IndexTypes&&... indices) Make a general spin y-projection operator :math:`S_y` with given dynamically typed indices and the complex scalar type. The :expr:`Multiplicity` template diff --git a/doc/loperator/hilbert_space.rst b/doc/loperator/hilbert_space.rst index 24f195ae..fca1cd4e 100644 --- a/doc/loperator/hilbert_space.rst +++ b/doc/loperator/hilbert_space.rst @@ -69,7 +69,7 @@ The simplest way to construct a :class:`hilbert_space` object is by calling .. code:: cpp using namespace libcommute; - using namespace static_indices::real; // For n() + using namespace static_indices; // For n() auto H = 2.0 * n("up", 0) * n("dn", 0); @@ -92,7 +92,7 @@ generators at once. .. code:: cpp using namespace libcommute; - using namespace static_indices::real; // For a_dag() and a() + using namespace static_indices; // For a_dag() and a() auto H = 2.0 * (a_dag(0) * a(0) - 0.5) + 3.0 * (a_dag(1) * a(1) - 0.5);