nicolaspanel / numjs

Like NumPy, in JavaScript
MIT License
2.4k stars 184 forks source link

code porting between python and nodejs #111

Open pedefe opened 2 years ago

pedefe commented 2 years ago

Hello, Here is a sample of code in python I want to convert in nodejs. But there are specific way to describe nparray index in python which not exist in nodejs, for exemple array[ index, :] Idem for "operator" like + on nparray Perhaps the dimensions order is different too.

# initialize perturbation rotation
angle = pi / 4
R_true = np.array([[cos(angle), -sin(angle)], [sin(angle),  cos(angle)]])
t_true = np.array([[-2], [5]])
# Generate data as a list of 2d points
num_points = 30
true_data = np.zeros((2, num_points))
true_data[0, :] = range(0, num_points)
true_data[1, :] = 0.2 * true_data[0, :] * np.sin(0.5 * true_data[0, :]) 
# Move the data
moved_data = R_true.dot(true_data) + t_true

Which are the way to convert python with "numjs" ?

Best regard.