# Best practice for complex/float operations

**URL:** <https://discuss.pytorch.org/t/best-practice-for-complex-float-operations/171745>\
**Category:** complex\
**Created:** [February 3, 2023, 4:05pm UTC](https://discuss.pytorch.org/t/best-practice-for-complex-float-operations/171745 "2023-02-03T16:05:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronan\_Gautier](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ronan_gautier/32/56791_2.png) [@Ronan\_Gautier](https://discuss.pytorch.org/u/Ronan_Gautier)\
**Post date:** [February 3, 2023, 4:05pm UTC](https://discuss.pytorch.org/t/best-practice-for-complex-float-operations/171745/1 "2023-02-03T16:05:50Z")

</div>

If I want to operate on both float and complex-valued tensors, what is the best practice? Should everything be in complex format throughout computation? Or is it fine and efficient to multiply float and complex tensors together? Assuming that they are of the same precision.

A simple exemple is for solving an ODE `y'(t) = f(t, y, θ)`, I may have a forward function that looks like

```auto
def forward(self, t, y):
    return torch.exp(1j * self.theta * t) * y

```

where `self.theta` is a real-valued 1-D tensor of parameters, `t` is the real-valued time, and `y` is a complex-valued 1-D tensor. Should I store `self.theta` and `t` as float or complex objects?
