Skip to content

Commit 8fd744d

Browse files
author
Kristian Larsson
committed
Sync std math with base
The std copy of math still used the older RealFuns witness wrapper while base had moved to direct float functions. That left std.math out of step with the unboxed math ABI used on this branch. Copy the simplified math.act shape from base and keep only the std module symbol prefix in math.ext.c. The exported C functions now use raw double arguments and results like the base module.
1 parent 2e4e7e0 commit 8fd744d

2 files changed

Lines changed: 61 additions & 95 deletions

File tree

std/src/std/math.act

Lines changed: 31 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,70 +11,36 @@
1111
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1212
#
1313

14-
pi = 3.141592653589793
14+
pi: float = 3.141592653589793
1515

16-
protocol RealFuns:
17-
@staticmethod
18-
sqrt : (Self) -> Self
19-
@staticmethod
20-
exp : (Self) -> Self
21-
@staticmethod
22-
log : (Self) -> Self
23-
@staticmethod
24-
sin : (Self) -> Self
25-
@staticmethod
26-
cos : (Self) -> Self
27-
@staticmethod
28-
tan : (Self) -> Self
29-
@staticmethod
30-
asin : (Self) -> Self
31-
@staticmethod
32-
acos : (Self) -> Self
33-
@staticmethod
34-
atan : (Self) -> Self
35-
@staticmethod
36-
sinh : (Self) -> Self
37-
@staticmethod
38-
cosh : (Self) -> Self
39-
@staticmethod
40-
tanh : (Self) -> Self
41-
@staticmethod
42-
asinh : (Self) -> Self
43-
@staticmethod
44-
acosh : (Self) -> Self
45-
@staticmethod
46-
atanh : (Self) -> Self
4716

48-
extension float (RealFuns):
49-
NotImplemented
50-
51-
def sqrt(x: float):
52-
return RealFuns.sqrt(x)
53-
def exp(x: float):
54-
return RealFuns.exp(x)
55-
def log(x: float):
56-
return RealFuns.log(x)
57-
def sin(x: float):
58-
return RealFuns.sin(x)
59-
def cos(x: float):
60-
return RealFuns.cos(x)
61-
def tan(x: float):
62-
return RealFuns.tan(x)
63-
def asin(x: float):
64-
return RealFuns.asin(x)
65-
def acos(x: float):
66-
return RealFuns.acos(x)
67-
def atan(x: float):
68-
return RealFuns.atan(x)
69-
def sinh(x: float):
70-
return RealFuns.sinh(x)
71-
def cosh(x: float):
72-
return RealFuns.cosh(x)
73-
def tanh(x: float):
74-
return RealFuns.tanh(x)
75-
def asinh(x: float):
76-
return RealFuns.asinh(x)
77-
def acosh(x: float):
78-
return RealFuns.acosh(x)
79-
def atanh(x: float):
80-
return RealFuns.atanh(x)
17+
def sqrt(x: float)->float:
18+
NotImplemented
19+
def exp(x: float)->float:
20+
NotImplemented
21+
def log(x: float)->float:
22+
NotImplemented
23+
def sin(x: float)->float:
24+
NotImplemented
25+
def cos(x: float)->float:
26+
NotImplemented
27+
def tan(x: float)->float:
28+
NotImplemented
29+
def asin(x: float)->float:
30+
NotImplemented
31+
def acos(x: float)->float:
32+
NotImplemented
33+
def atan(x: float)->float:
34+
NotImplemented
35+
def sinh(x: float)->float:
36+
NotImplemented
37+
def cosh(x: float)->float:
38+
NotImplemented
39+
def tanh(x: float)->float:
40+
NotImplemented
41+
def asinh(x: float)->float:
42+
NotImplemented
43+
def acosh(x: float)->float:
44+
NotImplemented
45+
def atanh(x: float)->float:
46+
NotImplemented

std/src/std/math.ext.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
B_float stdQ_mathQ_RealFunsD_floatD_sqrt(stdQ_mathQ_RealFunsD_float wit, B_float x) {
2-
return to$float(sqrt(x->val));
1+
double stdQ_mathQ_sqrt(double x) {
2+
return sqrt(x);
33
}
4-
B_float stdQ_mathQ_RealFunsD_floatD_exp(stdQ_mathQ_RealFunsD_float wit, B_float x) {
5-
return to$float(exp(x->val));
4+
double stdQ_mathQ_exp(double x) {
5+
return exp(x);
66
}
7-
B_float stdQ_mathQ_RealFunsD_floatD_log(stdQ_mathQ_RealFunsD_float wit, B_float x) {
8-
return to$float(log(x->val));
7+
double stdQ_mathQ_log(double x) {
8+
return log(x);
99
}
10-
B_float stdQ_mathQ_RealFunsD_floatD_sin(stdQ_mathQ_RealFunsD_float wit, B_float x) {
11-
return to$float(sin(x->val));
10+
double stdQ_mathQ_sin(double x) {
11+
return sin(x);
1212
}
13-
B_float stdQ_mathQ_RealFunsD_floatD_cos(stdQ_mathQ_RealFunsD_float wit, B_float x) {
14-
return to$float(cos(x->val));
13+
double stdQ_mathQ_cos(double x) {
14+
return cos(x);
1515
}
16-
B_float stdQ_mathQ_RealFunsD_floatD_tan(stdQ_mathQ_RealFunsD_float wit, B_float x) {
17-
return to$float(tan(x->val));
16+
double stdQ_mathQ_tan(double x) {
17+
return tan(x);
1818
}
19-
B_float stdQ_mathQ_RealFunsD_floatD_asin(stdQ_mathQ_RealFunsD_float wit, B_float x) {
20-
return to$float(asin(x->val));
19+
double stdQ_mathQ_asin(double x) {
20+
return asin(x);
2121
}
22-
B_float stdQ_mathQ_RealFunsD_floatD_acos(stdQ_mathQ_RealFunsD_float wit, B_float x) {
23-
return to$float(acos(x->val));
22+
double stdQ_mathQ_acos(double x) {
23+
return acos(x);
2424
}
25-
B_float stdQ_mathQ_RealFunsD_floatD_atan(stdQ_mathQ_RealFunsD_float wit, B_float x) {
26-
return to$float(atan(x->val));
25+
double stdQ_mathQ_atan(double x) {
26+
return atan(x);
2727
}
28-
B_float stdQ_mathQ_RealFunsD_floatD_sinh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
29-
return to$float(sinh(x->val));
28+
double stdQ_mathQ_sinh(double x) {
29+
return sinh(x);
3030
}
31-
B_float stdQ_mathQ_RealFunsD_floatD_cosh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
32-
return to$float(cosh(x->val));
31+
double stdQ_mathQ_cosh(double x) {
32+
return cosh(x);
3333
}
34-
B_float stdQ_mathQ_RealFunsD_floatD_tanh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
35-
return to$float(tanh(x->val));
34+
double stdQ_mathQ_tanh(double x) {
35+
return tanh(x);
3636
}
37-
B_float stdQ_mathQ_RealFunsD_floatD_asinh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
38-
return to$float(asinh(x->val));
37+
double stdQ_mathQ_asinh(double x) {
38+
return asinh(x);
3939
}
40-
B_float stdQ_mathQ_RealFunsD_floatD_acosh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
41-
return to$float(acosh(x->val));
40+
double stdQ_mathQ_acosh(double x) {
41+
return acosh(x);
4242
}
43-
B_float stdQ_mathQ_RealFunsD_floatD_atanh(stdQ_mathQ_RealFunsD_float wit, B_float x) {
44-
return to$float(atanh(x->val));
43+
double stdQ_mathQ_atanh(double x) {
44+
return atanh(x);
4545
}
4646

4747
void stdQ_mathQ___ext_init__() {

0 commit comments

Comments
 (0)