def add_sqsums(self, mat, axis, mult = 1.):
        """
        Add the sum of squares of mat along the given dimension to self. 0 represents the
        leading dimension and 1 represents the non-leading dimension.
        """
        m, n = mat.shape
        if axis == 0:
          assert self.shape == (1, n), 'Self has shape %s but mat has shape %s' % (self.shape, mat.shape)
        elif axis == 1:
          assert self.shape == (m, 1)

        err_code =  _cudamat.sqsum_by_axis(mat.p_mat, self.p_mat,
                                           ct.c_int(axis), ct.c_float(mult),
                                           ct.c_float(1.0))
        if err_code:
            raise generate_exception(err_code)

        Add the sum of squares of mat along the given dimension to self. 0 represents the
        leading dimension and 1 represents the non-leading dimension.
        
cudamat/cudamat.py