Function sequant::parse_expr

Function Documentation

ExprPtr sequant::parse_expr(std::wstring_view raw, Symmetry tensor_sym = Symmetry::nonsymm)
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.

  • tensor_sym – The symmetry of all atomic tensors in the 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.