Crates.io | easy_complex |
lib.rs | easy_complex |
version | 0.4.1 |
source | src |
created_at | 2018-02-13 19:20:06.561372 |
updated_at | 2019-04-23 19:14:01.146261 |
description | Complex numbers crate |
homepage | |
repository | https://github.com/spcan/easy-complex |
max_upload_size | |
id | 51037 |
size | 35,707 |
easy-complex
is a procedurally generated, no-dependencies crate that provides easy to use complex number operations and provides casting for most numeric types in the standard library.
If you have any issues, please report them here
Complex
) and Exponential Complex number (EComplex
).easy complex doesn't have any dependencies except the standard library.
Just add to your Cargo.toml
[dependencies]
easy_complex = "0.4.0"
Add to your crate root:
extern crate easy_complex;
If you don't use or want to use cargo, the crate can be found in this crates.io page
For extensive explanation and usage go to the wiki where the full usage is demonstrated
As the crate is generated by macros, documentation is pretty much impossible to create.
Below you will find a summary of the crate's structs and methods.
Struct | Description |
---|---|
Complex |
Complex number represented in rectangular form |
EComplex |
Complex number represented in exponential form |
Enum | Description | Variants |
---|---|---|
Angle | An angle | Radians , Degrees |
These methods are available in both Complex
and EComplex
Method | Arguments | Output | Description |
---|---|---|---|
new | f32, f32 or f64, f64 |
Self |
Generates a new struct |
real | f32 or f64 |
Returns the value of the real part of the complex number | |
imag | f32 or f64 |
Returns the value of the imaginary part of the complex number | |
module | f32 or f64 |
Returns the value of the module of the complex number | |
arg | f32 or f64 |
Returns the value of the argument of the complex number | |
conjugate | Self |
Returns the conjugate of the complex number | |
ln | Self |
Returns the natural logarithm of the complex number | |
log | f32 or f64 |
Self |
Returns the logarithm in the given base |
log2 | Self |
Returns the logarithm in base 2 | |
log10 | Self |
Returns the logarithm in base 10 | |
powf | f32 or f64 |
Self |
Returns the number to the given power |
exp | Self |
Returns e^self |
|
sqrt | Self |
Returns the square root of the number | |
root | usize |
Vec<Self> |
Returns a Vec with all the nth roots of the number |
powc | Self |
Self |
Returns self to the given complex power |
expf | f32 or f64 |
Self |
Returns the given base to the self complex power |
cos, sin, tan | Self |
Returns the corresponding geometrical function | |
cosh, sinh, tanh | Self |
Returns the corresponding hyperbolic geometrical function |
To do automatic conversion, use the convert!
macro in the convert
module.
This macro takes a list of types that cast into either f32
or f64
and implements the corresponding methods for the given struct.
This example is taken directly from the source code of the crate:
convert!([i8, u8, i16, u16, f32], f32, Complex);
Dual licensed under Apache 2.0 and MIT licenses