def add_row_vec(self, vec, target = None):
"""
Add vector vec to every row 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 (a_ == 1 and b_ == b):
raise IncompatibleDimensionsException
if target is None:
target = self
target.resize(self.shape)
target.numpy_array[:] = vec.numpy_array + self.numpy_array
return target
评论列表
文章目录