Skip to content

Commit abf3f54

Browse files
committed
Added self.matvec and self.rmatvec in torch_op
1 parent 69eb204 commit abf3f54

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pylops/torchoperator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ def __init__(
7676

7777
def _register_torchop(self, batch: bool):
7878
# choose _matvec and _rmatvec
79-
self._hmatvec: Callable
80-
self._hrmatvec: Callable
79+
self.matvec: Callable
80+
self.rmatvec: Callable
8181
if not batch:
82-
self._hmatvec = lambda x: self.Op @ x
83-
self._hrmatvec = lambda x: self.Op.H @ x
82+
self.matvec = lambda x: self.Op @ x
83+
self.rmatvec = lambda x: self.Op.H @ x
8484
else:
85-
self._hmatvec = lambda x: (self.Op @ x.transpose(self.transpf)).transpose(self.transpb)
86-
self._hrmatvec = lambda x: (self.Op.H @ x.transpose(self.transpf)).transpose(self.transpb)
85+
self.matvec = lambda x: (self.Op @ x.transpose(self.transpf)).transpose(self.transpb)
86+
self.rmatvec = lambda x: (self.Op.H @ x.transpose(self.transpf)).transpose(self.transpb)
8787

8888
def _matvec(self, x: NDArray) -> NDArray:
89-
return self._hmatvec(x)
89+
return self.matvec(x)
9090

9191
def _rmatvec(self, x: NDArray) -> NDArray:
92-
return self._hrmatvec(x)
92+
return self.rmatvec(x)
9393

9494
def apply(self, x: TensorTypeLike) -> TensorTypeLike:
9595
"""Apply forward pass to input vector
@@ -105,4 +105,4 @@ def apply(self, x: TensorTypeLike) -> TensorTypeLike:
105105
Output array resulting from the application of the operator to ``x``.
106106
107107
"""
108-
return self.Top(x, self._hmatvec, self._hrmatvec, self.device, self.devicetorch)
108+
return self.Top(x, self.matvec, self.rmatvec, self.device, self.devicetorch)

0 commit comments

Comments
 (0)