A julia function to stack two arrays of size (m, n), to get one of size (2, m, n)

waves Someone who knows it here, as in I basically built it.

Can you clarify which method you’re asking about?

It’s sole purpose is to efficiently lower the syntax, so other uses are unintentional benefits.

But if it helps, this is what the three types do:

  1. “Concatenate this list of arguments along just one dimension”
  2. “Concatenate this list of arguments in the special case where an equal number of arguments are given along each axis”
  3. “Concatenate this list of arguments using the indicated groupings along each axis”
1 Like

Sorry if I’m late. I had forgotten the reference for this discussion.
Thanks for the intervention
The last of these three is the method that I have not understood when it is needed

help?> hvncat
search: hvncat

  hvncat(dim::Int, row_first, values...)
  hvncat(dims::Tuple{Vararg{Int}}, row_first, values...)
  hvncat(shape::Tuple{Vararg{Tuple}}, row_first, values...)

“…The shape form is used when the
number of elements along each axis is unbalanced (e.g., [a b ; c]). Unbalanced
syntax needs additional validation overhead. …”

Could you please provide some more elaborate examples and explain the rationale of the method in what differs from the second one for example?

Sure, first check out this blog post - skip down to “here’s how the syntax is lowered”: Julia 1.7 Highlights

A similar description is in the docstring, but I just noticed the line breaks are messed up.

But put more simply - the shape method is the one that can handle any input. The other two methods take advantage of redundancy in the input to simplify the method call overhead and computations needed to determine the correct result. The dims method works when the shape is balanced (same number of arguments along an axis inside each slice at that level). The dim method works when there’s only one dimension being concatenated.

1 Like