1 )write a function in python satisfies the following you might access attributes directly rather than define gette/setter methods. You DO NOT need to implement the spare matrix itself, only colmeans() method
class CSCMatrix: def_init_(self,data,ind,ptr,shape,dtype="d") """intializes a compress spare column (CSC) matrix param data: an iterable of the nonzero data elements param ind: an iterable of non zero data indices param ptr: an iterable of the nonzero data index pointers param shape: a tuple giving the (nrow,ncol) param dtupe: the data type(defaults to double)""" param self.nrow,self.ncol=shape self.data=array(dtype,data) self.ind=array("L",ind) self.ptr=array("L",ptr) def colmeans(self): """calauate and returns the means of the matrix columns. param slef: an instance of CSCMatrix. returns: A list of numbers giving the means of each column""" pass
2)
write a function in python satisfies the following you might access attributes directly rather than define getter/setter methods. You DO NOT need to implement the spare matrix itself, only rowssums() method
class RMatrix:
def_init_(slef,data,shape,dtype="d")
"""intializes a denese row-major ("C-sytle"") matrix
param data: an iterable of all the data elements
param shape: a tuple giving the (nrow,ncol)
param dtype: the data type(defaults to double)"""
self.nrow,self.ncol=shape
self.data=array(dtype,data)
def rowsums(self):
"""calauate and returns the sums of the matrix row.
param slef: an instance of RMatrix.
returns: A list of numbers giving the sums of each row"""
pass