Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex enhancements #630

Merged
merged 2 commits into from
Mar 2, 2024
Merged

Conversation

AngelEzquerra
Copy link
Contributor

A couple of improvements to the complex() function:

  • It is now possible to call it without the second (imaginary) tensor. This let's you use similar code whether you are creating a complex tensor by combining 2 tensors or by taking just a single, real tensor. It also has the advantage over asType that it automatically chooses the right Complex type based on the input, leading to more generic code.
  • It is now possible to use complex() to directly convert integer tensors into complex tensors. This avoids unnecessary copies and also leads to more uniform code when dealing with complex tensors.

Note that you while can also convert a real tensor into a complex tensor by means of the `asType` procedure, this has the advantage that you can use the same function to combine a real and imaginary tensor or a single real tensor into a complex tensor.

Another advantage is that this function will automatically use the right Complex type for the output tensor, leading to more generic code.

That being said, `asType` can still be useful when you want to control the type of the Complex tensor.
This avoids unnecessary intermediate conversions from int to float and then to complex.
@Vindaar Vindaar merged commit 282cd70 into mratsim:master Mar 2, 2024
6 checks passed
@Vindaar
Copy link
Collaborator

Vindaar commented Mar 2, 2024

Thank you!

@AngelEzquerra AngelEzquerra deleted the complex_enhancements branch March 2, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants