julia - Implementation of ComplexInt16 type - Stack Overflow

I have a large binary file with interleaved Int16 values representing the real and imaginary parts of e

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}?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745617393a4636317.html

相关推荐

  • julia - Implementation of ComplexInt16 type - Stack Overflow

    I have a large binary file with interleaved Int16 values representing the real and imaginary parts of e

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信