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

Add type caster for complex numbers #292

Merged
merged 7 commits into from
Sep 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
info
  • Loading branch information
gillesdegottex committed Sep 24, 2023
commit fddc8a214e1da2ac8f068f1e2e1bf678d2448e45
3 changes: 2 additions & 1 deletion include/nanobind/stl/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ template <typename T1> struct type_caster<std::complex<T1>> {
(void)policy;
(void)cleanup;

// Conversion from 2xfloat to 2xdouble if needs be
// There is no such float32 in Python, so always build as double.
// We could build a numpy.float32, though it would force dependency to numpy.
return PyComplex_FromDoubles(value.real(), value.imag());
}
};
Expand Down