You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let a = array![[9.,7.],[5.,2.]];let b = array![[1.,9.],[5.,1.]];println!("a vstack b = \n{:?}\n", stack![Axis(0), a, b]);println!("a hstack b = \n{:?}\n", stack![Axis(1), a, b]);
should be
a vstack b =
[[9.0,7.0],[5.0,2.0],[1.0,9.0],[5.0,1.0]], shape=[4,2], strides=[2,1], layout=C(0x1),const ndim=2
a hstack b =
[[9.0,7.0,1.0,9.0],[5.0,2.0,5.0,1.0]], shape=[2,4], strides=[4,1], layout=C(0x1),const ndim=2
but it returns
a vstack b =
[[[9.0,7.0],[5.0,2.0]],[[1.0,9.0],[5.0,1.0]]], shape=[2,2,2], strides=[4,2,1], layout=Cc(0x5),const ndim=3
a hstack b =
[[[9.0,7.0],[1.0,9.0]],[[5.0,2.0],[5.0,1.0]]], shape=[2,2,2], strides=[2,4,1], layout=c(0x4),const ndim=3
The concatenate! macro does what you're looking for. (Playground) concatenate! concatenates arrays along an existing axis; stack! stacks arrays along a new axis.
example
should be
but it returns
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=%0D%0A%20%20use%20ndarray%3A%3Aprelude%3A%3A*%3B%0D%0A%20%20use%20ndarray%3A%3A%7BArray%2C%20Axis%2C%20stack%7D%3B%0D%0A%20%20%0D%0A%20%20fn%20main()%7B%0D%0A%20%20%20%20%20%20let%20a%20%3D%20array!%5B%5B9.%2C%207.%5D%2C%20%5B5.%2C%202.%5D%5D%3B%0D%0A%0D%0A%20%20%20%20%20%20let%20b%20%3D%20array!%5B%5B1.%2C%209.%5D%2C%20%5B5.%2C%201.%5D%5D%3B%0D%0A%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20println!(%22a%20vstack%20b%20%3D%20%5Cn%7B%3A%3F%7D%5Cn%22%2C%20stack!%5BAxis(0)%2C%20a%2C%20b%5D)%3B%0D%0A%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20println!(%22a%20hstack%20b%20%3D%20%5Cn%7B%3A%3F%7D%5Cn%22%2C%20stack!%5BAxis(1)%2C%20a%2C%20b%5D)%3B%0D%0A%20%20%7D
The text was updated successfully, but these errors were encountered: