@@ -619,9 +619,10 @@ julia> ones(Complex128, 2, 3)
619
619
ones (t,dims)
620
620
621
621
"""
622
- ones(A)
622
+ ones(A::AbstractArray, T=eltype(A)::Type, dims=size(A)::DimOrInd )
623
623
624
- Create an array of all ones with the same element type and shape as `A`.
624
+ Create an array of all ones with the same layout as `A`. Element type and size
625
+ can optionally be adjusted.
625
626
626
627
```jldoctest
627
628
julia> A = [1 2; 3 4]
@@ -633,6 +634,17 @@ julia> ones(A)
633
634
2×2 Array{Int64,2}:
634
635
1 1
635
636
1 1
637
+
638
+ julia> ones(A, Float64)
639
+ 2×2 Array{Float64,2}:
640
+ 1. 1.
641
+ 1. 1.
642
+
643
+ julia> ones(A, Bool, (3,))
644
+ 3-element Array{Bool,1}:
645
+ true
646
+ true
647
+ true
636
648
```
637
649
"""
638
650
ones (A)
@@ -2892,9 +2904,10 @@ julia> zeros(Int8, 2, 3)
2892
2904
zeros (t,dims)
2893
2905
2894
2906
"""
2895
- zeros(A)
2907
+ zeros(A::AbstractArray, T=eltype(A)::Type, dims=size(A)::DimOrInd )
2896
2908
2897
- Create an array of all zeros with the same element type and shape as `A`.
2909
+ Create an array of all zeros with the same layout as `A`. Element type and size
2910
+ can optionally be adjusted.
2898
2911
2899
2912
```jldoctest
2900
2913
julia> A = [1 2; 3 4]
@@ -2906,6 +2919,17 @@ julia> zeros(A)
2906
2919
2×2 Array{Int64,2}:
2907
2920
0 0
2908
2921
0 0
2922
+
2923
+ julia> zeros(A, Float64)
2924
+ 2×2 Array{Float64,2}:
2925
+ 0.0 0.0
2926
+ 0.0 0.0
2927
+
2928
+ julia> zeros(A, Bool, (3,))
2929
+ 3-element Array{Bool,1}:
2930
+ false
2931
+ false
2932
+ false
2909
2933
```
2910
2934
"""
2911
2935
zeros (A)
0 commit comments