Can you j oporator to define a complex numbers?

like this

val complex = 3 + j4

or

val complex = 3 + i4

```
data class Complex(val re: Double, val im: Double)
val Double.j: Complex
get() = Complex(0, this)
operator fun Double.plus(c: Complex): Complex{
return Complex(this + c.re, c.im)
}
val res = 3 + 4.j
```

Of course you need to redeclare all mathematical operators. Also I recommend to use Commons Math or Commons Number complex implementation under the `Complex`

class hood.

thatâ€™s great

But I want them to add them to the basic Library of the language

What do you mean by â€śadd them to the basic Libraryâ€ť? Using darksnakes example and also using Commons Math/Numbers for the calculations should work fine for you in your projects. If you are talking about a PR to the Kotlin Standard Library I donâ€™t think there is a high chance it will be accepted as complex numbers normally arenâ€™t part of the standard library as they are not that widely used.

we use too much, and i liked Kotlin ,

is there any place to put my suggestion ?

The reality is that complex numbers will never be a part of standard library. At least for kotlin. I was a bit shocked to find them in c++ standard library, but c++ does not have packaging system and it tends to accumulate everything in standard library.

I am working with a wrapper for commons math and I could decouple it from my project and launch as a separate library, but only if there are people wanting to contribute, because I currently do not have time to do it all on my own.

Catch the opportunity to publish your code on GitHub/GitLab

Having small, independent libraries is the way to go. Take a look at the XML APIs of the JDK to see what should be avoided â€¦ By the way, that is also the way Rust goes with its small standard library. There is a small crate for complex numbers as there are libs for thousands of other things.

So, maybe itâ€™s a good chance to start such a project on GitHub as it seems like two potential contributors had just found each other

okey, thank every body

Iâ€™ll start building it as a small library

Could you share a link here to the library?

I would like to use it and contribute and implement some operators if you left any

Iâ€™ve started to create a modular mathematical library here. The progress will be very slow for the next few weeks since I have absolutely no time for side projects, but I hope to work on it during summer.

Complex number are already implemented. I use similar, but slightly different approach from the one used by commons-numbers, since they have all the operations in the field element and field is used only as a marker class and in my case all operations are implemented in field.

I plan to add full-scale vector algebra, grid generators and useful wrappers on top of commons math library. Iâ€™ve created a multi-platform architecture, but I do not plan to invest efforts in JS back-end for now. Contributions and ideas about what to add are welcome.

Something I noticed, however, is that thereâ€™s no immediate way to get the angle for the complex number (other than manually calling atan2(im,re) yourself). Theta was implemented as atan(im/re) which may violate the principle of least astonishment for some users.

Which library do you mean?

I was talking about this implementation:

Please file an issue if you think it should be changed. I never use this function, so it is possible I missed something.