Function sequant::parse_expr

Function Documentation

ExprPtr sequant::parse_expr(std::wstring_view raw, std::optional<Symmetry> perm_symm = {}, std::optional<BraKetSymmetry> braket_symm = {}, std::optional<ParticleSymmetry> particle_symm = {})
Parameters:
  • raw – A tensor algebra expression. A valid expression is a product, a sum or a mix of those including parentheses. eg. ‘A{i1, a1; i2, a2}’ A is the label (non-space), i1, a1 are bra indices, i2, a2 are ket indices. ‘A{i_1, a_1; i_2, a_2}’ same as above with alternate notation for indices ‘A_{i1, a1}^{i2, a2}’ same as above with alternate notation for bra and ket ‘A^{i2, a2}_{i1, a1}’ same as above with alternate notation for bra and ket ‘A{i1,i2; a1,a2} + B{i2,i1; a1,a2}’ a sum of tensors ‘A{i1,i2; a3,a4} * B{a3,a4; a1,a2}’ a product of tensors ‘A{i1,i2; a3,a4} * B{a3,a4; a1,a2} + C{i1,i2;a1,a2}’ a sum and a product of tensors ‘A{i1,i2; a3,a4} * (B{a3,a4; a1,a2} + C{a3,a4; a1,a2}) a parenthesized expression ‘0.5 * t{i1;a1} * f{i1; a1}’ tensor product with a scalar ‘1/2 * t{i1;a1} * f{i1; a1}’ same as above (fractions supported) ‘1./2. * t{i1;a1} * f{i1; a1}’ same as above num. and denom. are automatically cast to double ‘1.0/2.0 * t{i1;a1} * f{i1; a1}’ same as above ‘t{i1,i2; a1<i1,i2>, a2<i1,i2>}’ a tensor having indices with proto indices. a1<i1,i2> is an index with i1 and i2 as proto-indices. Every tensor may optionally be annoted with index symmetry specifications. The general syntax is <tensorSpec> [:<perm symm> [-<braket symm> [-<particle symm>]]] (no whitespace is allowed at this place). Examples are ‘t{i1;i2}:A’, ‘t{i1;i2}:A-S’, ‘t{i1;i2}:N-C-S’ Possible values for <perm symm> are

  • perm_symm – Default index permutation symmetry to be used if tensors don’t specify a permutation symmetry explicitly.

  • braket_symm – Default BraKet symmetry to be used if tensors don’t specify a BraKet symmetry explicitly.

  • particle_symm – Default particle symmetry to be used if tensors don’t specify a particle symmetry explicitly. raw expression. Explicit tensor symmetry can be annotated in the expression itself. In that case, the annotated symmetry will be used. eg. ‘g{i1, a1; i2, a2}:A’ tensor with ‘sequant::Symmetry::antisymm’ annotation ‘g{i1, a1; i2, a2}:S’ tensor with ‘sequant::Symmetry::symm’ annotation ‘g{i1, a1; i2, a2}:N’ tensor with ‘sequant::Symmetry::nonsymm’ annotation

Returns:

SeQuant expression.