Skip to content

Commit

Permalink
fix: change position where x is copied to y
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshoku committed Dec 20, 2023
1 parent fbbb628 commit 4eb1727
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rumale-core/lib/rumale/pairwise_metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def manhattan_distance(x, y = nil)
# @param y [Numo::DFloat] (shape: [n_samples_y, n_features])
# @return [Numo::DFloat] (shape: [n_samples_x, n_samples_x] or [n_samples_x, n_samples_y] if y is given)
def squared_error(x, y = nil)
y = x if y.nil?
sum_x_vec = (x**2).sum(axis: 1).expand_dims(1)
sum_y_vec = y.nil? ? sum_x_vec.transpose : (y**2).sum(axis: 1).expand_dims(1).transpose
y = x if y.nil?
err_mat = -2 * x.dot(y.transpose)
err_mat += sum_x_vec
err_mat += sum_y_vec
Expand Down

0 comments on commit 4eb1727

Please sign in to comment.