-
Notifications
You must be signed in to change notification settings - Fork 55
/
staticarbitraryop.py
47 lines (38 loc) · 2.38 KB
/
staticarbitraryop.py
1
2
3
4
5
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
"""
The StaticArbitraryOp class and supporting functionality.
"""
#***************************************************************************************************
# Copyright 2015, 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
# Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights
# in this software.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0 or in the LICENSE file in the root pyGSTi directory.
#***************************************************************************************************
import numpy as _np
from pygsti.modelmembers.operations.denseop import DenseOperator as _DenseOperator
from pygsti.modelmembers.errorgencontainer import NoErrorGeneratorInterface as _NoErrorGeneratorInterface
class StaticArbitraryOp(_DenseOperator, _NoErrorGeneratorInterface):
"""
An operation matrix that is completely fixed, or "static" (i.e. that posesses no parameters).
Parameters
----------
m : array_like or LinearOperator
a square 2D array-like or LinearOperator object representing the operation action.
The shape of m sets the dimension of the operation.
evotype : Evotype or str, optional
The evolution type. The special value `"default"` is equivalent
to specifying the value of `pygsti.evotypes.Evotype.default_evotype`.
state_space : StateSpace, optional
The state space for this operation. If `None` a default state space
with the appropriate number of qubits is used.
"""
def __init__(self, m, evotype="default", state_space=None):
_DenseOperator.__init__(self, m, evotype, state_space)
#(default DenseOperator/LinearOperator methods implement an object with no parameters)
def _is_similar(self, other, rtol, atol):
""" Returns True if `other` model member (which it guaranteed to be the same type as self) has
the same local structure, i.e., not considering parameter values or submembers """
# static objects must also test their values in is_similar, since these aren't parameters.
return (super()._is_similar(other, rtol, atol)
and _np.allclose(self.to_dense(), other.to_dense(), rtol=rtol, atol=atol))