We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5668adc commit dcb8a12Copy full SHA for dcb8a12
src/util.jl
@@ -3,7 +3,7 @@ import Base: cumsum, cumprod, cummin, cummax, chol, abs2
3
4
export constant, get_last_error, err_to_string, sort_index, fir, iir
5
export mean_weighted, var_weighted, set_array_indexer, set_seq_param_indexer
6
-export afeval
+export afeval, iota
7
8
const af_threshold = Ref(4*1024*1024*1024)
9
const af_gc_count = Ref(0)
@@ -471,3 +471,11 @@ function iir{T,N}(b::AFArray{T},a::AFArray{T},x::AFArray{T,N})
471
_error(ccall((:af_iir,af_lib),af_err,(Ptr{af_array},af_array,af_array,af_array),y,b.arr,a.arr,x.arr))
472
AFArray{T,N}(y[])
473
end
474
+
475
+function iota{T,N}(dims::NTuple{N,Int}, typ::Type{T} = Int32)
476
+ out = RefValue{af_array}(0)
477
+ _error(ccall((:af_iota,af_lib), af_err,
478
+ (Ptr{af_array},UInt32,Ptr{dim_t},UInt32,Ptr{dim_t},af_dtype),
479
+ out,UInt32(N),[dims...],UInt32(1),[1],af_type(T)))
480
+ AFArray{T,N}(out[])+T(1)
481
+end
test/array.jl
@@ -9,6 +9,8 @@
x = range(AFArray{Float32}, 2, 3, 10)
10
@test Array(x) == collect(range(2,3,10))
11
@test typeof(x) == AFArray{Float32, 1}
12
13
+ @test sum(@inferred iota((2,3))) == 21
14
15
16
@testset "linspace" begin
0 commit comments