Reshaping array dimensions in Julia | Array reshape() Method Last Updated : 23 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The reshape() is an inbuilt function in julia which is used to return an array with the same data as the specified array, but with different specified dimension sizes. Syntax: reshape(A, dims) Parameters: A: Specified array. dims: Specified dimension. Returns: It returns an array with the same data as the specified array, but with different specified dimension sizes. Example 1: Python # Julia program to illustrate # the use of Array reshape() method # Getting an array with the same data # as the specified 1D array, but with # (2 * 2) dimension sizes. A = [1, 2, 3, 4]; println(reshape(A, (2, 2))) # Getting an array with the same data # as the specified 2D array, but with # (4 * 4) dimension sizes. B = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]; println(reshape(B, (4, 4))) # Getting an array with the same data # as the specified 2D array, but with # (2 * 8) dimension sizes. C = [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16]; println(reshape(C, 2, :)) Output: Example 2: Python # Julia program to illustrate # the use of Array reshape() method # Getting an array with the same data # as the specified 1D array, but with # (2 * 2) dimension sizes. A = ["a", "b", "c", "d"]; println(reshape(A, (2, 2))) # Getting an array with the same data # as the specified 2D array, but with # (2 * 2) dimension sizes. B = ["a" "b"; "c" "d"]; println(reshape(B, (2, 2))) # Getting an array with the same data # as the specified 3D array, but with # (2 * 2*3) dimension sizes. C = cat(["a" "b"; "c" "d"], ["e" "f"; "g" "h"], ["i" "j"; "k" "l"], dims = 3); println(reshape(C, (2, 2, 3))) Output: Comment More infoAdvertise with us Next Article Reshaping array dimensions in Julia | Array reshape() Method K Kanchan_Ray Follow Improve Article Tags : Julia Julia Array-functions Similar Reads Representing the dimensions of array in Julia - Dims() Method The Dims() is an inbuilt function in julia which is used to represent the dimensions of the specified AbstractArray. Syntax: Dims(A) Parameters: A: Specified array Returns: It returns the represented dimensions of the specified AbstractArray. Example 1: Python # Julia program to illustrate # the use 1 min read Get dimensions of array in Julia - ndims() Method The ndims() is an inbuilt function in julia which is used to return the number of dimension of the specified array A. Syntax: ndims(A::AbstractArray) Parameters: A: Specified array Returns: It returns the number of dimension of the specified array A. Example 1: Python # Julia program to illustrate # 1 min read Get array dimensions and size of a dimension in Julia - size() Method The size() is an inbuilt function in julia which is used to return a tuple containing the dimensions of the specified array. This returned tuple format is (a, b, c) where a is the rows, b is the columns and c is the height of the array. Syntax: size(A::AbstractArray) or size(A::AbstractArray, Dim) P 2 min read Reshaping array as a vector in Julia - vec() Method The vec() is an inbuilt function in julia which is used to reshape the specified array as a one-dimensional column vector i.e, 1D array. Syntax: vec(a::AbstractArray) Parameters: a::AbstractArray: Specified array. Returns: It returns the reshaped 1D array. Example 1: Python # Julia program to illust 2 min read Creating array with repeated elements in Julia - repeat() Method The repeat() is an inbuilt function in julia which is used to construct an array by repeating the specified array elements with the specified number of times. Syntax: repeat(A::AbstractArray, counts::Integer...) or repeat(A::AbstractArray; inner, outer) or repeat(s::AbstractString, r::Integer) or re 2 min read Like