Qx.Draw.Tables (Qx - Quantum Computing Simulator v0.5.0)

View Source

State table formatting for quantum registers and state vectors.

This module provides functions for displaying quantum states in tabular format, showing basis states with their amplitudes and probabilities. Supports multiple output formats:

  • :auto - Auto-detects LiveBook/Kino and chooses best format
  • :text - Plain text table with ASCII formatting
  • :html - HTML table with styling
  • :markdown - Markdown table (with Kino support in LiveBook)

Internal Module

This module is part of the Qx.Draw refactoring and should be accessed through the public Qx.Draw API rather than directly.

Summary

Functions

Displays a quantum state as a formatted table.

Functions

render(register_or_state, options \\ [])

Displays a quantum state as a formatted table.

Shows basis states with their complex amplitudes and probabilities.

Parameters

  • register_or_state - Either a Qx.Register struct or an Nx.Tensor state vector
  • options - Keyword list of options

Options

  • :format - Output format (:auto, :text, :html, :markdown) (default: :auto)
  • :precision - Number of decimal places for floats (default: 3)
  • :hide_zeros - Hide states with near-zero probability (default: false)

Returns

Formatted table as string or Kino.Markdown struct (if in LiveBook).

Examples

# Display register state
register = Qx.Register.new(2)
Qx.Draw.Tables.render(register)

# Custom format
Qx.Draw.Tables.render(register, format: :html, precision: 4)

# Hide negligible amplitudes
Qx.Draw.Tables.render(register, hide_zeros: true)