1,448 questions
1 vote
1 answer
147 views
Why isn't my Hermitian covariance matrix invertible?
I am following a paper that uses a Hermitian covariance matrix and inverts it to produce a Fisher matrix. I construct my covariance as Gamma[i,m,n], stored inside a larger array of shape (n_z, n_k, ...
4 votes
1 answer
151 views
optimize computation of real part of complex product
I need (only) the real part of the product of two complex numbers. Naturally, I can code this as real(x)*real(y) - imag(x)*imag(y); or real(x*y); The latter, however, formally first computes the ...
1 vote
1 answer
112 views
If ARM has FMLA-FMLS, then why ARM has only FCMLA?
Arm® Architecture Reference Manual for A-profile architecture has the following instructions: FMLA (Floating-point fused multiply-add) FMLS (Floating-point fused multiply-subtract) FCMLA (Floating-...
1 vote
1 answer
115 views
in pybind11, how do you test if py::object is a complex number or a callable?
Context: I've recently been using pybind11 to put a python frontend on an old c++ project of mine. This has mostly been a breeze (thanks pybind11 devs!), but there are some areas where I've had to ...
-1 votes
1 answer
109 views
Best practices for creating and deconstructing 32-bit complex values in C? (2 x 16-bit floats) [closed]
I am interested in working with 32-bit complex values in C, made up of 16-bit real and imaginary values. I am working with clang and gcc, and representing my 16-bit floats using _Float16, which I ...
6 votes
3 answers
287 views
How to select element from two complex number lists to get minimum magnitude for their sum
I have two python lists(list1 and list2),each containing 51 complex numbers. At each index i, I can choose either list1[i] or list2[i]. I want to select one element per index(Total of 51 elements) ...
0 votes
2 answers
61 views
Why does the square of a complex tensor with no imaginary part yields a result with an imaginary part?
I have a complex tensor: tensor1 = tensor([0.0000+0.j, -106990.0794+0.j], device='cuda:1', dtype=torch.complex128) The both elements have no imaginary part (0.j), however, when squaring the variable ...
6 votes
1 answer
124 views
Can a real floating-point type alias a complex floating-point type in C?
According to the C Standard: Each complex type has the same representation and alignment requirements as an array type containing exactly two elements of the corresponding real type; the first ...
2 votes
1 answer
171 views
What is the fastest way to split even and odd indices with AVX2?
For example, what Intel AVX/SSE intrinsics can I use to split a array of complex numbers into a two arrays of real and imaginary parts respectively? So something like [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7....
6 votes
2 answers
346 views
Is there a way to compute only the real part of a NumPy matmul?
Let's say I have two arrays a and b both with dtype np.complex128 and I want to compute C = np.matmul(a, b).real . That is, I don't care about the imaginary part, only the real part. Is there a better ...
0 votes
0 answers
56 views
complex type conversion errors in NumPy vs C complex.h library
I have a large Python method that calculates a series of ndarray quantities of dtype=np.complex128. I have been experimenting with what speed increases are possible using Cython. In converting a ...
0 votes
0 answers
96 views
Quadruple precision complex matrix diagonalization in Fortran 90
I'm writing a code that mostly consists of matrices manipulation and, in particular, diagonalization. I already have a code, both in python and in Fortran 90 that are able to solve my problem in a ...
0 votes
0 answers
58 views
Understanding `omp_orig` in a custom OpenMP reduction
I've encountered a bug when using Clang[1] with libomp[2] whereby using omp_priv = omp_orig in the initializer of a custom OpenMP reduction silently gives erroneous output. For example: /* file.cpp */ ...
4 votes
1 answer
232 views
Why does Python treat 1.0j as 1j as the same?
I'm beginning to learn about Python and am starting to understand the importance between integers and floats and how they are different objects. For example, the integer 1 is not the same as the float ...
0 votes
0 answers
65 views
Javascript formula to math.js formula format
I used Maple 2024 to find some big expressions which I want to use in Javascript for further calculations. In total there are 20 big expressions which I have in the format of Latex and Maple. The ...