def add_col_mult(self, vec, mult, target = None):
"""
Add a multiple of vector vec to every column of the matrix. If a target
is provided, it is used to store the result instead of self.
"""
a, b = self.shape
a_, b_ = vec.shape
if not (b_ == 1 and a_ == a):
raise IncompatibleDimensionsException
if target is None:
target = self
target.resize(self.shape)
target.numpy_array[:] = self.numpy_array + vec.numpy_array * mult
return target
评论列表
文章目录