def test_incompatible_dimensions_raise(self): with self.test_session(): x = ops.convert_to_tensor(rng.rand(2, 4, 4)) operator = DomainDimensionStubOperator(3) with self.assertRaisesOpError("Incompatible matrix dimensions"): linear_operator_util.assert_compatible_matrix_dimensions( operator, x).run()
def test_incompatible_dimensions_raise(self): with self.test_session(): x = ops.convert_to_tensor(rng.rand(2, 4, 4)) operator = DomainDimensionStubOperator(3) with self.assertRaisesOpError("Incompatible matrix dimensions"): linear_operator_util.assert_compatible_matrix_dimensions( operator, x).run()
def test_compatible_dimensions_do_not_raise(self): with self.test_session(): x = ops.convert_to_tensor(rng.rand(2, 3, 4)) operator = DomainDimensionStubOperator(3) # Should not raise linear_operator_util.assert_compatible_matrix_dimensions( operator, x).run()
def test_compatible_dimensions_do_not_raise(self): with self.test_session(): x = ops.convert_to_tensor(rng.rand(2, 3, 4)) operator = DomainDimensionStubOperator(3) # Should not raise linear_operator_util.assert_compatible_matrix_dimensions( operator, x).run()
def _apply(self, x, adjoint=False): # Note that adjoint has no effect since this matrix is self-adjoint. if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions( self, x) x = control_flow_ops.with_dependencies([aps], x) return self._possibly_broadcast_batch_shape(x)
def _apply(self, x, adjoint=False): # Note that adjoint has no effect since this matrix is self-adjoint. if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions( self, x) x = control_flow_ops.with_dependencies([aps], x) return self._possibly_broadcast_batch_shape(x)
def _solve(self, rhs, adjoint=False): if adjoint: matrix = self._multiplier_matrix_conj else: matrix = self._multiplier_matrix if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions( self, rhs) rhs = control_flow_ops.with_dependencies([aps], rhs) return rhs / matrix
def _matmul(self, x, adjoint=False, adjoint_arg=False): x = linear_operator_util.matrix_adjoint(x) if adjoint_arg else x if adjoint: matrix = self._multiplier_matrix_conj else: matrix = self._multiplier_matrix if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions(self, x) x = control_flow_ops.with_dependencies([aps], x) return x * matrix
def _solve(self, rhs, adjoint=False): if adjoint: matrix = self._multiplier_matrix_conj else: matrix = self._multiplier_matrix if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions( self, rhs) rhs = control_flow_ops.with_dependencies([aps], rhs) return rhs / matrix
def _matmul(self, x, adjoint=False, adjoint_arg=False): x = linear_operator_util.matrix_adjoint(x) if adjoint_arg else x if adjoint: matrix = self._multiplier_matrix_conj else: matrix = self._multiplier_matrix if self._assert_proper_shapes: aps = linear_operator_util.assert_compatible_matrix_dimensions( self, x) x = control_flow_ops.with_dependencies([aps], x) return x * matrix