def from_array(arr): def call(self, vec): return nm.asarray(sc.dot(self.arr, vec)) obj = MatrixAction(shape=arr.shape, dtype=arr.dtype, arr=arr, kind="array") insert_method(obj, call) return obj
def from_function(fun, expected_shape, dtype): def call(self, vec): aux = fun(vec) assert_(aux.shape[0] == self.shape[0]) return nm.asanyarray(aux, dtype=self.dtype) obj = MatrixAction(shape=expected_shape, dtype=dtype, kind='function') insert_method(obj, call) return obj
def from_function(fun, expected_shape, dtype): def call(self, vec): aux = fun(vec) assert_(aux.shape[0] == self.shape[0]) return nm.asanyarray(aux, dtype=self.dtype) obj = MatrixAction(shape=expected_shape, dtype=dtype, kind="function") insert_method(obj, call) return obj
def from_array( arr ): def call( self, vec ): return nm.asarray( sc.dot( self.arr, vec ) ) obj = MatrixAction( shape = arr.shape, dtype = arr.dtype, arr = arr, kind = 'array' ) insert_method( obj, call ) return obj