Main /
OperatorExpressionsOperators are used in many places in the toolkit. The syntax is lattice ':' expression important note: When using expressions on the command line, remember to enclose it in quotes, or the shell will interpret brackets, The parser understands complex arithmetic (for example, There are distinct functions available for constructing TriangularOperators and ProductOperators?. Exampleslattice:H^2 The square of an operator, equivalent to lattice:Sz(0)[0] * Sz(1)[0] A correlation between two unit cells lattice:Sz(0) * Sz(1) A nearest-neighbor correlation, where the unit cell size is 1 (or where Sz is defined as a unit cell operator) lattice:(exp(0.4i * pi) * Sz(1) + Sz(2))^2 + log(2) * Sz(3) A more complicated example. lattice:i * [H,A] Commutator brackets are allowed, both for finite operators and triangular operators. lattice:CH(1) * adjoint(CH(2)) + conj(Sz(3)) The lattice:inner(S(1), S(2)) The inner product of operators For {$SU(2)$} vector operators, there is also The The parser also understands
But care needs to be taken, since the implementation of Swap gates are defined. There are two forms,
is a 'bosonic' swap between site PrecedenceUnary + and - operators have highest precedence. Next precedence to the power operator ('^'), which associates right-to-left ( Multiplication and division have next highest precedence. Lowest precedence to binary + and -. FileGrid
The format of the file is the same as gnuplot 3D format. The X direction is the rows. The Y direction is the columns. The Z direction is blocks separated by an empty line. Example: $ cat testfile 0 2 1 3 10 30 20 40 $ mp-expectation psi lat:"filegrid(testfile,0.5,0.5,0.5) *I(0)" 13.25 The filename doesn't need to be quoted, but it cannot contain a comma. Also it shouldn't include whitespace at the start or end, since these are ignored. The contents of the file can contain numbers or an arbitrary expression, including an MPO. Currently function arguments don't work properly if filegrid is used in a function definition and it refers to arguments passed into the function. The elements of the file are separated by whitespace. To use expressions that contain spaces, you can use quotes, or backslash escapes. For example: $ cat testfile2 "2 * I(0)" "4 * I(0)" $ ./mp-expectation psi lat:"filegrid(testfile2,0.5)" 3 |