Marcel-Rodekamp / NSL

Nanosystem Simulation Library (NSL) implements statistical simulations for systems on the nanoscale
Other
2 stars 0 forks source link

Need better way to deal with complex numbers outside of tensors #91

Open luutom opened 2 years ago

luutom commented 2 years ago

Assigning complex numbers to tensor elements is really cumbersome. For example, when I want to insert the imaginary constant to the (0,1) element of tensor A, I have to do

A(0,1)=NSL::complex<typename NSL::RT_extractor::type>{0,1};

Typing this all out hurts my poor fingers. Can there be a simpler way?

Also, let's say I want to multiply a tensor by a scalar number. If the number is real, say x, then this is simple:

A = x A; // (or A = x)

But if x is complex, then there seems to be no equally simple way to do this operation without having to do something like:

NSL::complex<typename NSL::RT_extractor::type> tmp(0,x); A = tmp*A;

Again, this seems cumbersome.

evanberkowitz commented 2 years ago

I would like eg. Complexify<Type>, which if Type is complex just gives Type but if Type is real gives NSL::complex<Type.

The issue with Complexify is that I don't know a good word for getting the associated real type; Realify looks / sounds horrible.

So maybe a different word from Complexify, but something along those lines?

Or, (the more radical solution): completely remove anything to do with real types?