Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -0,0 +1,152 @@
|
|||
Class Complex {
|
||||
private:
|
||||
double vr, vi
|
||||
public:
|
||||
property real {
|
||||
value {link parent vr to vr : value=vr}
|
||||
}
|
||||
property imaginary {
|
||||
value {link parent vi to vi : value=vi}
|
||||
}
|
||||
property toString {
|
||||
value {
|
||||
clear
|
||||
' so default variable VALUE deleted and again defined it as string
|
||||
link parent vr, vi to vr, vi
|
||||
if vi then
|
||||
if vr then
|
||||
if vi>0 then
|
||||
if vi==1 then
|
||||
value="("+vr+"+i)"
|
||||
else
|
||||
value="("+vr+"+"+vi+"i)"
|
||||
end if
|
||||
else
|
||||
if vi==-1 then
|
||||
value="("+vr+"-i)"
|
||||
else
|
||||
value="("+vr+""+vi+"i)"
|
||||
end if
|
||||
end if
|
||||
else
|
||||
if vi=1 then
|
||||
value="(i)"
|
||||
else.if vi=-1 then
|
||||
value="(-i)"
|
||||
else
|
||||
value="("+vi+"i)"
|
||||
end if
|
||||
end if
|
||||
else
|
||||
value="("+vr+")"
|
||||
end if
|
||||
}
|
||||
}
|
||||
function final Arg {
|
||||
declare m math
|
||||
Method m, "Atan2", .vi, .vr as ret
|
||||
=ret
|
||||
}
|
||||
function final exp(rr=10) {
|
||||
double exp = 2.71828182845905^.vr
|
||||
c=this
|
||||
th=.vi/1.74532925199433E-02
|
||||
c.vr<=round(exp * cos(th), rr)
|
||||
c.vi<=round(exp * sin(th),rr)
|
||||
=c
|
||||
}
|
||||
function final cabs {
|
||||
if abs(.vr)=infinity or abs(.vi)=infinity then
|
||||
=1.7976931348623157E+308 : break
|
||||
end if
|
||||
double c=abs(.vr), d=abs(.vi)
|
||||
if c>d then
|
||||
r=d/c : =c*sqrt(1+r*r)
|
||||
else.if d==0 then
|
||||
=c
|
||||
else
|
||||
r=c/d : =d*sqrt(1+r*r)
|
||||
end if
|
||||
}
|
||||
function final clog {
|
||||
c=this
|
||||
c.vr<=ln(.cabs())
|
||||
c.vi<=.Arg()
|
||||
=c
|
||||
}
|
||||
function final pow {
|
||||
if match("G") then
|
||||
read p as Complex
|
||||
else
|
||||
read p1 as double
|
||||
p=this:p.vr=p1:p.vi=0
|
||||
end if
|
||||
Read ? rr=10
|
||||
exp=.clog()*p
|
||||
c=exp.exp(rr)
|
||||
c.vr=round(c.vr, rr)
|
||||
c.vi=round(c.vi, rr)
|
||||
=c
|
||||
}
|
||||
function final inv {
|
||||
if .vr==0 and .vi==0 then error "zero complex num"
|
||||
acb=this.conj()
|
||||
c=this*acb
|
||||
c.vi <= acb.vi/c.vr
|
||||
c.vr <= acb.vr/c.vr
|
||||
=c
|
||||
}
|
||||
function final conj {
|
||||
c=this : c.vi-! : =c
|
||||
}
|
||||
function final absc {
|
||||
c=this*.conj() : =sqrt(c.vr)
|
||||
}
|
||||
operator final "+" {
|
||||
read k as Complex : .vr+= k.vr : .vi+= k.vi
|
||||
}
|
||||
operator final "-" {
|
||||
read k as Complex : .vr-= k.vr : .vi-= k.vi
|
||||
}
|
||||
operator final high "*" {
|
||||
read k as Complex
|
||||
double ivr = .vr*k.vr-.vi*k.vi
|
||||
.vi <= .vi*k.vr+.vr*k.vi
|
||||
.vr <= ivr
|
||||
}
|
||||
operator final high "/" {
|
||||
read k as Complex
|
||||
k1=k*k.conj()
|
||||
acb = this*k.conj()
|
||||
.vr <= acb.vr/k1.vr
|
||||
.vi <= acb.vi/k1.vr
|
||||
}
|
||||
operator final unary {
|
||||
.vr-!
|
||||
.vi-!
|
||||
}
|
||||
|
||||
class:
|
||||
module Complex (.vr, .vi) {}
|
||||
}
|
||||
Module Check (filename as string="") {
|
||||
def f(x)=x.toString
|
||||
a=Complex(8,-3)
|
||||
b=a.inv()
|
||||
open filename for wide output as #f
|
||||
Print #f, "A="+a.toString
|
||||
Print #f, " r=";a.cabs();" θ=";a.Arg();" rad"
|
||||
Print #f, "B="+b.toString+" as 1/A"
|
||||
Print #f, " r=";b.cabs();" θ=";b.Arg();" rad"
|
||||
Print #f, a.toString+"*"+b.toString+"="+f(a*b)
|
||||
Print #f, Complex(1).toString+"/"+b.toString+"="+f(Complex(1)/b)
|
||||
Print #f, a.toString+"/"+a.toString+"="+f(a/a)
|
||||
Print #f, a.toString+"+"+a.toString+"="+f(a+a)
|
||||
Print #f, a.toString+"-"+a.toString+"="+f(a-a)
|
||||
Print #f, "-"+a.toString+"="+f(-a)
|
||||
Print #f, "e^(πi)+1="+f(Complex(2.71828182845905).pow(Complex(0,pi))+Complex(1))
|
||||
close #f
|
||||
if filename<>"" then if exist(filename) then win "notepad", dir$+filename
|
||||
}
|
||||
Check "out.txt"
|
||||
Check ' just show here
|
||||
Loading…
Add table
Add a link
Reference in a new issue