最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

julia - Implementation of ComplexInt16 type - Stack Overflow

programmeradmin1浏览0评论

I have a large binary file with interleaved Int16 values representing the real and imaginary parts of each sample. Letting S_i represent the sample number i, the data is arranged as

[Re(S_1), Im(S_1), Re(S_2), Im(S_2), ...]

My thought was to define a custom ComplexInt16 type and operate on that. I produced the code below:

struct ComplexInt16
    re::Int16
    im::Int16
end

filehandle = open("y_baseband.dat")
dh = mmap(filehandle, Vector{ComplexInt16})

The code above functions as expected, but I am unable to use functions that are defined for complex numbers (e.g. real(dh[1]) returns an error.) Is there a way to have my ComplexInt16 type work with the existing Complex functions within Julia?

I have a large binary file with interleaved Int16 values representing the real and imaginary parts of each sample. Letting S_i represent the sample number i, the data is arranged as

[Re(S_1), Im(S_1), Re(S_2), Im(S_2), ...]

My thought was to define a custom ComplexInt16 type and operate on that. I produced the code below:

struct ComplexInt16
    re::Int16
    im::Int16
end

filehandle = open("y_baseband.dat")
dh = mmap(filehandle, Vector{ComplexInt16})

The code above functions as expected, but I am unable to use functions that are defined for complex numbers (e.g. real(dh[1]) returns an error.) Is there a way to have my ComplexInt16 type work with the existing Complex functions within Julia?

Share Improve this question edited Nov 18, 2024 at 12:49 Dawson Beatty asked Nov 18, 2024 at 12:46 Dawson BeattyDawson Beatty 6863 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

why not just use Complex{Int16}?

发布评论

评论列表(0)

  1. 暂无评论