Project: Complex Number Class
[[Complex_number|Complex numbers]] is a number that can be expressed in the form `a + bi` where `a` and `b` are real numbers and `i` represents the imaginary quantity `sqrt(-1)`. Define a complex number class that can perform multiplication, division, reciprocal, addition, subtraction, absolute value (magnitude), argument (phase), square root, exponential, and natural logarithm functions.
Output
$ rustc ComplexNumberClass.rs
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `1`
--> ComplexNumberClass.rs:56:32
|
56 | i *= ((self.imaginary > 0) ? 1 : ((self.imaginary < 0) ? -1 : 0));
| -^ expected one of `)`, `,`, `.`, `?`, or an operator
| |
| help: missing `,`
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:`
--> ComplexNumberClass.rs:56:34
|
56 | i *= ((self.imaginary > 0) ? 1 : ((self.imaginary < 0) ? -1 : 0));
| ^ expected one of `)`, `,`, `.`, `?`, or an operator
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:20:3
|
19 | fn new(r:f64, i:f64) -> Complex {
| --- this function doesn't have a `self` parameter
20 | self.real = r;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
19 | fn new(&self, r:f64, i:f64) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:21:3
|
19 | fn new(r:f64, i:f64) -> Complex {
| --- this function doesn't have a `self` parameter
20 | self.real = r;
21 | self.imaginary = i;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
19 | fn new(&self, r:f64, i:f64) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:24:23
|
23 | fn add(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
24 | return Complex::new(self.real + x.real, self.imaginary + x.imaginary);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
23 | fn add(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:24:43
|
23 | fn add(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
24 | return Complex::new(self.real + x.real, self.imaginary + x.imaginary);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
23 | fn add(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:27:23
|
26 | fn sub(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
27 | return Complex::new(self.real - x.real, self.imaginary - x.imaginary);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
26 | fn sub(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:27:43
|
26 | fn sub(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
27 | return Complex::new(self.real - x.real, self.imaginary - x.imaginary);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
26 | fn sub(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:30:23
|
29 | fn mul(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
30 | return Complex::new(self.real * x.real - self.imaginary * x.imaginary, self.real * x.imaginary + self.imaginary * x.real);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
29 | fn mul(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:30:44
|
29 | fn mul(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
30 | return Complex::new(self.real * x.real - self.imaginary * x.imaginary, self.real * x.imaginary + self.imaginary * x.real);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
29 | fn mul(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:30:74
|
29 | fn mul(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
30 | return Complex::new(self.real * x.real - self.imaginary * x.imaginary, self.real * x.imaginary + self.imaginary * x.real);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
29 | fn mul(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:30:100
|
29 | fn mul(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
30 | return Complex::new(self.real * x.real - self.imaginary * x.imaginary, self.real * x.imaginary + self.imaginary * x.real);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
29 | fn mul(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:33:24
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
33 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:33:36
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
33 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:33:48
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
33 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:33:65
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
33 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:35:23
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
...
35 | return Complex::new(self.real / magSquared, -self.imaginary / magSquared);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:35:48
|
32 | fn recip() -> Complex {
| ----- this function doesn't have a `self` parameter
...
35 | return Complex::new(self.real / magSquared, -self.imaginary / magSquared);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
32 | fn recip(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:38:10
|
37 | fn div(x:Complex) -> Complex {
| --- this function doesn't have a `self` parameter
38 | return self.mul(x.recip());
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
37 | fn div(&self, x:Complex) -> Complex {
| ++++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:41:24
|
40 | fn abs() -> f64 {
| --- this function doesn't have a `self` parameter
41 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
40 | fn abs(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:41:36
|
40 | fn abs() -> f64 {
| --- this function doesn't have a `self` parameter
41 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
40 | fn abs(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:41:48
|
40 | fn abs() -> f64 {
| --- this function doesn't have a `self` parameter
41 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
40 | fn abs(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:41:65
|
40 | fn abs() -> f64 {
| --- this function doesn't have a `self` parameter
41 | let magSquared:f64 = self.real * self.real + self.imaginary * self.imaginary;
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
40 | fn abs(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:45:11
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
45 | assert!(self.real != 0.f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:45:33
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
45 | assert!(self.real != 0.f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:46:23
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
45 | assert!(self.real != 0.f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
46 | let magnitude:f64 = self.abs();
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:47:6
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
...
47 | if self.real < 0.f64 && self.imaginary == 0.f64 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:47:27
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
...
47 | if self.real < 0.f64 && self.imaginary == 0.f64 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0425]: cannot find value `PI` in this scope
--> ComplexNumberClass.rs:48:11
|
48 | return PI;
| ^^ not found in this scope
|
help: consider importing one of these items
|
8 + use consts::PI;
|
8 + use std::f32::consts::PI;
|
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:50:23
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
...
50 | return 2.f64 * atan(self.imaginary / (magnitude + self.real));
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:50:53
|
44 | fn phase() -> f64 {
| ----- this function doesn't have a `self` parameter
...
50 | return 2.f64 * atan(self.imaginary / (magnitude + self.real));
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
44 | fn phase(&self) -> f64 {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:53:17
|
52 | fn csqrt() -> Complex {
| ----- this function doesn't have a `self` parameter
53 | let mag:f64 = self.abs();
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
52 | fn csqrt(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:54:21
|
52 | fn csqrt() -> Complex {
| ----- this function doesn't have a `self` parameter
53 | let mag:f64 = self.abs();
54 | let r:f64 = sqrt((self.real + mag) / 2.f64);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
52 | fn csqrt(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:55:26
|
52 | fn csqrt() -> Complex {
| ----- this function doesn't have a `self` parameter
...
55 | let mut i:f64 = sqrt((-self.real + mag) / 2.f64);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
52 | fn csqrt(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:60:21
|
59 | fn cexp() -> Complex {
| ---- this function doesn't have a `self` parameter
60 | let mag:f64 = exp(self.real);
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
59 | fn cexp(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:61:33
|
59 | fn cexp() -> Complex {
| ---- this function doesn't have a `self` parameter
60 | let mag:f64 = exp(self.real);
61 | return Complex::new(mag * cos(self.imaginary), mag * sin(self.imaginary));
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
59 | fn cexp(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:61:60
|
59 | fn cexp() -> Complex {
| ---- this function doesn't have a `self` parameter
60 | let mag:f64 = exp(self.real);
61 | return Complex::new(mag * cos(self.imaginary), mag * sin(self.imaginary));
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
59 | fn cexp(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:64:17
|
63 | fn clog() -> Complex {
| ---- this function doesn't have a `self` parameter
64 | let mag:f64 = self.abs();
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
63 | fn clog(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:65:33
|
63 | fn clog() -> Complex {
| ---- this function doesn't have a `self` parameter
64 | let mag:f64 = self.abs();
65 | return Complex::new(log(mag), self.phase());
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
63 | fn clog(&self) -> Complex {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:68:6
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
68 | if self.real == 0.0f64 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:69:11
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
68 | if self.real == 0.0f64 {
69 | return self.imaginary.to_string() + "i";
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:70:13
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
70 | } else if self.imaginary == 0.0f64 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:71:11
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
71 | return self.real.to_string();
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:72:13
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
72 | } else if self.imaginary < 0 {
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:73:11
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
73 | return self.real.to_string() + &self.imaginary.to_string() + "i";
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:73:36
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
73 | return self.real.to_string() + &self.imaginary.to_string() + "i";
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:75:11
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
75 | return self.real.to_string() + "+" + &self.imaginary.to_string() + "i";
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
error[E0424]: expected value, found module `self`
--> ComplexNumberClass.rs:75:42
|
67 | fn toString() -> String {
| -------- this function doesn't have a `self` parameter
...
75 | return self.real.to_string() + "+" + &self.imaginary.to_string() + "i";
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
|
help: add a `self` receiver parameter to make the associated `fn` a method
|
67 | fn toString(&self) -> String {
| +++++
warning: unused import: `std::f64::consts`
--> ComplexNumberClass.rs:8:5
|
8 | use std::f64::consts;
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0308]: mismatched types
--> ComplexNumberClass.rs:19:26
|
19 | fn new(r:f64, i:f64) -> Complex {
| --- ^^^^^^^ expected `Complex`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:34:27
|
34 | assert!(magSquared != 0.f64, "Can't compute reciprocal of 0+0i");
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
34 | assert!(magSquared != 0.0f64, "Can't compute reciprocal of 0+0i");
| +
error[E0599]: no method named `recip` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:38:21
|
10 | struct Complex {
| -------------- method `recip` not found for this struct
...
38 | return self.mul(x.recip());
| ^^^^^ this is an associated function, not a method
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:32:2
|
32 | fn recip() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^
help: use associated function syntax instead
|
38 | return self.mul(Complex::recip());
| ~~~~~~~~~~~~~~~~
help: some of the expressions' fields have a method of the same name
|
38 | return self.mul(x.imaginary.recip());
| ++++++++++
38 | return self.mul(x.real.recip());
| +++++
error[E0425]: cannot find function `sqrt` in this scope
--> ComplexNumberClass.rs:42:10
|
42 | return sqrt(magSquared);
| ^^^^ not found in this scope
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:45:26
|
45 | assert!(self.real != 0.f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
45 | assert!(self.real != 0.0f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:45:53
|
45 | assert!(self.real != 0.f64 || self.imaginary != 0.f64, "Can't compute phase of 0+0i");
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
45 | assert!(self.real != 0.f64 || self.imaginary != 0.0f64, "Can't compute phase of 0+0i");
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:47:20
|
47 | if self.real < 0.f64 && self.imaginary == 0.f64 {
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
47 | if self.real < 0.0f64 && self.imaginary == 0.f64 {
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:47:47
|
47 | if self.real < 0.f64 && self.imaginary == 0.f64 {
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
47 | if self.real < 0.f64 && self.imaginary == 0.0f64 {
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:50:12
|
50 | return 2.f64 * atan(self.imaginary / (magnitude + self.real));
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
50 | return 2.0f64 * atan(self.imaginary / (magnitude + self.real));
| +
error[E0425]: cannot find function `atan` in this scope
--> ComplexNumberClass.rs:50:18
|
50 | return 2.f64 * atan(self.imaginary / (magnitude + self.real));
| ^^^^ not found in this scope
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:54:42
|
54 | let r:f64 = sqrt((self.real + mag) / 2.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
54 | let r:f64 = sqrt((self.real + mag) / 2.0f64);
| +
error[E0425]: cannot find function `sqrt` in this scope
--> ComplexNumberClass.rs:54:15
|
54 | let r:f64 = sqrt((self.real + mag) / 2.f64);
| ^^^^ not found in this scope
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:55:47
|
55 | let mut i:f64 = sqrt((-self.real + mag) / 2.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
55 | let mut i:f64 = sqrt((-self.real + mag) / 2.0f64);
| +
error[E0425]: cannot find function `sqrt` in this scope
--> ComplexNumberClass.rs:55:19
|
55 | let mut i:f64 = sqrt((-self.real + mag) / 2.f64);
| ^^^^ not found in this scope
error[E0425]: cannot find function `exp` in this scope
--> ComplexNumberClass.rs:60:17
|
60 | let mag:f64 = exp(self.real);
| ^^^ not found in this scope
error[E0425]: cannot find function `cos` in this scope
--> ComplexNumberClass.rs:61:29
|
61 | return Complex::new(mag * cos(self.imaginary), mag * sin(self.imaginary));
| ^^^ not found in this scope
error[E0425]: cannot find function `sin` in this scope
--> ComplexNumberClass.rs:61:56
|
61 | return Complex::new(mag * cos(self.imaginary), mag * sin(self.imaginary));
| ^^^ not found in this scope
error[E0425]: cannot find function `log` in this scope
--> ComplexNumberClass.rs:65:23
|
65 | return Complex::new(log(mag), self.phase());
| ^^^ not found in this scope
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:81:37
|
81 | let mut a:Complex = Complex::new(1.f64, 1.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
81 | let mut a:Complex = Complex::new(1.0f64, 1.f64);
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:81:44
|
81 | let mut a:Complex = Complex::new(1.f64, 1.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
81 | let mut a:Complex = Complex::new(1.f64, 1.0f64);
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:82:37
|
82 | let mut b:Complex = Complex::new(3.f64, 4.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
82 | let mut b:Complex = Complex::new(3.0f64, 4.f64);
| +
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> ComplexNumberClass.rs:82:44
|
82 | let mut b:Complex = Complex::new(3.f64, 4.f64);
| ^^^
|
help: if intended to be a floating point literal, consider adding a `0` after the period
|
82 | let mut b:Complex = Complex::new(3.f64, 4.0f64);
| +
error[E0599]: no method named `toString` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:83:22
|
10 | struct Complex {
| -------------- method `toString` not found for this struct
...
83 | println!("a: {}", a.toString());
| --^^^^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::toString()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:67:2
|
67 | fn toString() -> String {
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `toString` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:84:22
|
10 | struct Complex {
| -------------- method `toString` not found for this struct
...
84 | println!("b: {}", b.toString());
| --^^^^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::toString()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:67:2
|
67 | fn toString() -> String {
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `add` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:85:26
|
10 | struct Complex {
| -------------- method `add` not found for this struct
...
85 | println!("a + b: {}", a.add(b).toString());
| --^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::add(b)`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:23:2
|
23 | fn add(x:Complex) -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `add`, perhaps you need to implement it:
candidate #1: `Add`
error[E0599]: no method named `sub` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:86:26
|
10 | struct Complex {
| -------------- method `sub` not found for this struct
...
86 | println!("a - b: {}", a.sub(b).toString());
| --^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::sub(b)`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:26:2
|
26 | fn sub(x:Complex) -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `sub`, perhaps you need to implement it:
candidate #1: `Sub`
error[E0599]: no method named `mul` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:87:26
|
10 | struct Complex {
| -------------- method `mul` not found for this struct
...
87 | println!("a * b: {}", a.mul(b).toString());
| --^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::mul(b)`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:29:2
|
29 | fn mul(x:Complex) -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `mul`, perhaps you need to implement it:
candidate #1: `Mul`
error[E0599]: no method named `recip` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:88:26
|
10 | struct Complex {
| -------------- method `recip` not found for this struct
...
88 | println!("1 / a: {}", a.recip().toString());
| ^^^^^ this is an associated function, not a method
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:32:2
|
32 | fn recip() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^
help: use associated function syntax instead
|
88 | println!("1 / a: {}", Complex::recip().toString());
| ~~~~~~~~~~~~~~~~
help: some of the expressions' fields have a method of the same name
|
88 | println!("1 / a: {}", a.imaginary.recip().toString());
| ++++++++++
88 | println!("1 / a: {}", a.real.recip().toString());
| +++++
error[E0599]: no method named `recip` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:89:26
|
10 | struct Complex {
| -------------- method `recip` not found for this struct
...
89 | println!("1 / b: {}", b.recip().toString());
| ^^^^^ this is an associated function, not a method
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:32:2
|
32 | fn recip() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^
help: use associated function syntax instead
|
89 | println!("1 / b: {}", Complex::recip().toString());
| ~~~~~~~~~~~~~~~~
help: some of the expressions' fields have a method of the same name
|
89 | println!("1 / b: {}", b.imaginary.recip().toString());
| ++++++++++
89 | println!("1 / b: {}", b.real.recip().toString());
| +++++
error[E0599]: no method named `div` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:90:26
|
10 | struct Complex {
| -------------- method `div` not found for this struct
...
90 | println!("a / b: {}", a.div(b).toString());
| --^^^---
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::div(b)`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:37:2
|
37 | fn div(x:Complex) -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `div`, perhaps you need to implement it:
candidate #1: `Div`
error[E0599]: no method named `abs` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:91:24
|
10 | struct Complex {
| -------------- method `abs` not found for this struct
...
91 | println!("|a|: {}", a.abs());
| ^^^ this is an associated function, not a method
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:40:2
|
40 | fn abs() -> f64 {
| ^^^^^^^^^^^^^^^
help: use associated function syntax instead
|
91 | println!("|a|: {}", Complex::abs());
| ~~~~~~~~~~~~~~
help: some of the expressions' fields have a method of the same name
|
91 | println!("|a|: {}", a.imaginary.abs());
| ++++++++++
91 | println!("|a|: {}", a.real.abs());
| +++++
error[E0599]: no method named `abs` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:92:24
|
10 | struct Complex {
| -------------- method `abs` not found for this struct
...
92 | println!("|b|: {}", b.abs());
| ^^^ this is an associated function, not a method
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:40:2
|
40 | fn abs() -> f64 {
| ^^^^^^^^^^^^^^^
help: use associated function syntax instead
|
92 | println!("|b|: {}", Complex::abs());
| ~~~~~~~~~~~~~~
help: some of the expressions' fields have a method of the same name
|
92 | println!("|b|: {}", b.imaginary.abs());
| ++++++++++
92 | println!("|b|: {}", b.real.abs());
| +++++
error[E0599]: no method named `phase` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:93:25
|
10 | struct Complex {
| -------------- method `phase` not found for this struct
...
93 | println!("φ(a): {}", a.phase());
| --^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::phase()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:44:2
|
44 | fn phase() -> f64 {
| ^^^^^^^^^^^^^^^^^
error[E0599]: no method named `phase` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:94:25
|
10 | struct Complex {
| -------------- method `phase` not found for this struct
...
94 | println!("φ(b): {}", b.phase());
| --^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::phase()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:44:2
|
44 | fn phase() -> f64 {
| ^^^^^^^^^^^^^^^^^
error[E0599]: no method named `csqrt` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:95:28
|
10 | struct Complex {
| -------------- method `csqrt` not found for this struct
...
95 | println!("sqrt(a): {}", a.csqrt().toString());
| --^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::csqrt()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:52:2
|
52 | fn csqrt() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `csqrt` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:96:28
|
10 | struct Complex {
| -------------- method `csqrt` not found for this struct
...
96 | println!("sqrt(b): {}", b.csqrt().toString());
| --^^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::csqrt()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:52:2
|
52 | fn csqrt() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `cexp` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:97:27
|
10 | struct Complex {
| -------------- method `cexp` not found for this struct
...
97 | println!("exp(a): {}", a.cexp().toString());
| --^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::cexp()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:59:2
|
59 | fn cexp() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `cexp` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:98:27
|
10 | struct Complex {
| -------------- method `cexp` not found for this struct
...
98 | println!("exp(b): {}", b.cexp().toString());
| --^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::cexp()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:59:2
|
59 | fn cexp() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `clog` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:99:26
|
10 | struct Complex {
| -------------- method `clog` not found for this struct
...
99 | println!("ln(a): {}", a.clog().toString());
| --^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::clog()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:63:2
|
63 | fn clog() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `clog` found for struct `Complex` in the current scope
--> ComplexNumberClass.rs:100:26
|
10 | struct Complex {
| -------------- method `clog` not found for this struct
...
100 | println!("ln(b): {}", b.clog().toString());
| --^^^^--
| | |
| | this is an associated function, not a method
| help: use associated function syntax instead: `Complex::clog()`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in an impl for the type `Complex`
--> ComplexNumberClass.rs:63:2
|
63 | fn clog() -> Complex {
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 88 previous errors; 1 warning emitted
Some errors have detailed explanations: E0308, E0424, E0425, E0599, E0610.
For more information about an error, try `rustc --explain E0308`.