00001 __copyright__ = """
00002 Copyright 2008 Sean Ross-Ross
00003 """
00004 __license__ = """
00005 This file is part of SLIMpy .
00006
00007 SLIMpy is free software: you can redistribute it and/or modify
00008 it under the terms of the GNU Lesser General Public License as published by
00009 the Free Software Foundation, either version 3 of the License, or
00010 (at your option) any later version.
00011
00012 SLIMpy is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 GNU Lesser General Public License for more details.
00016
00017 You should have received a copy of the GNU Lesser General Public License
00018 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00019 """
00020
00021
00022 from slimpy_base.Core.Interface.node import Source
00023 from slimpy_base.Core.User.linop.rclinOp import linearop_r as LinearOperatorStruct
00024
00025
00026
00027
00028
00029 class MatMult(LinearOperatorStruct):
00030 """
00031 M = MatMult(vecSpace, matrix)
00032
00033 Matrix-vector multiplication. n1 of input must match n1 of matrix.
00034 In other words, n1 corresponds to row index and n2 corresponds to column index when RSF file is 2D.
00035 Paradoxiolly, A vector RSF file with values in the n1 direction is a column vector.
00036
00037 NOTE: The adj flag gives the transpose
00038
00039 Matrix is a file name of an rsf file of the matrix we wish to apply.
00040
00041 Designed to work with SLIMpy2
00042
00043 Written by Tim Lin
00044 July 2007
00045 """
00046
00047 name = "matrixmult"
00048
00049
00050
00051 def __init__(self, space, matrix, adj=False):
00052
00053 from slimpy_base.Core.User.Structures.serial_vector import Vector
00054 if isinstance(matrix, str):
00055 from slimpy_base import vector
00056 matrix = vector( matrix )
00057 elif not isinstance(matrix, Vector):
00058 raise TypeError( "argument 'matrix' must be a 'Vector' or a 'str' instance got '%s'" %type(matrix) )
00059
00060 self.inSpace = space
00061 kparams = dict(mat=Source(matrix.container), adj=adj)
00062
00063 LinearOperatorStruct.__init__( self, self.inSpace, **kparams )
00064
00065