Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
 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