Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,19 @@
x@(Number traits) raisedTo: y@(Integer traits)
[
y isZero ifTrue: [^ x unit].
x isZero \/ [y = 1] ifTrue: [^ x].
y isPositive
ifTrue:
"(x * x raisedTo: y // 2) * (x raisedTo: y \\ 2)"
[| count result |
count: 1.
[(count: (count bitShift: 1)) < y] whileTrue.
result: x unit.
[count isPositive]
whileTrue:
[result: result squared.
(y bitAnd: count) isZero ifFalse: [result: result * x].
count: (count bitShift: -1)].
result]
ifFalse: [(x raisedTo: y negated) reciprocal]
].

View file

@ -0,0 +1,8 @@
x@(Float traits) raisedTo: y@(Float traits)
"Implements floating-point exponentiation in terms of the natural logarithm
and exponential primitives - this is generally faster than the naive method."
[
y isZero ifTrue: [^ x unit].
x isZero \/ [y isUnit] ifTrue: [^ x].
(x ln * y) exp
].