diff --git a/SeQuant/core/abstract_tensor.hpp b/SeQuant/core/abstract_tensor.hpp index 3505f1234..caa6cf21a 100644 --- a/SeQuant/core/abstract_tensor.hpp +++ b/SeQuant/core/abstract_tensor.hpp @@ -107,8 +107,8 @@ class AbstractTensor { } /// accesses aux (invariant) indices /// @return view of a contiguous range of Index objects - virtual const_any_view_randsz _auxiliary() const { - throw missing_instantiation_for("_auxiliary"); + virtual const_any_view_randsz _aux() const { + throw missing_instantiation_for("_aux"); } /// accesses bra and ket indices /// view of a not necessarily contiguous range of Index objects @@ -129,8 +129,8 @@ class AbstractTensor { throw missing_instantiation_for("_ket_rank"); } /// @return the number of aux indices - virtual std::size_t _auxiliary_rank() const { - throw missing_instantiation_for("_auxiliary_rank"); + virtual std::size_t _aux_rank() const { + throw missing_instantiation_for("_aux_rank"); } /// @return the permutational symmetry of the vector space indices of /// the tensor @@ -184,11 +184,11 @@ class AbstractTensor { virtual any_view_randsz _ket_mutable() { throw missing_instantiation_for("_ket_mutable"); } - /// @return mutable view of auxiliary indices + /// @return mutable view of aux indices /// @warning this is used for mutable access, flush memoized state before /// returning! - virtual any_view_randsz _auxiliary_mutable() { - throw missing_instantiation_for("_auxiliary_mutable"); + virtual any_view_randsz _aux_mutable() { + throw missing_instantiation_for("_aux_mutable"); } friend class TensorCanonicalizer; @@ -199,14 +199,12 @@ class AbstractTensor { /// @{ inline auto bra(const AbstractTensor& t) { return t._bra(); } inline auto ket(const AbstractTensor& t) { return t._ket(); } -inline auto auxiliary(const AbstractTensor& t) { return t._auxiliary(); } +inline auto aux(const AbstractTensor& t) { return t._aux(); } inline auto braket(const AbstractTensor& t) { return t._braket(); } inline auto indices(const AbstractTensor& t) { return t._indices(); } inline auto bra_rank(const AbstractTensor& t) { return t._bra_rank(); } inline auto ket_rank(const AbstractTensor& t) { return t._ket_rank(); } -inline auto auxiliary_rank(const AbstractTensor& t) { - return t._auxiliary_rank(); -} +inline auto aux_rank(const AbstractTensor& t) { return t._aux_rank(); } inline auto symmetry(const AbstractTensor& t) { return t._symmetry(); } inline auto braket_symmetry(const AbstractTensor& t) { return t._braket_symmetry(); @@ -222,12 +220,12 @@ inline auto to_latex(const AbstractTensor& t) { return t._to_latex(); } /// Type trait for checking whether a given class fulfills the Tensor interface /// requirements Object @c t of a type that meets the concept must satisfy the /// following: -/// - @c bra(t) , @c ket(t), @c auxiliary(t), @c braket(t) and +/// - @c bra(t) , @c ket(t), @c aux(t), @c braket(t) and /// @c indices(t) are valid expressions and evaluate to a range of Index /// objects; -/// - @c bra_rank(t), @c ket_rank(t) and @c auxiliary_rank(t) are valid -/// expression and return sizes of the @c bra(t), @c ket(t) and @c -/// auxiliary(t) ranges, respectively; +/// - @c bra_rank(t), @c ket_rank(t) and @c aux_rank(t) are valid +/// expression and return sizes of the @c bra(t), @c ket(t) and +/// @c aux(t) ranges, respectively; /// - @c symmetry(t) is a valid expression and evaluates to a Symmetry /// object that describes the symmetry of bra/ket of a /// _particle-symmetric_ @c t ; @@ -251,12 +249,12 @@ struct is_tensor : std::bool_constant< std::is_invocable_v && std::is_invocable_v && - std::is_invocable_v && + std::is_invocable_v && std::is_invocable_v && std::is_invocable_v && std::is_invocable_v && std::is_invocable_v && - std::is_invocable_v && + std::is_invocable_v && std::is_invocable_v && std::is_invocable_v && std::is_invocable_v && diff --git a/SeQuant/core/eval_expr.cpp b/SeQuant/core/eval_expr.cpp index 6cefbd4bf..dbb710455 100644 --- a/SeQuant/core/eval_expr.cpp +++ b/SeQuant/core/eval_expr.cpp @@ -339,7 +339,7 @@ ExprPtr make_sum(EvalExpr const& left, EvalExpr const& right) noexcept { auto ts = tensor_symmetry_sum(left, right); auto ps = particle_symmetry(ts); auto bks = get_default_context().braket_symmetry(); - return ex(L"I", t1.bra(), t1.ket(), t1.auxiliary(), ts, bks, ps); + return ex(L"I", t1.bra(), t1.ket(), t1.aux(), ts, bks, ps); } ExprPtr make_prod(EvalExpr const& left, EvalExpr const& right) noexcept { @@ -379,9 +379,8 @@ ExprPtr make_imed(EvalExpr const& left, EvalExpr const& right, assert(op == EvalOp::Prod && "scalar + tensor not supported"); auto const& t = right.expr()->as(); - return ex(Tensor{L"I", t.bra(), t.ket(), t.auxiliary(), - t.symmetry(), t.braket_symmetry(), - t.particle_symmetry()}); + return ex(Tensor{L"I", t.bra(), t.ket(), t.aux(), t.symmetry(), + t.braket_symmetry(), t.particle_symmetry()}); } else if (lres == ResultType::Tensor && rres == ResultType::Scalar) { // tensor (*) scalar diff --git a/SeQuant/core/export/itf.cpp b/SeQuant/core/export/itf.cpp index 6de7fff70..fafefd5dd 100644 --- a/SeQuant/core/export/itf.cpp +++ b/SeQuant/core/export/itf.cpp @@ -257,7 +257,7 @@ void one_electron_integral_remapper( auto braIndices = tensor.bra(); auto ketIndices = tensor.ket(); - assert(tensor.auxiliary().empty()); + assert(tensor.aux().empty()); IndexTypeComparer cmp; @@ -273,7 +273,7 @@ void one_electron_integral_remapper( } expr = ex(tensor.label(), std::move(braIndices), - std::move(ketIndices), tensor.auxiliary()); + std::move(ketIndices), tensor.aux()); } template @@ -317,7 +317,7 @@ void two_electron_integral_remapper( // Copy indices as we might have to mutate them auto braIndices = tensor.bra(); auto ketIndices = tensor.ket(); - assert(tensor.auxiliary().empty()); + assert(tensor.aux().empty()); IndexTypeComparer cmp; @@ -408,7 +408,7 @@ void two_electron_integral_remapper( } expr = ex(std::move(tensorLabel), std::move(braIndices), - std::move(ketIndices), tensor.auxiliary()); + std::move(ketIndices), tensor.aux()); } void integral_remapper(ExprPtr &expr, std::wstring_view oneElectronIntegralName, diff --git a/SeQuant/core/op.hpp b/SeQuant/core/op.hpp index 106dd3aa2..5b76089a9 100644 --- a/SeQuant/core/op.hpp +++ b/SeQuant/core/op.hpp @@ -829,7 +829,7 @@ class NormalOperator : public Operator, ranges::views::transform( [](auto &&op) -> const Index & { return op.index(); }); } - AbstractTensor::const_any_view_randsz _auxiliary() const override final { + AbstractTensor::const_any_view_randsz _aux() const override final { return {}; } AbstractTensor::const_any_view_rand _braket() const override final { @@ -842,7 +842,7 @@ class NormalOperator : public Operator, } std::size_t _bra_rank() const override final { return nannihilators(); } std::size_t _ket_rank() const override final { return ncreators(); } - std::size_t _auxiliary_rank() const override final { return 0; } + std::size_t _aux_rank() const override final { return 0; } Symmetry _symmetry() const override final { return (S == Statistics::FermiDirac ? (get_default_context(S).spbasis() == SPBasis::spinorbital @@ -890,9 +890,7 @@ class NormalOperator : public Operator, ranges::views::transform( [](auto &&op) -> Index & { return op.index(); }); } - AbstractTensor::any_view_randsz _auxiliary_mutable() override final { - return {}; - } + AbstractTensor::any_view_randsz _aux_mutable() override final { return {}; } }; static_assert( diff --git a/SeQuant/core/parse/deparse.cpp b/SeQuant/core/parse/deparse.cpp index 056b0f342..94ad99d99 100644 --- a/SeQuant/core/parse/deparse.cpp +++ b/SeQuant/core/parse/deparse.cpp @@ -136,11 +136,11 @@ std::wstring deparse(Tensor const& tensor, bool annot_sym) { if (tensor.ket_rank() > 0) { deparsed += L";" + details::deparse_indices(tensor.ket()); } - if (tensor.auxiliary_rank() > 0) { + if (tensor.aux_rank() > 0) { if (tensor.ket_rank() == 0) { deparsed += L";"; } - deparsed += L";" + details::deparse_indices(tensor.auxiliary()); + deparsed += L";" + details::deparse_indices(tensor.aux()); } deparsed += L"}"; diff --git a/SeQuant/core/tensor.hpp b/SeQuant/core/tensor.hpp index 28f7416f8..9f500a0ac 100644 --- a/SeQuant/core/tensor.hpp +++ b/SeQuant/core/tensor.hpp @@ -71,8 +71,8 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { /// @return concatenated view of the bra and ket index ranges auto braket() { return ranges::views::concat(bra_, ket_); } - /// @return concatenated view of bra, ket, and auxiliary index ranges - auto indices() { return ranges::views::concat(bra_, ket_, auxiliary_); } + /// @return concatenated view of bra, ket, and aux index ranges + auto indices() { return ranges::views::concat(bra_, ket_, aux_); } /// asserts that @p label is not reserved /// @note Tensor with reserved labels are constructed using friends of Tensor @@ -87,14 +87,14 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { template Tensor(std::wstring_view label, IndexRange1 &&bra_indices, - IndexRange2 &&ket_indices, IndexRange3 &&auxiliary_indices, - reserved_tag, Symmetry s = Symmetry::nonsymm, + IndexRange2 &&ket_indices, IndexRange3 &&aux_indices, reserved_tag, + Symmetry s = Symmetry::nonsymm, BraKetSymmetry bks = get_default_context().braket_symmetry(), ParticleSymmetry ps = ParticleSymmetry::symm) : label_(label), bra_(make_indices(bra_indices)), ket_(make_indices(ket_indices)), - auxiliary_(make_indices(auxiliary_indices)), + aux_(make_indices(aux_indices)), symmetry_(s), braket_symmetry_(bks), particle_symmetry_(ps) { @@ -112,7 +112,7 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { /// to indices) /// @param ket_indices list of ket indices (or objects that can be converted /// to indices) - /// @param auxiliary_indices list of auxiliary indices (or objects that can be + /// @param aux_indices list of aux indices (or objects that can be /// converted to indices) /// @param s the symmetry of bra or ket /// @param bks the symmetry with respect to bra-ket exchange @@ -123,14 +123,14 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { !meta::is_initializer_list_v> && !meta::is_initializer_list_v>>> Tensor(std::wstring_view label, IndexRange1 &&bra_indices, - IndexRange2 &&ket_indices, IndexRange3 &&auxiliary_indices, + IndexRange2 &&ket_indices, IndexRange3 &&aux_indices, Symmetry s = Symmetry::nonsymm, BraKetSymmetry bks = get_default_context().braket_symmetry(), ParticleSymmetry ps = ParticleSymmetry::symm) : Tensor(label, std::forward(bra_indices), std::forward(ket_indices), - std::forward(auxiliary_indices), reserved_tag{}, s, - bks, ps) { + std::forward(aux_indices), reserved_tag{}, s, bks, + ps) { assert_nonreserved_label(label_); } @@ -143,7 +143,7 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { /// to indices) /// @param ket_indices list of ket indices (or objects that can be converted /// to indices) - /// @param auxiliary_indices list of auxiliary indices (or objects that can be + /// @param aux_indices list of aux indices (or objects that can be /// converted to indices) /// @param s the symmetry of bra or ket /// @param bks the symmetry with respect to bra-ket exchange @@ -151,12 +151,11 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { template Tensor(std::wstring_view label, std::initializer_list bra_indices, std::initializer_list ket_indices, - std::initializer_list auxiliary_indices, - Symmetry s = Symmetry::nonsymm, + std::initializer_list aux_indices, Symmetry s = Symmetry::nonsymm, BraKetSymmetry bks = get_default_context().braket_symmetry(), ParticleSymmetry ps = ParticleSymmetry::symm) : Tensor(label, make_indices(bra_indices), make_indices(ket_indices), - make_indices(auxiliary_indices), reserved_tag{}, s, bks, ps) { + make_indices(aux_indices), reserved_tag{}, s, bks, ps) { assert_nonreserved_label(label_); } @@ -173,13 +172,13 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { const auto &bra() const { return bra_; } /// @return the ket index range const auto &ket() const { return ket_; } - /// @return the auxiliary index range - const auto &auxiliary() const { return auxiliary_; } + /// @return the aux index range + const auto &aux() const { return aux_; } /// @return concatenated view of the bra and ket index ranges auto braket() const { return ranges::views::concat(bra_, ket_); } /// @return concatenated view of all indices of this tensor (bra, ket and - /// auxiliary) - auto indices() const { return ranges::views::concat(bra_, ket_, auxiliary_); } + /// aux) + auto indices() const { return ranges::views::concat(bra_, ket_, aux_); } /// @return view of the bra+ket index ranges /// @note this is to work around broken lookup rules auto const_braket() const { return this->braket(); } @@ -207,8 +206,8 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { std::size_t bra_rank() const { return bra_.size(); } /// @return number of ket indices std::size_t ket_rank() const { return ket_.size(); } - /// @return number of auxiliary indices - auto auxiliary_rank() const { return auxiliary_.size(); } + /// @return number of aux indices + std::size_t aux_rank() const { return aux_.size(); } /// @return number of indices in bra/ket /// @throw std::logic_error if bra and ket ranks do not match std::size_t rank() const { @@ -234,13 +233,13 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { result += L"}_{"; for (const auto &i : this->bra()) result += sequant::to_latex(i); result += L"}"; - if (!this->auxiliary_.empty()) { + if (!this->aux_.empty()) { result += L"("; - const index_container_type &aux = auxiliary(); - for (std::size_t i = 0; i < auxiliary_rank(); ++i) { - result += sequant::to_latex(aux[i]); + const index_container_type &__aux = aux(); + for (std::size_t i = 0; i < aux_rank(); ++i) { + result += sequant::to_latex(__aux[i]); - if (i + 1 < auxiliary_rank()) { + if (i + 1 < aux_rank()) { result += L","; } } @@ -287,7 +286,7 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { std::wstring label_{}; index_container_type bra_{}; index_container_type ket_{}; - index_container_type auxiliary_{}; + index_container_type aux_{}; Symmetry symmetry_ = Symmetry::invalid; BraKetSymmetry braket_symmetry_ = BraKetSymmetry::invalid; ParticleSymmetry particle_symmetry_ = ParticleSymmetry::invalid; @@ -308,7 +307,7 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { auto val = hash::range(begin(bra()), end(bra())); bra_hash_value_ = val; hash::range(val, begin(ket()), end(ket())); - hash::range(val, begin(auxiliary()), end(auxiliary())); + hash::range(val, begin(aux()), end(aux())); hash::combine(val, label_); hash::combine(val, symmetry_); hash_value_ = val; @@ -324,7 +323,8 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { if (this->label() == that_cast.label() && this->symmetry() == that_cast.symmetry() && this->bra_rank() == that_cast.bra_rank() && - this->ket_rank() == that_cast.ket_rank()) { + this->ket_rank() == that_cast.ket_rank() && + this->aux_rank() == that_cast.aux_rank()) { // compare hash values first if (this->hash_value() == that.hash_value()) // hash values agree -> do full comparison @@ -351,6 +351,10 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { return this->ket_rank() < that_cast.ket_rank(); } + if (this->aux_rank() != that_cast.aux_rank()) { + return this->aux_rank() < that_cast.aux_rank(); + } + // v1: compare hashes only // return Expr::static_less_than(that); // v2: compare fully @@ -366,9 +370,9 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { that_cast.ket().end()); } - return std::lexicographical_compare( - this->auxiliary().begin(), this->auxiliary().end(), - that_cast.auxiliary().begin(), that_cast.auxiliary().end()); + return std::lexicographical_compare(this->aux().begin(), this->aux().end(), + that_cast.aux().begin(), + that_cast.aux().end()); } // these implement the AbstractTensor interface @@ -380,9 +384,9 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { return ranges::counted_view( ket_.empty() ? nullptr : &(ket_[0]), ket_.size()); } - AbstractTensor::const_any_view_randsz _auxiliary() const override final { + AbstractTensor::const_any_view_randsz _aux() const override final { return ranges::counted_view( - auxiliary_.empty() ? nullptr : &(auxiliary_[0]), auxiliary_.size()); + aux_.empty() ? nullptr : &(aux_[0]), aux_.size()); } AbstractTensor::const_any_view_rand _braket() const override final { return braket(); @@ -392,9 +396,7 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { } std::size_t _bra_rank() const override final { return bra_rank(); } std::size_t _ket_rank() const override final { return ket_rank(); } - std::size_t _auxiliary_rank() const override final { - return auxiliary_rank(); - } + std::size_t _aux_rank() const override final { return aux_rank(); } Symmetry _symmetry() const override final { return symmetry_; } BraKetSymmetry _braket_symmetry() const override final { return braket_symmetry_; @@ -430,10 +432,10 @@ class Tensor : public Expr, public AbstractTensor, public Labeled { return ranges::counted_view(ket_.empty() ? nullptr : &(ket_[0]), ket_.size()); } - AbstractTensor::any_view_randsz _auxiliary_mutable() override final { + AbstractTensor::any_view_randsz _aux_mutable() override final { this->reset_hash_value(); - return ranges::counted_view( - auxiliary_.empty() ? nullptr : &(auxiliary_[0]), auxiliary_.size()); + return ranges::counted_view(aux_.empty() ? nullptr : &(aux_[0]), + aux_.size()); } }; // class Tensor diff --git a/SeQuant/core/tensor_canonicalizer.hpp b/SeQuant/core/tensor_canonicalizer.hpp index beddfe6e7..818e03de8 100644 --- a/SeQuant/core/tensor_canonicalizer.hpp +++ b/SeQuant/core/tensor_canonicalizer.hpp @@ -102,9 +102,7 @@ class TensorCanonicalizer { protected: inline auto bra_range(AbstractTensor& t) const { return t._bra_mutable(); } inline auto ket_range(AbstractTensor& t) const { return t._ket_mutable(); } - inline auto auxiliary_range(AbstractTensor& t) const { - return t._auxiliary_mutable(); - } + inline auto aux_range(AbstractTensor& t) const { return t._aux_mutable(); } /// the object used to compare indices static index_comparer_t index_comparer_; @@ -163,7 +161,7 @@ class DefaultTensorCanonicalizer : public TensorCanonicalizer { auto is_antisymm = (s == Symmetry::antisymm); const auto _bra_rank = bra_rank(t); const auto _ket_rank = ket_rank(t); - const auto _aux_rank = auxiliary_rank(t); + const auto _aux_rank = aux_rank(t); const auto _rank = std::min(_bra_rank, _ket_rank); // nothing to do for rank-1 tensors @@ -217,7 +215,7 @@ class DefaultTensorCanonicalizer : public TensorCanonicalizer { } // TODO: Handle auxiliary index symmetries once they are introduced - // auto _aux = auxiliary_range(t); + // auto _aux = aux_range(t); // ranges::sort(_aux, comp); ExprPtr result = diff --git a/SeQuant/core/tensor_network.cpp b/SeQuant/core/tensor_network.cpp index 4c5db4bc4..784bc51d8 100644 --- a/SeQuant/core/tensor_network.cpp +++ b/SeQuant/core/tensor_network.cpp @@ -65,8 +65,8 @@ struct TensorBlockCompare { if (ket_rank(lhs) != ket_rank(rhs)) { return ket_rank(lhs) < ket_rank(rhs); } - if (auxiliary_rank(lhs) != auxiliary_rank(rhs)) { - return auxiliary_rank(lhs) < auxiliary_rank(rhs); + if (aux_rank(lhs) != aux_rank(rhs)) { + return aux_rank(lhs) < aux_rank(rhs); } auto lhs_indices = indices(lhs); @@ -759,7 +759,7 @@ TensorNetwork::Graph TensorNetwork::create_graph( // TODO: handle aux indices permutation symmetries once they are supported // for now, auxiliary indices are considered to always be asymmetric - for (std::size_t i = 0; i < auxiliary_rank(tensor); ++i) { + for (std::size_t i = 0; i < aux_rank(tensor); ++i) { graph.vertex_labels.emplace_back(L"aux_" + std::to_wstring(i + 1)); graph.vertex_types.push_back(VertexType::TensorAux); graph.vertex_colors.push_back(2 * max_rank + i); @@ -942,7 +942,7 @@ void TensorNetwork::init_edges() { Vertex(Origin::Ket, tensor_idx, index_idx, tensor_symm)); } - auto aux_indices = auxiliary(tensor); + auto aux_indices = aux(tensor); for (std::size_t index_idx = 0; index_idx < aux_indices.size(); ++index_idx) { // Note: for the time being we don't have a way of expressing diff --git a/SeQuant/core/utility/indices.hpp b/SeQuant/core/utility/indices.hpp index 2b3e2c1ad..53abb8d0a 100644 --- a/SeQuant/core/utility/indices.hpp +++ b/SeQuant/core/utility/indices.hpp @@ -97,10 +97,10 @@ IndexGroups get_uncontracted_indices(const Tensor& t1, detail::not_in{t1.bra()}); // Auxiliary indices - std::copy_if(t1.auxiliary().begin(), t1.auxiliary().end(), - std::back_inserter(groups.aux), detail::not_in{t2.auxiliary()}); - std::copy_if(t2.auxiliary().begin(), t2.auxiliary().end(), - std::back_inserter(groups.aux), detail::not_in{t1.auxiliary()}); + std::copy_if(t1.aux().begin(), t1.aux().end(), std::back_inserter(groups.aux), + detail::not_in{t2.aux()}); + std::copy_if(t2.aux().begin(), t2.aux().end(), std::back_inserter(groups.aux), + detail::not_in{t1.aux()}); return groups; } @@ -132,7 +132,7 @@ IndexGroups get_unique_indices(const Tensor& tensor) { } } - for (const Index& current : tensor.auxiliary()) { + for (const Index& current : tensor.aux()) { if (encounteredIndices.find(current) == encounteredIndices.end()) { groups.aux.push_back(current); encounteredIndices.insert(current); diff --git a/SeQuant/domain/mbpt/antisymmetrizer.hpp b/SeQuant/domain/mbpt/antisymmetrizer.hpp index 34fd7156d..9c4e9077e 100644 --- a/SeQuant/domain/mbpt/antisymmetrizer.hpp +++ b/SeQuant/domain/mbpt/antisymmetrizer.hpp @@ -503,7 +503,7 @@ ExprPtr spin_sum(std::vector original_upper, } factor = ex(L"Γ", factor->as().bra(), factor->as().ket(), - factor->as().auxiliary()); + factor->as().aux()); } else if (factor->is()) { // prefactor = ex(-0.5) * // ex(factor->as().rank()) * prefactor; diff --git a/SeQuant/domain/mbpt/spin.cpp b/SeQuant/domain/mbpt/spin.cpp index c3fe59acc..b6e6ca620 100644 --- a/SeQuant/domain/mbpt/spin.cpp +++ b/SeQuant/domain/mbpt/spin.cpp @@ -126,7 +126,7 @@ ExprPtr swap_bra_ket(const ExprPtr& expr) { // Lambda for tensor auto tensor_swap = [](const Tensor& tensor) { auto result = Tensor(tensor.label(), tensor.ket(), tensor.bra(), - tensor.auxiliary(), tensor.symmetry(), + tensor.aux(), tensor.symmetry(), tensor.braket_symmetry(), tensor.particle_symmetry()); return ex(result); }; @@ -198,8 +198,8 @@ ExprPtr remove_spin(const ExprPtr& expr) { idx = make_spinfree(idx); } } - Tensor result(tensor.label(), bra, ket, tensor.auxiliary(), - tensor.symmetry(), tensor.braket_symmetry()); + Tensor result(tensor.label(), bra, ket, tensor.aux(), tensor.symmetry(), + tensor.braket_symmetry()); return std::make_shared(std::move(result)); }; @@ -287,9 +287,9 @@ ExprPtr expand_antisymm(const Tensor& tensor, bool skip_spinsymm) { assert(tensor.bra_rank() == tensor.ket_rank()); // Return non-symmetric tensor if rank is 1 if (tensor.bra_rank() == 1) { - Tensor new_tensor(tensor.label(), tensor.bra(), tensor.ket(), - tensor.auxiliary(), Symmetry::nonsymm, - tensor.braket_symmetry(), tensor.particle_symmetry()); + Tensor new_tensor(tensor.label(), tensor.bra(), tensor.ket(), tensor.aux(), + Symmetry::nonsymm, tensor.braket_symmetry(), + tensor.particle_symmetry()); return std::make_shared(new_tensor); } @@ -318,8 +318,8 @@ ExprPtr expand_antisymm(const Tensor& tensor, bool skip_spinsymm) { container::set ket_list(tensor.ket().begin(), tensor.ket().end()); auto expr_sum = std::make_shared(); do { - auto new_tensor = Tensor(tensor.label(), bra_list, ket_list, - tensor.auxiliary(), Symmetry::nonsymm); + auto new_tensor = Tensor(tensor.label(), bra_list, ket_list, tensor.aux(), + Symmetry::nonsymm); if (spin_symm_tensor(new_tensor)) { auto new_tensor_product = std::make_shared(); @@ -524,7 +524,7 @@ ExprPtr symmetrize_expr(const Product& product) { auto S = Tensor{}; if (A_is_nconserving) { - S = Tensor(L"S", A_tensor.bra(), A_tensor.ket(), A_tensor.auxiliary(), + S = Tensor(L"S", A_tensor.bra(), A_tensor.ket(), A_tensor.aux(), Symmetry::nonsymm); } else { // A is N-nonconserving auto n = std::min(A_tensor.bra_rank(), A_tensor.ket_rank()); @@ -532,8 +532,7 @@ ExprPtr symmetrize_expr(const Product& product) { A_tensor.bra().begin() + n); container::svector ket_list(A_tensor.ket().begin(), A_tensor.ket().begin() + n); - S = Tensor(L"S", bra_list, ket_list, A_tensor.auxiliary(), - Symmetry::nonsymm); + S = Tensor(L"S", bra_list, ket_list, A_tensor.aux(), Symmetry::nonsymm); } // Generate replacement maps from a list of Index type (could be a bra or a @@ -1081,7 +1080,7 @@ Tensor swap_spin(const Tensor& t) { return {t.label(), bra, ket, - t.auxiliary(), + t.aux(), t.symmetry(), t.braket_symmetry(), t.particle_symmetry()}; @@ -1121,7 +1120,7 @@ ExprPtr merge_tensors(const Tensor& O1, const Tensor& O2) { assert(O1.symmetry() == O2.symmetry()); auto bra = ranges::views::concat(O1.bra(), O2.bra()); auto ket = ranges::views::concat(O1.ket(), O2.ket()); - auto aux = ranges::views::concat(O1.auxiliary(), O2.auxiliary()); + auto aux = ranges::views::concat(O1.aux(), O2.aux()); return ex(Tensor(O1.label(), bra, ket, aux, O1.symmetry())); } @@ -1148,7 +1147,7 @@ std::vector open_shell_A_op(const Tensor& A) { ranges::for_each(spin_bra, [](const Index& i) { i.reset_tag(); }); ranges::for_each(spin_ket, [](const Index& i) { i.reset_tag(); }); result.at(i) = ex( - Tensor(L"A", spin_bra, spin_ket, A.auxiliary(), Symmetry::antisymm)); + Tensor(L"A", spin_bra, spin_ket, A.aux(), Symmetry::antisymm)); // std::wcout << to_latex(result.at(i)) << " "; } // std::wcout << "\n" << std::endl; diff --git a/tests/unit/test_canonicalize.cpp b/tests/unit/test_canonicalize.cpp index 5567c7849..b344a7b8a 100644 --- a/tests/unit/test_canonicalize.cpp +++ b/tests/unit/test_canonicalize.cpp @@ -17,7 +17,7 @@ #include -// TODO: Add test cases with auxiliary indices +// TODO: Add test cases with aux indices TEST_CASE("Canonicalizer", "[algorithms]") { using namespace sequant; diff --git a/tests/unit/test_parse.cpp b/tests/unit/test_parse.cpp index 8c55b1b88..27383aeaf 100644 --- a/tests/unit/test_parse.cpp +++ b/tests/unit/test_parse.cpp @@ -88,7 +88,7 @@ TEST_CASE("parse_expr", "[parse]") { REQUIRE(expr->is()); REQUIRE(expr->as().bra().empty()); REQUIRE(expr->as().ket().empty()); - REQUIRE(expr->as().auxiliary().empty()); + REQUIRE(expr->as().aux().empty()); REQUIRE(expr == parse_expr(L"t{;}")); REQUIRE(expr == parse_expr(L"t{;;}")); @@ -103,7 +103,7 @@ TEST_CASE("parse_expr", "[parse]") { REQUIRE(expr->as().bra().at(0).label() == L"i_1"); REQUIRE(expr->as().ket().size() == 1); REQUIRE(expr->as().ket().at(0) == L"a_1"); - REQUIRE(expr->as().auxiliary().empty()); + REQUIRE(expr->as().aux().empty()); REQUIRE(expr == parse_expr(L"t_{i1}^{a1}")); REQUIRE(expr == parse_expr(L"t^{a1}_{i1}")); @@ -118,7 +118,7 @@ TEST_CASE("parse_expr", "[parse]") { REQUIRE(expr->as().ket().size() == 2); REQUIRE(expr->as().ket().at(0).label() == L"a_1"); REQUIRE(expr->as().ket().at(1).label() == L"a_2"); - REQUIRE(expr->as().auxiliary().empty()); + REQUIRE(expr->as().aux().empty()); REQUIRE(expr == parse_expr(L"+t{i1, i2; a1, a2}")); REQUIRE(parse_expr(L"-t{i1;a1}")->is()); @@ -150,8 +150,8 @@ TEST_CASE("parse_expr", "[parse]") { REQUIRE(expr->is()); REQUIRE(expr->as().bra().empty()); REQUIRE(expr->as().ket().empty()); - REQUIRE(expr->as().auxiliary().size() == 1); - REQUIRE(expr->as().auxiliary()[0].label() == L"i_1"); + REQUIRE(expr->as().aux().size() == 1); + REQUIRE(expr->as().aux()[0].label() == L"i_1"); // All index groups at once expr = parse_expr(L"t{i1,i2;a1;x1,x2}"); @@ -161,9 +161,9 @@ TEST_CASE("parse_expr", "[parse]") { REQUIRE(expr->as().bra().at(1).label() == L"i_2"); REQUIRE(expr->as().ket().size() == 1); REQUIRE(expr->as().ket().at(0).label() == L"a_1"); - REQUIRE(expr->as().auxiliary().size() == 2); - REQUIRE(expr->as().auxiliary().at(0).label() == L"x_1"); - REQUIRE(expr->as().auxiliary().at(1).label() == L"x_2"); + REQUIRE(expr->as().aux().size() == 2); + REQUIRE(expr->as().aux().at(0).label() == L"x_1"); + REQUIRE(expr->as().aux().at(1).label() == L"x_2"); } SECTION("Tensor with symmetry annotation") { diff --git a/tests/unit/test_tensor.cpp b/tests/unit/test_tensor.cpp index a9f526b77..5a33174cf 100644 --- a/tests/unit/test_tensor.cpp +++ b/tests/unit/test_tensor.cpp @@ -32,7 +32,7 @@ TEST_CASE("Tensor", "[elements]") { REQUIRE(!t1); REQUIRE(t1.bra_rank() == 0); REQUIRE(t1.ket_rank() == 0); - REQUIRE(t1.auxiliary_rank() == 0); + REQUIRE(t1.aux_rank() == 0); REQUIRE(t1.rank() == 0); REQUIRE(t1.symmetry() == Symmetry::invalid); REQUIRE(t1.braket_symmetry() == BraKetSymmetry::invalid); @@ -44,7 +44,7 @@ TEST_CASE("Tensor", "[elements]") { REQUIRE(t2); REQUIRE(t2.bra_rank() == 1); REQUIRE(t2.ket_rank() == 1); - REQUIRE(t2.auxiliary_rank() == 0); + REQUIRE(t2.aux_rank() == 0); REQUIRE(t2.rank() == 1); REQUIRE(t2.const_indices().size() == 2); REQUIRE(t2.symmetry() == Symmetry::nonsymm); @@ -57,7 +57,7 @@ TEST_CASE("Tensor", "[elements]") { REQUIRE(t3); REQUIRE(t3.bra_rank() == 1); REQUIRE(t3.ket_rank() == 0); - REQUIRE(t3.auxiliary_rank() == 1); + REQUIRE(t3.aux_rank() == 1); REQUIRE_THROWS(t3.rank()); REQUIRE(t3.const_indices().size() == 2); REQUIRE(t3.symmetry() == Symmetry::nonsymm); @@ -76,7 +76,7 @@ TEST_CASE("Tensor", "[elements]") { REQUIRE(t4); REQUIRE(t4.bra_rank() == 2); REQUIRE(t4.ket_rank() == 2); - REQUIRE(t4.auxiliary_rank() == 1); + REQUIRE(t4.aux_rank() == 1); REQUIRE(t4.rank() == 2); REQUIRE(t4.const_indices().size() == 5); REQUIRE(t4.symmetry() == Symmetry::nonsymm);