15
15
from odl .solvers .functional .functional import (Functional ,
16
16
FunctionalQuadraticPerturb )
17
17
from odl .space import ProductSpace
18
- from odl .set import RealNumbers #, ComplexNumbers
18
+ from odl .set import RealNumbers
19
19
from odl .operator import (Operator , ConstantOperator , ZeroOperator ,
20
20
ScalingOperator , DiagonalOperator , PointwiseNorm )
21
21
from odl .solvers .nonsmooth .proximal_operators import (
@@ -69,10 +69,13 @@ def __init__(self, domain, exponent, range=None):
69
69
Domain of the functional.
70
70
exponent : float
71
71
Exponent for the norm (``p``).
72
+ range : `Field`, optional
73
+ Range of the functional. The default `None` will be treated as
74
+ `RealNumbers`.
72
75
"""
73
76
if range is None and getattr (domain , 'is_complex' , False ):
74
77
range = RealNumbers ()
75
-
78
+
76
79
super (LpNorm , self ).__init__ (
77
80
domain = domain , linear = False , grad_lipschitz = np .nan , range = range )
78
81
self .exponent = float (exponent )
@@ -227,6 +230,9 @@ def __init__(self, vfspace, exponent=None, range=None):
227
230
0 and 1 are currently not supported due to numerical
228
231
instability. Infinity gives the supremum norm.
229
232
Default: ``vfspace.exponent``, usually 2.
233
+ range : `Field`, optional
234
+ Range of the functional. The default `None` will be treated as
235
+ `vfspace.field`.
230
236
231
237
Examples
232
238
--------
@@ -356,6 +362,9 @@ def __init__(self, vfspace, exponent=None, range=None):
356
362
0 and 1 are currently not supported due to numerical
357
363
instability. Infinity gives the supremum norm.
358
364
Default: ``vfspace.exponent``, usually 2.
365
+ range : `Field`, optional
366
+ Range of the functional. The default `None` will be treated as
367
+ `vfspace.field`.
359
368
360
369
Examples
361
370
--------
@@ -466,6 +475,9 @@ def __init__(self, domain, exponent, range=None):
466
475
Domain of the functional.
467
476
exponent : int or infinity
468
477
Specifies wich norm to use.
478
+ range : `Field`, optional
479
+ Range of the functional. The default `None` will be treated as
480
+ `domain.field`.
469
481
"""
470
482
super (IndicatorLpUnitBall , self ).__init__ (domain = domain , linear = False ,
471
483
range = range )
@@ -512,7 +524,6 @@ def convex_conj(self):
512
524
[BC2011] Bauschke, H H, and Combettes, P L. *Convex analysis and
513
525
monotone operator theory in Hilbert spaces*. Springer, 2011.
514
526
"""
515
- # HELP: I guess it needs `range`, too
516
527
if self .exponent == np .inf :
517
528
return L1Norm (self .domain , range = self .range_ )
518
529
elif self .exponent == 2 :
@@ -582,6 +593,9 @@ def __init__(self, domain, range=None):
582
593
----------
583
594
domain : `DiscreteLp` or `TensorSpace`
584
595
Domain of the functional.
596
+ range : `Field`, optional
597
+ Range of the functional. The default `None` will be treated as
598
+ `RealNumbers`.
585
599
"""
586
600
super (L1Norm , self ).__init__ (domain = domain , exponent = 1 , range = range )
587
601
@@ -620,6 +634,9 @@ def __init__(self, domain, range=None):
620
634
----------
621
635
domain : `DiscreteLp` or `TensorSpace`
622
636
Domain of the functional.
637
+ range : `Field`, optional
638
+ Range of the functional. The default `None` will be treated as
639
+ `RealNumbers`.
623
640
"""
624
641
super (L2Norm , self ).__init__ (domain = domain , exponent = 2 , range = range )
625
642
@@ -666,6 +683,9 @@ def __init__(self, domain, range=None):
666
683
----------
667
684
domain : `DiscreteLp` or `TensorSpace`
668
685
Domain of the functional.
686
+ range : `Field`, optional
687
+ Range of the functional. The default `None` will be treated as
688
+ `RealNumbers`.
669
689
"""
670
690
super (L2NormSquared , self ).__init__ (
671
691
domain = domain , linear = False , grad_lipschitz = 2 , range = range )
@@ -723,6 +743,9 @@ def __init__(self, domain, constant, range=None):
723
743
Domain of the functional.
724
744
constant : element in ``domain.field``
725
745
The constant value of the functional
746
+ range : `Field`, optional
747
+ Range of the functional. The default `None` will be treated as
748
+ `domain.field`.
726
749
"""
727
750
super (ConstantFunctional , self ).__init__ (
728
751
domain = domain , linear = (constant == 0 ), grad_lipschitz = 0 ,
@@ -781,9 +804,12 @@ def __init__(self, domain, range=None):
781
804
----------
782
805
domain : `LinearSpace`
783
806
Domain of the functional.
807
+ range : `Field`, optional
808
+ Range of the functional. The default `None` will be treated as
809
+ `domain.field`.
784
810
"""
785
811
super (ZeroFunctional , self ).__init__ (domain = domain , constant = 0 ,
786
- range = range )
812
+ range = range )
787
813
788
814
def __repr__ (self ):
789
815
"""Return ``repr(self)``."""
@@ -874,6 +900,9 @@ def __init__(self, domain, lower=None, upper=None, range=None):
874
900
upper : ``domain.field`` element or ``domain`` `element-like`, optional
875
901
The upper bound.
876
902
Default: ``None``, interpreted as +infinity
903
+ range : `Field`, optional
904
+ Range of the functional. The default `None` will be treated as
905
+ `domain.field`.
877
906
878
907
Examples
879
908
--------
@@ -929,6 +958,9 @@ def __init__(self, domain, range=None):
929
958
----------
930
959
domain : `LinearSpace`
931
960
Domain of the functional.
961
+ range : `Field`, optional
962
+ Range of the functional. The default `None` will be treated as
963
+ `domain.field`.
932
964
933
965
Examples
934
966
--------
@@ -963,6 +995,9 @@ def __init__(self, domain, constant=0, range=None):
963
995
Domain of the functional.
964
996
constant : element in ``domain.field``, optional
965
997
The constant value of the functional
998
+ range : `Field`, optional
999
+ Range of the functional. The default `None` will be treated as
1000
+ `domain.field`.
966
1001
967
1002
Examples
968
1003
--------
@@ -1107,7 +1142,6 @@ def __init__(self, domain, prior=None):
1107
1142
>>> func(x)
1108
1143
3.0
1109
1144
"""
1110
- # HELP: range is domain.field, correct?
1111
1145
super (KullbackLeibler , self ).__init__ (
1112
1146
domain = domain , linear = False , grad_lipschitz = np .nan )
1113
1147
@@ -1955,7 +1989,9 @@ def __init__(self, domain, outer_exp=1, singular_vector_exp=2, range=None):
1955
1989
Exponent for the outer norm.
1956
1990
singular_vector_exp : {1, 2, inf}, optional
1957
1991
Exponent for the norm for the singular vectors.
1958
-
1992
+ range : `Field`, optional
1993
+ Range of the functional. The default `None` will be treated as
1994
+ `RealNumbers`.
1959
1995
Examples
1960
1996
--------
1961
1997
Simple example, nuclear norm of matrix valued function with all ones
@@ -1974,7 +2010,8 @@ def __init__(self, domain, outer_exp=1, singular_vector_exp=2, range=None):
1974
2010
'`ProductSpace`s' )
1975
2011
if (not domain .is_power_space or not domain [0 ].is_power_space ):
1976
2012
raise TypeError ('`domain` must be of the form `TensorSpace^(nxm)`' )
1977
-
2013
+ if range is None :
2014
+ range = RealNumbers ()
1978
2015
super (NuclearNorm , self ).__init__ (
1979
2016
domain = domain , linear = False , grad_lipschitz = np .nan , range = range )
1980
2017
@@ -2166,7 +2203,9 @@ def __init__(self, domain, outer_exp=1, singular_vector_exp=2, range=None):
2166
2203
Exponent for the outer norm.
2167
2204
singular_vector_exp : {1, 2, inf}, optional
2168
2205
Exponent for the norm for the singular vectors.
2169
-
2206
+ range : `Field`, optional
2207
+ Range of the functional. The default `None` will be treated as
2208
+ `domain.field` or it that doesn't exist `RealNumbers`.
2170
2209
Examples
2171
2210
--------
2172
2211
Simple example, nuclear norm of matrix valued function with all ones
@@ -2282,7 +2321,8 @@ def __init__(self, functional, sigma=1.0, range=RealNumbers()):
2282
2321
sigma : positive float, optional
2283
2322
The scalar ``sigma`` in the definition of the Moreau envelope.
2284
2323
Larger values mean stronger smoothing.
2285
-
2324
+ range : `Field`, optional
2325
+ Range of the functional. The default is `RealNumbers`.
2286
2326
Examples
2287
2327
--------
2288
2328
Create smoothed l1 norm:
@@ -2354,6 +2394,8 @@ def __init__(self, domain, gamma, range=RealNumbers()):
2354
2394
the functional is non-smooth and corresponds to the usual L1 norm.
2355
2395
For ``gamma > 0``, it has a ``1/gamma``-Lipschitz gradient so that
2356
2396
its convex conjugate is ``gamma``-strongly convex.
2397
+ range : `Field`, optional
2398
+ Range of the functional. The default is `RealNumbers`.
2357
2399
2358
2400
Examples
2359
2401
--------
0 commit comments