Source code for cil.optimisation.operators.IdentityOperator
# Copyright 2019 United Kingdom Research and Innovation# Copyright 2019 The University of Manchester## 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## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.## Authors:# CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txtfromcil.optimisation.operatorsimportLinearOperatorimportscipy.sparseasspimportnumpyasnp
[docs]classIdentityOperator(LinearOperator):'''IdentityOperator: Id: X -> Y, Id(x) = x\in Y X : gm_domain Y : gm_range ( Default: Y = X ) '''def__init__(self,domain_geometry,range_geometry=None):ifrange_geometryisNone:range_geometry=domain_geometrysuper(IdentityOperator,self).__init__(domain_geometry=domain_geometry,range_geometry=range_geometry)
[docs]defcalculate_norm(self,**kwargs):'''Evaluates operator norm of IdentityOperator'''return1.0
########################################################################################## For preconditioning #################################################################################################################defmatrix(self):returnsp.eye(np.prod(self.gm_domain.shape))defsum_abs_row(self):returnself.gm_range.allocate(1)defsum_abs_col(self):returnself.gm_domain.allocate(1)