June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,4 +1,4 @@
|
|||
Number 100 Class newPriority: Complex(re, im)
|
||||
Object Class new: Complex(re, im)
|
||||
|
||||
Complex method: re @re ;
|
||||
Complex method: im @im ;
|
||||
|
|
@ -6,21 +6,34 @@ Complex method: im @im ;
|
|||
Complex method: initialize := im := re ;
|
||||
Complex method: << '(' <<c @re << ',' <<c @im << ')' <<c ;
|
||||
|
||||
Integer method: asComplex self 0 Complex new ;
|
||||
Float method: asComplex self 0 Complex new ;
|
||||
0 1 Complex new const: I
|
||||
|
||||
Complex new(0, 1) Constant new: I
|
||||
Complex method: ==(c -- b )
|
||||
c re @re == c im @im == and ;
|
||||
|
||||
Complex method: ==(c) c re @re == c im @im == and ;
|
||||
Complex method: norm @re sq @im sq + sqrt ;
|
||||
Complex method: conj Complex new(@re, @im neg) ;
|
||||
Complex method: +(c) Complex new(c re @re +, c im @im +) ;
|
||||
Complex method: -(c) Complex new(c re @re -, c im @im -) ;
|
||||
Complex method: norm -- f
|
||||
@re sq @im sq + sqrt ;
|
||||
|
||||
Complex method: conj -- c
|
||||
@re @im neg Complex new ;
|
||||
|
||||
Complex method: +(c -- d )
|
||||
c re @re + c im @im + Complex new ;
|
||||
|
||||
Complex method: -(c -- d )
|
||||
c re @re - c im @im - Complex new ;
|
||||
|
||||
Complex method: *(c -- d)
|
||||
c re @re * c im @im * - c re @im * @re c im * + Complex new ;
|
||||
|
||||
Complex method: *(c) Complex new(c re @re * c im @im * -, c re @im * @re c im * + ) ;
|
||||
Complex method: inv
|
||||
| n |
|
||||
@re sq @im sq + asFloat ->n
|
||||
Complex new(@re n /, @im neg n / ) ;
|
||||
@re sq @im sq + >float ->n
|
||||
@re n / @im neg n / Complex new
|
||||
;
|
||||
|
||||
Complex method: /(c) c self inv * ;
|
||||
Complex method: /( c -- d )
|
||||
c self inv * ;
|
||||
|
||||
Integer method: >complex self 0 Complex new ;
|
||||
Float method: >complex self 0 Complex new ;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
2 3.2 I * + .cr
|
||||
Complex new(2, 3) 1.2 + .cr
|
||||
Complex new(2, 3) 1.2 * .cr
|
||||
2 Complex new(2, 3) / .cr
|
||||
3.2 >complex I * 2 >complex + .cr
|
||||
2 3 Complex new 1.2 >complex + .cr
|
||||
2 3 Complex new 1.2 >complex * .cr
|
||||
2 >complex 2 3 Complex new / .cr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue