Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimension overhaul #1826

Closed
wants to merge 26 commits into from
Closed

Dimension overhaul #1826

wants to merge 26 commits into from

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented Mar 8, 2022

Description

This is an overhaul of the dimensions based on the proposition by @jakelishman in #1476.
As proposed, dimension objects singleton instances composed of map and spaces.

Dimensions used by Qobj are all represented by a map between 2 spaces:

  • ket: Dimensions(Field, Space)
  • bra: Dimensions(Space, Field)
  • oper: Dimensions(Space, Space)
    ...

This Dimension is the Map proposed by Jake, but ket are map from Field to Space and not Spacethemselves. Spaces come into multiple sub classes as proposed :Space, SuperSpace, Field, Compound, and EnrSpace. Splitting maps and spaces simplify spaces by not needing to have a dummy 2nd dims : Space()[1]` does exist.

Dimensions can be initiated from a list and converted back to one. Field are automatically contracted: Compound(Field, Field) is a Field, same for maps. With the exceptions that Qobj with a shape of (1,1) with be a Dimensions(Field, Field) and not a Field.

Some previously valid and used list format are no longer accepted. Playing with of tensor of super operators, permute and reshuffle, you could make object with dims as [[[2, 2], [3, 3], [4, 4]], [[2, 2], [3, 3], [4, 4]]] which can be interpreted as the tensor of 3 super operators. But then [[[2, 2], [3, 3]], [[2, 2],[3, 3]]] can both be interpreted as tensor of super operator or super operator of tensor spaces, so :

  • [[[2, 2], [3, 3], [4, 4]], [[2, 2], [3, 3], [4, 4]]]: Error
  • [[[2, 2], [4, 4]], [[2, 2], [4, 4]]]: list representation of dimensions of to_super(tensor(oper, oper))
  • [[[2], [2], [3], [3]], [[2], [2], [3], [3]]]: list representation of dimensions of tensor(to_super(oper), to_super(oper))

Dimensions object have a type and shape set a initialization. There is a check when creating/ modifying a Qobj with between the data's shape and dims's shape and an error is raise when they are not matching.

Since operator-ket have a superrep, I added the superrep parameter to the Superspace instead of the dimensions, for now. But a better look at super operator representation is needed.

At the present state, Qobj.dims take and return a list, keeping the dimension object internally. From there, minimal adjustment were made so test pass.

The eigenstate fix in #1820 is already merged since it would create Qobj which dims and shape did not match.

ToDo:

  • Tensor using dimension directly instead of list.
  • QobjEvo.dims use dimension object.
  • state and operator accept dimension.
  • Super operator representation.
  • Ptrace, partial_transpose and permute use dimension object (supported with enr states).
  • Flags / new types for rectangular operator?
  • List dimension manipulation function in dimension.py should support the class/ be integrated in it / removed.

Related issues or PRs
#1476

Changelog

@Ericgig Ericgig changed the title Dimension Dimension overhaul Mar 8, 2022
@coveralls
Copy link

coveralls commented Mar 8, 2022

Coverage Status

Coverage increased (+0.3%) to 65.978% when pulling 0af50ac on Ericgig:dimension into d240c4c on qutip:dev.major.

@hodgestar hodgestar added this to the QuTiP 5.0 milestone Apr 8, 2022
@Ericgig Ericgig mentioned this pull request Sep 19, 2022
@Ericgig Ericgig closed this Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants