jaxquantum
jaxquantum
Qarray
Source code in jaxquantum/core/qarray.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
header
property
Print the header of the Qarray.
__deepcopy__(memo)
Need to override this when defininig getattr.
Source code in jaxquantum/core/qarray.py
444 445 446 447 448 449 450 451 |
|
__len__()
Length of the Qarray.
Source code in jaxquantum/core/qarray.py
260 261 262 263 264 265 |
|
__truediv__(other)
For Qarray's, this only really makes sense in the context of division by a scalar.
Source code in jaxquantum/core/qarray.py
328 329 330 331 332 333 334 |
|
from_array(qarr_arr)
classmethod
Create a Qarray from a nested list of Qarrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr_arr
|
list
|
nested list of Qarrays |
required |
Returns:
Name | Type | Description |
---|---|---|
Qarray |
Qarray
|
Qarray object |
Source code in jaxquantum/core/qarray.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
from_list(qarr_list)
classmethod
Create a Qarray from a list of Qarrays.
Source code in jaxquantum/core/qarray.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
reshape_bdims(*args)
Reshape the batch dimensions of the Qarray.
Source code in jaxquantum/core/qarray.py
202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
reshape_qdims(*args)
Reshape the quantum dimensions of the Qarray.
Note that this does not take in qdims but rather the new Hilbert space dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
new Hilbert dimensions for the Qarray. |
()
|
Returns:
Name | Type | Description |
---|---|---|
Qarray |
reshaped Qarray. |
Source code in jaxquantum/core/qarray.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
resize(new_shape)
Resize the Qarray to a new shape.
TODO: review and maybe deprecate this method.
Source code in jaxquantum/core/qarray.py
248 249 250 251 252 253 254 255 256 257 258 |
|
QuantumStateTomography
Source code in jaxquantum/core/measurements.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
__init__(rho_guess, measurement_basis, measurement_results, complete_basis=None, true_rho=None)
Reconstruct a quantum state from measurement results using quantum state tomography. The tomography can be performed either by direct inversion or by maximum likelihood estimation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rho_guess
|
Qarray
|
The initial guess for the quantum state. |
required |
measurement_basis
|
Qarray
|
The basis in which measurements are performed. |
required |
measurement_results
|
ndarray
|
The results of the measurements. |
required |
complete_basis
|
Optional[Qarray]
|
The complete basis for state |
None
|
true_rho
|
Optional[Qarray]
|
The true quantum state, if known. |
None
|
Source code in jaxquantum/core/measurements.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
quantum_state_tomography_direct()
Perform quantum state tomography using direct inversion.
This method reconstructs the quantum state from measurement results by directly solving a system of linear equations. The method assumes that the measurement basis is complete and the measurement results are noise-free.
Returns:
Name | Type | Description |
---|---|---|
Qarray |
Qarray
|
Reconstructed quantum state. |
Source code in jaxquantum/core/measurements.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
quantum_state_tomography_mle(L1_reg_strength=0.0, epochs=10000, lr=0.005)
Perform quantum state tomography using maximum likelihood estimation (MLE).
This method reconstructs the quantum state from measurement results by optimizing a likelihood function using gradient descent. The optimization ensures the resulting density matrix is positive semi-definite with trace 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L1_reg_strength
|
float
|
Strength of L1 |
0.0
|
epochs
|
int
|
Number of optimization iterations. |
10000
|
lr
|
float
|
Learning rate for the Adam optimizer. |
0.005
|
Returns:
Name | Type | Description |
---|---|---|
MLETomographyResult |
MLETomographyResult
|
Named tuple containing: - rho: Reconstructed quantum state as Qarray - params_history: List of parameter values during optimization - loss_history: List of loss values during optimization - grads_history: List of gradient values during optimization - infidelity_history: List of infidelities if true_rho was provided, None otherwise |
Source code in jaxquantum/core/measurements.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
basis(N, k)
Creates a |k> (i.e. fock state) ket in a specified Hilbert Space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
int
|
Hilbert space dimension |
required |
k
|
int
|
fock number |
required |
Returns:
Type | Description |
---|---|
Fock State |k> |
Source code in jaxquantum/core/operators.py
162 163 164 165 166 167 168 169 170 171 172 |
|
basis_like(A, ks)
Creates a |k> (i.e. fock state) ket with the same space dims as A.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
Qarray
|
state or operator. |
required |
k
|
fock number. |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Fock State |k> with the same space dims as A. |
Source code in jaxquantum/core/operators.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
cf_wigner(psi, xvec, yvec)
Wigner function for a state vector or density matrix at points
xvec + i * yvec
.
Parameters
Qarray
A state vector or density matrix.
array_like
x-coordinates at which to calculate the Wigner function.
array_like
y-coordinates at which to calculate the Wigner function.
Returns
array
Values representing the Wigner function calculated over the specified range [xvec,yvec].
Source code in jaxquantum/core/cfunctions.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
coherent(N, α)
Coherent state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
int
|
Hilbert Space Size. |
required |
α
|
complex
|
coherent state amplitude. |
required |
Return
Coherent state |α⟩.
Source code in jaxquantum/core/operators.py
188 189 190 191 192 193 194 195 196 197 198 |
|
collapse(qarr, mode='sum')
Collapse the Qarray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array array |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Collapsed quantum array |
Source code in jaxquantum/core/qarray.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
|
comb(N, k)
NCk
TODO: replace with jsp.special.comb once issue is closed:
https://github.com/google/jax/issues/9709
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
total items |
required | |
k
|
of items to choose |
required |
Returns:
Name | Type | Description |
---|---|---|
NCk |
N choose k |
Source code in jaxquantum/utils/utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
concatenate(qarr_list, axis=0)
Concatenate a list of Qarrays along a specified axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr_list
|
List[Qarray]
|
List of Qarrays to concatenate. |
required |
axis
|
int
|
Axis along which to concatenate. Default is 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
Qarray |
Qarray
|
Concatenated Qarray. |
Source code in jaxquantum/core/qarray.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
cosm(qarr)
Matrix cosine wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Qarray
|
matrix cosine |
Source code in jaxquantum/core/qarray.py
781 782 783 784 785 786 787 788 789 790 791 792 |
|
cosm_data(data, **kwargs)
Matrix cosine wrapper.
Returns:
Type | Description |
---|---|
Array
|
matrix cosine |
Source code in jaxquantum/core/qarray.py
772 773 774 775 776 777 778 |
|
create(N)
creation operator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
Hilbert space size |
required |
Returns:
Type | Description |
---|---|
Qarray
|
creation operator in Hilber Space of size N |
Source code in jaxquantum/core/operators.py
98 99 100 101 102 103 104 105 106 107 |
|
dag(qarr)
Conjugate transpose.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Qarray
|
conjugate transpose of qarr |
Source code in jaxquantum/core/qarray.py
913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
|
dag_data(arr)
Conjugate transpose.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
Array
|
operator |
required |
Returns:
Type | Description |
---|---|
Array
|
conjugate of op, and transposes last two axes |
Source code in jaxquantum/core/qarray.py
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
|
destroy(N)
annihilation operator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
Hilbert space size |
required |
Returns:
Type | Description |
---|---|
Qarray
|
annilation operator in Hilber Space of size N |
Source code in jaxquantum/core/operators.py
86 87 88 89 90 91 92 93 94 95 |
|
displace(N, α)
Displacement operator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
Hilbert Space Size |
required | |
α
|
Phase space displacement |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Displace operator D(α) |
Source code in jaxquantum/core/operators.py
145 146 147 148 149 150 151 152 153 154 155 156 |
|
eigenenergies(qarr)
Eigenvalues of a quantum array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Array
|
eigenvalues |
Source code in jaxquantum/core/qarray.py
858 859 860 861 862 863 864 865 866 867 868 869 |
|
eigenstates(qarr)
Eigenstates of a quantum array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Qarray
|
eigenvalues and eigenstates |
Source code in jaxquantum/core/qarray.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
|
expm(qarr, **kwargs)
Matrix exponential wrapper.
Returns:
Type | Description |
---|---|
Qarray
|
matrix exponential |
Source code in jaxquantum/core/qarray.py
732 733 734 735 736 737 738 739 740 |
|
expm_data(data, **kwargs)
Matrix exponential wrapper.
Returns:
Type | Description |
---|---|
Array
|
matrix exponential |
Source code in jaxquantum/core/qarray.py
723 724 725 726 727 728 729 |
|
extract_dims(arr, dims=None)
Extract dims from a JAX array or Qarray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
Array
|
JAX array or Qarray. |
required |
dims
|
Optional[Union[DIMS_TYPE, List[int]]]
|
Qarray dims. |
None
|
Returns:
Type | Description |
---|---|
Qarray dims. |
Source code in jaxquantum/core/conversions.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
fidelity(rho, sigma, force_positivity=False)
Fidelity between two states.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rho
|
Qarray
|
state. |
required |
sigma
|
Qarray
|
state. |
required |
force_positivity
|
bool
|
force the states to be positive semidefinite |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
Fidelity between rho and sigma. |
Source code in jaxquantum/core/measurements.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
hadamard()
H
Returns:
Name | Type | Description |
---|---|---|
H |
Qarray
|
Hadamard gate |
Source code in jaxquantum/core/operators.py
42 43 44 45 46 47 48 |
|
identity(*args, **kwargs)
Identity matrix.
Returns:
Type | Description |
---|---|
Qarray
|
Identity matrix. |
Source code in jaxquantum/core/operators.py
122 123 124 125 126 127 128 |
|
identity_like(A)
Identity matrix with the same shape as A.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
Matrix. |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Identity matrix with the same shape as A. |
Source code in jaxquantum/core/operators.py
131 132 133 134 135 136 137 138 139 140 141 142 |
|
is_dm_data(data)
Check if data is a density matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Array
|
matrix |
required |
Returns: True if data is a density matrix
Source code in jaxquantum/core/qarray.py
970 971 972 973 974 975 976 977 978 |
|
jnp2jqt(arr, dims=None)
JAX array -> QuTiP state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jnp_obj
|
JAX array. |
required | |
dims
|
Optional[Union[DIMS_TYPE, List[int]]]
|
Qarray dims. |
None
|
Returns:
Type | Description |
---|---|
QuTiP state. |
Source code in jaxquantum/core/conversions.py
79 80 81 82 83 84 85 86 87 88 89 90 |
|
jqt2qt(jqt_obj)
Qarray -> QuTiP state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jqt_obj
|
Qarray. |
required | |
dims
|
QuTiP dims. |
required |
Returns:
Type | Description |
---|---|
QuTiP state. |
Source code in jaxquantum/core/conversions.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
ket2dm(qarr)
Turns ket into density matrix. Does nothing if already operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
qarr |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Density matrix |
Source code in jaxquantum/core/qarray.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
|
mesolve(H, rho0, tlist, saveat_tlist=None, c_ops=None, solver_options=None)
Quantum Master Equation solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
H
|
Union[Qarray, Callable[[float], Qarray]]
|
time dependent Hamiltonian function or time-independent Qarray. |
required |
rho0
|
Qarray
|
initial state, must be a density matrix. For statevector evolution, please use sesolve. |
required |
tlist
|
Array
|
time list |
required |
saveat_tlist
|
Optional[Array]
|
list of times at which to save the state. If None, save at all times in tlist. Default: None. |
None
|
c_ops
|
Optional[Qarray]
|
qarray list of collapse operators |
None
|
solver_options
|
Optional[SolverOptions]
|
SolverOptions with solver options |
None
|
Returns:
Type | Description |
---|---|
Qarray
|
list of states |
Source code in jaxquantum/core/solvers.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
multi_mode_basis_set(Ns)
Creates a multi-mode basis set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Ns
|
List[int]
|
List of Hilbert space dimensions for each mode. |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Multi-mode basis set. |
Source code in jaxquantum/core/operators.py
174 175 176 177 178 179 180 181 182 183 184 185 |
|
num(N)
Number operator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
Hilbert Space size |
required |
Returns:
Type | Description |
---|---|
Qarray
|
number operator in Hilber Space of size N |
Source code in jaxquantum/core/operators.py
110 111 112 113 114 115 116 117 118 119 |
|
overlap(rho, sigma)
Overlap between two states or operators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rho
|
Qarray
|
state/operator. |
required |
sigma
|
Qarray
|
state/operator. |
required |
Returns:
Type | Description |
---|---|
Array
|
Overlap between rho and sigma. |
Source code in jaxquantum/core/measurements.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
plot_cf(state, pts_x, pts_y=None, axs=None, contour=True, qp_type=WIGNER, cbar_label='', axis_scale_factor=1, plot_cbar=True, x_ticks=None, y_ticks=None, z_ticks=None, subtitles=None, figtitle=None)
Plot characteristic function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
state with arbitrary number of batch dimensions, result will |
required | |
pts_x
|
x points to evaluate quasi-probability distribution at |
required | |
pts_y
|
y points to evaluate quasi-probability distribution at |
None
|
|
axs
|
matplotlib axes to plot on |
None
|
|
contour
|
make the plot use contouring |
True
|
|
qp_type
|
type of quasi probability distribution ("wigner") |
WIGNER
|
|
cbar_label
|
labels for the real and imaginary cbar |
''
|
|
axis_scale_factor
|
scale of the axes labels relative |
1
|
|
plot_cbar
|
whether to plot cbar |
True
|
|
x_ticks
|
tick position for the x-axis |
None
|
|
y_ticks
|
tick position for the y-axis |
None
|
|
z_ticks
|
tick position for the z-axis |
None
|
|
subtitles
|
subtitles for the subplots |
None
|
|
figtitle
|
figure title |
None
|
Returns:
Type | Description |
---|---|
axis on which the plot was plotted. |
Source code in jaxquantum/core/visualization.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
plot_cf_wigner(state, pts_x, pts_y=None, axs=None, contour=True, cbar_label='', axis_scale_factor=1, plot_cbar=True, x_ticks=None, y_ticks=None, z_ticks=None, subtitles=None, figtitle=None)
Plot the Wigner characteristic function of the state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
state with arbitrary number of batch dimensions, result will |
required | |
pts_x
|
x points to evaluate quasi-probability distribution at |
required | |
pts_y
|
y points to evaluate quasi-probability distribution at |
None
|
|
axs
|
matplotlib axes to plot on |
None
|
|
contour
|
make the plot use contouring |
True
|
|
cbar_label
|
label for the cbar |
''
|
|
axis_scale_factor
|
scale of the axes labels relative |
1
|
|
plot_cbar
|
whether to plot cbar |
True
|
|
x_ticks
|
tick position for the x-axis |
None
|
|
y_ticks
|
tick position for the y-axis |
None
|
|
z_ticks
|
tick position for the z-axis |
None
|
|
subtitles
|
subtitles for the subplots |
None
|
|
figtitle
|
figure title |
None
|
Returns:
Type | Description |
---|---|
axis on which the plot was plotted. |
Source code in jaxquantum/core/visualization.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|
plot_qfunc(state, pts_x, pts_y=None, g=2, axs=None, contour=True, cbar_label='', axis_scale_factor=1, plot_cbar=True, x_ticks=None, y_ticks=None, z_ticks=None, subtitles=None, figtitle=None)
Plot the husimi function of the state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
state with arbitrary number of batch dimensions, result will |
required | |
pts_x
|
x points to evaluate quasi-probability distribution at |
required | |
pts_y
|
y points to evaluate quasi-probability distribution at |
None
|
|
g
|
float, default: 2 |
2
|
|
related
|
to the value of
|
math: |
required |
|
math: |
required | |
axs
|
matplotlib axes to plot on |
None
|
|
contour
|
make the plot use contouring |
True
|
|
cbar_label
|
label for the cbar |
''
|
|
axis_scale_factor
|
scale of the axes labels relative |
1
|
|
plot_cbar
|
whether to plot cbar |
True
|
|
x_ticks
|
tick position for the x-axis |
None
|
|
y_ticks
|
tick position for the y-axis |
None
|
|
z_ticks
|
tick position for the z-axis |
None
|
|
subtitles
|
subtitles for the subplots |
None
|
|
figtitle
|
figure title |
None
|
Returns:
Type | Description |
---|---|
axis on which the plot was plotted. |
Source code in jaxquantum/core/visualization.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
plot_qp(state, pts_x, pts_y=None, g=2, axs=None, contour=True, qp_type=WIGNER, cbar_label='', axis_scale_factor=1, plot_cbar=True, x_ticks=None, y_ticks=None, z_ticks=None, subtitles=None, figtitle=None)
Plot quasi-probability distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
state with arbitrary number of batch dimensions, result will |
required | |
pts_x
|
x points to evaluate quasi-probability distribution at |
required | |
pts_y
|
y points to evaluate quasi-probability distribution at |
None
|
|
g
|
float, default: 2 |
2
|
|
related
|
to the value of
|
math: |
required |
|
math: |
required | |
axs
|
matplotlib axes to plot on |
None
|
|
contour
|
make the plot use contouring |
True
|
|
qp_type
|
type of quasi probability distribution ("wigner", "qfunc") |
WIGNER
|
|
cbar_label
|
label for the cbar |
''
|
|
axis_scale_factor
|
scale of the axes labels relative |
1
|
|
plot_cbar
|
whether to plot cbar |
True
|
|
x_ticks
|
tick position for the x-axis |
None
|
|
y_ticks
|
tick position for the y-axis |
None
|
|
z_ticks
|
tick position for the z-axis |
None
|
|
subtitles
|
subtitles for the subplots |
None
|
|
figtitle
|
figure title |
None
|
Returns:
Type | Description |
---|---|
axis on which the plot was plotted. |
Source code in jaxquantum/core/visualization.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
plot_wigner(state, pts_x, pts_y=None, g=2, axs=None, contour=True, cbar_label='', axis_scale_factor=1, plot_cbar=True, x_ticks=None, y_ticks=None, z_ticks=None, subtitles=None, figtitle=None)
Plot the wigner function of the state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
state with arbitrary number of batch dimensions, result will |
required | |
pts_x
|
x points to evaluate quasi-probability distribution at |
required | |
pts_y
|
y points to evaluate quasi-probability distribution at |
None
|
|
g
|
float, default: 2 |
2
|
|
related
|
to the value of
|
math: |
required |
|
math: |
required | |
axs
|
matplotlib axes to plot on |
None
|
|
contour
|
make the plot use contouring |
True
|
|
cbar_label
|
label for the cbar |
''
|
|
axis_scale_factor
|
scale of the axes labels relative |
1
|
|
plot_cbar
|
whether to plot cbar |
True
|
|
x_ticks
|
tick position for the x-axis |
None
|
|
y_ticks
|
tick position for the y-axis |
None
|
|
z_ticks
|
tick position for the z-axis |
None
|
|
subtitles
|
subtitles for the subplots |
None
|
|
figtitle
|
figure title |
None
|
Returns:
Type | Description |
---|---|
axis on which the plot was plotted. |
Source code in jaxquantum/core/visualization.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
powm(qarr, n, clip_eigvals=False)
Matrix power.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
n
|
int
|
power |
required |
clip_eigvals
|
bool
|
clip eigenvalues to always be able to compute |
False
|
Returns:
Type | Description |
---|---|
Qarray
|
matrix power |
Source code in jaxquantum/core/qarray.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
|
powm_data(data, n)
Matrix power.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Array
|
matrix |
required |
n
|
int
|
power |
required |
Returns:
Type | Description |
---|---|
Array
|
matrix power |
Source code in jaxquantum/core/qarray.py
981 982 983 984 985 986 987 988 989 990 991 |
|
propagator(H, ts, solver_options=None)
Generate the propagator for a time dependent Hamiltonian.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
H
|
Qarray or callable
|
A Qarray static Hamiltonian OR a function that takes a time argument and returns a Hamiltonian. |
required |
ts
|
float or Array
|
A single time point or an Array of time points. |
required |
Returns:
Type | Description |
---|---|
Qarray or List[Qarray]: The propagator for the Hamiltonian at time t. OR a list of propagators for the Hamiltonian at each time in t. |
Source code in jaxquantum/core/solvers.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
ptrace(qarr, indx)
Partial Trace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rho
|
density matrix |
required | |
indx
|
index of quantum object to keep, rest will be partial traced out |
required |
Returns:
Type | Description |
---|---|
Qarray
|
partial traced out density matrix |
TODO: Fix weird tracing errors that arise with reshape
Source code in jaxquantum/core/qarray.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
|
qfunc(psi, xvec, yvec, g=2)
Husimi-Q function of a given state vector or density matrix at phase-space
points 0.5 * g * (xvec + i*yvec)
.
Parameters
state : Qarray A state vector or density matrix. This cannot have tensor-product structure.
xvec, yvec : array_like x- and y-coordinates at which to calculate the Husimi-Q function.
float, default: 2
Scaling factor for a = 0.5 * g * (x + iy)
. The value of g
is
related to the value of :math:\hbar
in the commutation relation
:math:[x,\,y] = i\hbar
via :math:\hbar=2/g^2
.
Returns
jnp.ndarray
Values representing the Husimi-Q function calculated over the specified
range [xvec, yvec]
.
Source code in jaxquantum/core/qp_distributions.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
qt2jqt(qt_obj, dtype=jnp.complex128)
QuTiP state -> Qarray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qt_obj
|
QuTiP state. |
required | |
dtype
|
JAX dtype. |
complex128
|
Returns:
Type | Description |
---|---|
Qarray. |
Source code in jaxquantum/core/conversions.py
22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
qubit_rotation(theta, nx, ny, nz)
Single qubit rotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta
|
float
|
rotation angle. |
required |
nx
|
rotation axis x component. |
required | |
ny
|
rotation axis y component. |
required | |
nz
|
rotation axis z component. |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Single qubit rotation operator. |
Source code in jaxquantum/core/operators.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
sesolve(H, rho0, tlist, saveat_tlist=None, solver_options=None)
Schrödinger Equation solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
H
|
Union[Qarray, Callable[[float], Qarray]]
|
time dependent Hamiltonian function or time-independent Qarray. |
required |
rho0
|
Qarray
|
initial state, must be a density matrix. For statevector evolution, please use sesolve. |
required |
tlist
|
Array
|
time list |
required |
saveat_tlist
|
Optional[Array]
|
list of times at which to save the state. If None, save at all times in tlist. Default: None. |
None
|
solver_options
|
Optional[SolverOptions]
|
SolverOptions with solver options |
None
|
Returns:
Type | Description |
---|---|
Qarray
|
list of states |
Source code in jaxquantum/core/solvers.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
sigmam()
σ-
Returns:
Type | Description |
---|---|
Qarray
|
σ- Pauli Operator |
Source code in jaxquantum/core/operators.py
51 52 53 54 55 56 57 |
|
sigmap()
σ+
Returns:
Type | Description |
---|---|
Qarray
|
σ+ Pauli Operator |
Source code in jaxquantum/core/operators.py
60 61 62 63 64 65 66 |
|
sigmax()
σx
Returns:
Type | Description |
---|---|
Qarray
|
σx Pauli Operator |
Source code in jaxquantum/core/operators.py
15 16 17 18 19 20 21 |
|
sigmay()
σy
Returns:
Type | Description |
---|---|
Qarray
|
σy Pauli Operator |
Source code in jaxquantum/core/operators.py
24 25 26 27 28 29 30 |
|
sigmaz()
σz
Returns:
Type | Description |
---|---|
Qarray
|
σz Pauli Operator |
Source code in jaxquantum/core/operators.py
33 34 35 36 37 38 39 |
|
sinm_data(data, **kwargs)
Matrix sine wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Array
|
matrix |
required |
Returns:
Type | Description |
---|---|
Array
|
matrix sine |
Source code in jaxquantum/core/qarray.py
795 796 797 798 799 800 801 802 803 804 |
|
solve(f, ρ0, tlist, saveat_tlist, args, solver_options=None)
Gets teh desired solver from diffrax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solver_options
|
Optional[SolverOptions]
|
dictionary with solver options |
None
|
Returns:
Type | Description |
---|---|
solution |
Source code in jaxquantum/core/solvers.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
tensor(*args, **kwargs)
Tensor product.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Qarray
|
tensors to take the product of |
()
|
parallel
|
bool
|
if True, use parallel einsum for tensor product true: [A,B] ^ [C,D] = [A^C, B^D] false (default): [A,B] ^ [C,D] = [A^C, A^D, B^C, B^D] |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Tensor product of given tensors |
Source code in jaxquantum/core/qarray.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
|
tensor_basis(single_basis, n)
Construct n-fold tensor product basis from a single-system basis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
single_basis
|
Qarray
|
The single-system operator basis as a Qarray. |
required |
n
|
int
|
Number of tensor copies to construct. |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Qarray containing the n-fold tensor product basis operators. |
Qarray
|
The resulting basis has b^n elements where b is the number |
Qarray
|
of operators in the single-system basis. |
Source code in jaxquantum/core/measurements.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
thermal(N, beta)
Thermal state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
int
|
Hilbert Space Size. |
required |
beta
|
float
|
thermal state inverse temperature. |
required |
Return
Thermal state.
Source code in jaxquantum/core/operators.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
tr(qarr, **kwargs)
Full trace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Array
|
Full trace. |
Source code in jaxquantum/core/qarray.py
697 698 699 700 701 702 703 704 705 706 707 708 |
|
trace(qarr, **kwargs)
Full trace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Array
|
Full trace. |
Source code in jaxquantum/core/qarray.py
711 712 713 714 715 716 717 718 719 720 |
|
transpose(qarr, indices)
Transpose the quantum array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
*args
|
axes to transpose |
required |
Returns:
Type | Description |
---|---|
Qarray
|
tranposed Qarray |
Source code in jaxquantum/core/qarray.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
|
unit(qarr)
Normalize the quantum array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qarr
|
Qarray
|
quantum array |
required |
Returns:
Type | Description |
---|---|
Qarray
|
Normalized quantum array |
Source code in jaxquantum/core/qarray.py
624 625 626 627 628 629 630 631 632 633 634 635 |
|
wigner(psi, xvec, yvec, method='clenshaw', g=2)
Wigner function for a state vector or density matrix at points
xvec + i * yvec
.
Parameters
Qarray
A state vector or density matrix.
array_like
x-coordinates at which to calculate the Wigner function.
array_like
y-coordinates at which to calculate the Wigner function.
float, default: 2
Scaling factor for a = 0.5 * g * (x + iy)
, default g = 2
.
The value of g
is related to the value of hbar
in the commutation
relation [x, y] = i * hbar
via hbar=2/g^2
.
string {'clenshaw', 'iterative', 'laguerre', 'fft'}, default: 'clenshaw'
Only 'clenshaw' is currently supported.
Select method 'clenshaw' 'iterative', 'laguerre', or 'fft', where 'clenshaw'
and 'iterative' use an iterative method to evaluate the Wigner functions for density
matrices :math:|m><n|
, while 'laguerre' uses the Laguerre polynomials
in scipy for the same task. The 'fft' method evaluates the Fourier
transform of the density matrix. The 'iterative' method is default, and
in general recommended, but the 'laguerre' method is more efficient for
very sparse density matrices (e.g., superpositions of Fock states in a
large Hilbert space). The 'clenshaw' method is the preferred method for
dealing with density matrices that have a large number of excitations
(>~50). 'clenshaw' is a fast and numerically stable method.
Returns
array
Values representing the Wigner function calculated over the specified range [xvec,yvec].
References
Ulf Leonhardt, Measuring the Quantum State of Light, (Cambridge University Press, 1997)
Source code in jaxquantum/core/qp_distributions.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|