Skip to content

Instantly share code, notes, and snippets.

@davidmerwin
Last active November 24, 2023 07:28
Show Gist options
  • Save davidmerwin/c1929643fd4e3a37cc0fd8f22b4fdcd2 to your computer and use it in GitHub Desktop.
Save davidmerwin/c1929643fd4e3a37cc0fd8f22b4fdcd2 to your computer and use it in GitHub Desktop.

TypeScript Snippet

Preview:
constructor(
    initial_num_moments: number,
    symbols: SymbolInformation[],
    padding_factor = 1
  ) {
    super();
    this.padding_factor = padding_factor;
    this.qubit_map = new Map();

    for (const symbol of symbols) {
      // Being accurate is more important than speed here, so
      // traversing through each object isn't a big deal.
      // However, this logic can be changed if needed to avoid redundancy.
      for (const coordinate of symbol.location_info) {
        // If the key already exists in the map, don't repeat.
        if (this.hasQubit(coordinate.row, coordinate.col)) {
          continue;
        }
        this.addQubit(coordinate.row, coordinate.col, initial_num_moments);
      }
      this.addSymbol(symbol, initial_num_moments);
    }
  }
Associated Context
Type Code Snippet ( .ts )
Associated Tags cirq
Description 'No Description Provided'
Related Links https://github.com/davidmerwin
http://quantumai.google/cirq
Related People David Merwin, David Jeffrey Merwin, CIRQ
Sensitive Information No Sensitive Information Detected
Shareable Link https://davidmerwin.pieces.cloud/?p=d9df4fb4e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment