@@ -74,24 +74,55 @@ def evaluate(self, v):
7474 Evaluate coefficient vector in basis
7575
7676 :param v: A coefficient vector (or an array of coefficient vectors)
77- to be evaluated. The first dimension must equal `self.count`.
77+ to be evaluated. The first dimension must correspond to the number of
78+ coefficient vectors, while the second must correspond to `self.count`
7879 :return: The evaluation of the coefficient vector(s) `v` for this basis.
79- This is an array whose first dimensions equal `self.z` and the
80- remaining dimensions correspond to dimensions two and higher of `v `.
80+ This is an Image or a Volume object containing one image/volume for each
81+ coefficient vector, and of size `self.sz `.
8182 """
83+ if v .dtype != self .dtype :
84+ logger .warning (
85+ f"{ self .__class__ .__name__ } ::evaluate"
86+ f" Inconsistent dtypes v: { v .dtype } self: { self .dtype } "
87+ )
88+
89+ if self .ndim == 2 :
90+ return Image (self ._evaluate (v ))
91+ elif self .ndim == 3 :
92+ return Volume (self ._evaluate (v ))
93+
94+ def _evaluate (self , v ):
8295 raise NotImplementedError ("subclasses must implement this" )
8396
8497 def evaluate_t (self , v ):
8598 """
8699 Evaluate coefficient in dual basis
87100
88- :param v: The coefficient array to be evaluated. The first dimensions
89- must equal `self.sz`.
90- :return: The evaluation of the coefficient array `v` in the dual
101+ :param v: An Image or Volume object whose size matches `self.sz`.
102+ :return: The evaluation of the Image or Volume object `v` in the dual
91103 basis of `basis`.
92- This is an array of vectors whose first dimension equals `self.count`
93- and whose remaining dimensions correspond to higher dimensions of `v `.
104+ This is an array of vectors whose first dimension equals the number of
105+ images/volumes in `v`. and whose second dimension is `self.count `.
94106 """
107+ if v .dtype != self .dtype :
108+ logger .warning (
109+ f"{ self .__class__ .__name__ } ::evaluate_t"
110+ f" Inconsistent dtypes v: { v .dtype } self: { self .dtype } "
111+ )
112+
113+ if not isinstance (v , Image ) and not isinstance (v , Volume ):
114+ if self .ndim == 2 :
115+ _class = Image
116+ elif self .ndim == 3 :
117+ _class = Volume
118+ logger .warning (
119+ f"{ self .__class__ .__name__ } ::evaluate_t"
120+ f" passed numpy array instead of { _class } ."
121+ )
122+ v = _class (v )
123+ return self ._evaluate_t (v )
124+
125+ def _evaluate_t (self , v ):
95126 raise NotImplementedError ("Subclasses should implement this" )
96127
97128 def mat_evaluate (self , V ):
@@ -104,7 +135,7 @@ def mat_evaluate(self, V):
104135 -`self.sz` corresponding to the evaluation of `V` in
105136 this basis.
106137 """
107- return mdim_mat_fun_conj (V , 1 , len (self .sz ), self .evaluate )
138+ return mdim_mat_fun_conj (V , 1 , len (self .sz ), self ._evaluate )
108139
109140 def mat_evaluate_t (self , X ):
110141 """
@@ -120,7 +151,7 @@ def mat_evaluate_t(self, X):
120151 function calculates V = B' * X * B, where the rows of `B`, rows
121152 of 'X', and columns of `X` are read as vectorized arrays.
122153 """
123- return mdim_mat_fun_conj (X , len (self .sz ), 1 , self .evaluate_t )
154+ return mdim_mat_fun_conj (X , len (self .sz ), 1 , self ._evaluate_t )
124155
125156 def expand (self , x ):
126157 """
0 commit comments