Creating a view of parent array in Julia - view(), @view and @views Methods Last Updated : 21 Apr, 2020 Comments Improve Suggest changes Like Article Like Report The view() is an inbuilt function in julia which is used to return a view into the given parent array A with the given indices instead of making a copy. Syntax: view(A, inds...) Parameters: A: Specified parent array. inds: Specified indices. Returns: It returns a view into the given parent array A with the given indices instead of making a copy. Example: Python # Julia program to illustrate # the use of view() method # Getting a view into the given parent # array A with the given indices # instead of making a copy. A = [5, 10, 15, 20]; println(view(A, 2)) B = [5 10; 15 20]; println(view(B, :, 1)) C = cat([1 2; 3 4], [5 6; 7 8], dims = 3); println(view(C, :, :, 1)) Output: @view() The @view() is an inbuilt function in julia which is used to create a sub array from the given indexing expression. Syntax: @view A[inds...] Parameters: A: Specified parent array. inds: Specified indices. Returns: It returns the created sub array from the given indexing expression. Example: Python # Julia program to illustrate # the use of @view() method # Getting the created sub array # from the given indexing expression. A = [5, 10, 15, 20]; println(@view A[3]) B = [5 10; 15 20]; println(@view B[:, 1]) C = cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3); println(@view(C[:, :, 2])) Output: @views() The @views() is an inbuilt function in julia which is used to convert every given array-slicing operation in the given expression. Syntax: @views expression Parameters: expression: Specified expression. Returns: It returns the desired view. Example: Python # Julia program to illustrate # the use of @views() method # Getting the created sub array # from the given indexing expression. A = zeros(4, 4); @views for row in 2:4 b = A[row, :] b[:] .= row end println(A) Output: Comment More infoAdvertise with us Next Article Creating a view of parent array in Julia - view(), @view and @views Methods K Kanchan_Ray Follow Improve Article Tags : Julia Similar Reads Getting parent array of a specified array in Julia - parent() Method The parent() is an inbuilt function in julia which is used to return the parent array of a specified array view type (i.e, SubArray) or the array itself if it is not a view. Syntax: parent(A) Parameters: A: Specified array or an array view type. Returns: It returns the parent array of a specified ar 2 min read Creating a similar type of array in Julia - similar() Method The similar() is an inbuilt function in julia which is used to create an uninitialized mutable array with the given element type and size, based upon the given source array. Syntax: similar(array, element_type=eltype(array), dims=size(array)) Parameters: array: Specified arrays. element_type: Specif 1 min read Reverse array elements in Julia - reverse(), reverse!() and reverseind() Methods The reverse() is an inbuilt function in julia which is used to reverse the specified vector v from start to stop. Syntax: reverse(v, start, stop) or reverse(A; dims::Integer) Parameters: v: Specified vector. start: Specified starting value. stop: Specified stopping value. A: Specified array. dims::I 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 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 Like