Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
39
Task/Arithmetic-Complex/Oforth/arithmetic-complex-1.fth
Normal file
39
Task/Arithmetic-Complex/Oforth/arithmetic-complex-1.fth
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
Object Class new: Complex(re, im)
|
||||
|
||||
Complex method: re @re ;
|
||||
Complex method: im @im ;
|
||||
|
||||
Complex method: initialize := im := re ;
|
||||
Complex method: << '(' <<c @re << ',' <<c @im << ')' <<c ;
|
||||
|
||||
0 1 Complex new const: I
|
||||
|
||||
Complex method: ==(c -- b )
|
||||
c re @re == c im @im == and ;
|
||||
|
||||
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: inv
|
||||
| n |
|
||||
@re sq @im sq + >float ->n
|
||||
@re n / @im neg n / Complex new
|
||||
;
|
||||
|
||||
Complex method: /( c -- d )
|
||||
c self inv * ;
|
||||
|
||||
Integer method: >complex self 0 Complex new ;
|
||||
Float method: >complex self 0 Complex new ;
|
||||
4
Task/Arithmetic-Complex/Oforth/arithmetic-complex-2.fth
Normal file
4
Task/Arithmetic-Complex/Oforth/arithmetic-complex-2.fth
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
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