++rs jets

This commit is contained in:
Max G 2015-07-29 18:59:21 +03:00
parent 05e6a96bd5
commit 6fabd7c565
6 changed files with 138 additions and 91 deletions

View File

@ -211,6 +211,7 @@ J_E_OFILES=\
jets/e/mule.o \
jets/e/parse.o \
jets/e/rd.o \
jets/e/rs.o \
jets/e/repg.o \
jets/e/rexp.o \
jets/e/rub.o \

View File

@ -122,6 +122,18 @@
u3_noun u3qer_gte(u3_atom, u3_atom);
u3_noun u3qer_gth(u3_atom, u3_atom);
u3_noun u3qet_add(u3_atom, u3_atom);
u3_noun u3qet_sub(u3_atom, u3_atom);
u3_noun u3qet_mul(u3_atom, u3_atom);
u3_noun u3qet_div(u3_atom, u3_atom);
u3_noun u3qet_sqt(u3_atom);
u3_noun u3qet_fma(u3_atom, u3_atom, u3_atom);
u3_noun u3qet_lth(u3_atom, u3_atom);
u3_noun u3qet_lte(u3_atom, u3_atom);
u3_noun u3qet_equ(u3_atom, u3_atom);
u3_noun u3qet_gte(u3_atom, u3_atom);
u3_noun u3qet_gth(u3_atom, u3_atom);
/** Tier 6.
**/

View File

@ -151,6 +151,18 @@
u3_noun u3wer_gte(u3_noun);
u3_noun u3wer_gth(u3_noun);
u3_noun u3wet_add(u3_noun);
u3_noun u3wet_sub(u3_noun);
u3_noun u3wet_mul(u3_noun);
u3_noun u3wet_div(u3_noun);
u3_noun u3wet_sqt(u3_noun);
u3_noun u3wet_fma(u3_noun);
u3_noun u3wet_lth(u3_noun);
u3_noun u3wet_lte(u3_noun);
u3_noun u3wet_equ(u3_noun);
u3_noun u3wet_gte(u3_noun);
u3_noun u3wet_gth(u3_noun);
/** Tier 6.
**/

View File

@ -1,4 +1,4 @@
/* j/5/aes.c
/* j/e/rd.c
**
*/
#include "all.h"

View File

@ -1,26 +1,26 @@
/* j/e/rd.c
/* j/e/rs.c
**
*/
#include "all.h"
#include <math.h>
#include "softfloat.h"
#define SINGNAN 0x7fc00000
union sing {
float d;
float32_t s;
c3_w c;
};
/* functions
*/
static inline c3_t
_nan_test(float a)
_nan_test(float32_t a)
{
return !(a == a);
return !f32_eq(a, a);
}
static inline float
_nan_unify(float a)
static inline float32_t
_nan_unify(float32_t a)
{
if (_nan_test(a))
{
@ -32,19 +32,18 @@ union sing {
/* add
*/
u3_noun
u3qef_add(u3_atom a, u3_atom b)
u3qet_add(u3_atom a, u3_atom b)
{
union sing c, d, e;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
e.d = c.d + d.d;
e.d = _nan_unify(e.d);
e.s = _nan_unify(f32_add(c.s, d.s));
return u3i_words(1, &e.c);
}
u3_noun
u3wef_add(u3_noun cor)
u3wet_add(u3_noun cor)
{
u3_noun a, b;
@ -55,26 +54,25 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_add(a, b);
return u3qet_add(a, b);
}
}
/* sub
*/
u3_noun
u3qef_sub(u3_atom a, u3_atom b)
u3qet_sub(u3_atom a, u3_atom b)
{
union sing c, d, e;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
e.d = c.d - d.d;
e.d = _nan_unify(e.d);
e.s = _nan_unify(f32_sub(c.s, d.s));
return u3i_words(1, &e.c);
}
u3_noun
u3wef_sub(u3_noun cor)
u3wet_sub(u3_noun cor)
{
u3_noun a, b;
@ -85,26 +83,25 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_sub(a, b);
return u3qet_sub(a, b);
}
}
/* mul
*/
u3_noun
u3qef_mul(u3_atom a, u3_atom b)
u3qet_mul(u3_atom a, u3_atom b)
{
union sing c, d, e;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
e.d = c.d * d.d;
e.d = _nan_unify(e.d);
e.s = _nan_unify(f32_mul(c.s, d.s));
return u3i_words(1, &e.c);
}
u3_noun
u3wef_mul(u3_noun cor)
u3wet_mul(u3_noun cor)
{
u3_noun a, b;
@ -115,26 +112,25 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_mul(a, b);
return u3qet_mul(a, b);
}
}
/* div
*/
u3_noun
u3qef_div(u3_atom a, u3_atom b)
u3qet_div(u3_atom a, u3_atom b)
{
union sing c, d, e;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
e.d = c.d / d.d;
e.d = _nan_unify(e.d);
e.s = _nan_unify(f32_div(c.s, d.s));
return u3i_words(1, &e.c);
}
u3_noun
u3wef_div(u3_noun cor)
u3wet_div(u3_noun cor)
{
u3_noun a, b;
@ -145,25 +141,24 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_div(a, b);
return u3qet_div(a, b);
}
}
/* sqt
*/
u3_noun
u3qef_sqt(u3_atom a)
u3qet_sqt(u3_atom a)
{
union sing b, c;
b.c = u3r_word(0, a);
c.d = sqrt(b.d);
c.d = _nan_unify(c.d);
union sing c, d;
c.c = u3r_word(0, a);
d.s = _nan_unify(f32_sqrt(c.s));
return u3i_words(1, &c.c);
return u3i_words(1, &d.c);
}
u3_noun
u3wef_sqt(u3_noun cor)
u3wet_sqt(u3_noun cor)
{
u3_noun a;
@ -173,30 +168,55 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_sqt(a);
return u3qet_sqt(a);
}
}
/* fma
*/
u3_noun
u3qet_fma(u3_atom a, u3_atom b, u3_atom c)
{
union sing d, e, f, g;
d.c = u3r_word(0, a);
e.c = u3r_word(0, b);
f.c = u3r_word(0, c);
g.s = _nan_unify(f32_mulAdd(d.s, e.s, f.s));
return u3i_words(1, &g.c);
}
u3_noun
u3wet_fma(u3_noun cor)
{
u3_noun a, b, c;
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_6, &b, u3x_sam_7, &c, 0) ||
c3n == u3ud(a) ||
c3n == u3ud(b) ||
c3n == u3ud(c) )
{
return u3m_bail(c3__exit);
}
else {
return u3qet_fma(a, b, c);
}
}
/* lth
*/
u3_noun
u3qef_lth(u3_atom a, u3_atom b)
u3qet_lth(u3_atom a, u3_atom b)
{
union sing c, d;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
if (_nan_test(c.d) || _nan_test(d.d))
{
return u3_nul;
}
else {
return u3nc(u3_nul, __(c.d < d.d));
}
return __(f32_lt(c.s, d.s));
}
u3_noun
u3wef_lth(u3_noun cor)
u3wet_lth(u3_noun cor)
{
u3_noun a, b;
@ -207,30 +227,24 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_lth(a, b);
return u3qet_lth(a, b);
}
}
/* lte
*/
u3_noun
u3qef_lte(u3_atom a, u3_atom b)
u3qet_lte(u3_atom a, u3_atom b)
{
union sing c, d;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
if (_nan_test(c.d) || _nan_test(d.d))
{
return u3_nul;
}
else {
return u3nc(u3_nul, __(c.d <= d.d));
}
return __(f32_le(c.s, d.s));
}
u3_noun
u3wef_lte(u3_noun cor)
u3wet_lte(u3_noun cor)
{
u3_noun a, b;
@ -241,30 +255,24 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_lte(a, b);
return u3qet_lte(a, b);
}
}
/* equ
*/
u3_noun
u3qef_equ(u3_atom a, u3_atom b)
u3qet_equ(u3_atom a, u3_atom b)
{
union sing c, d;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
if (_nan_test(c.d) || _nan_test(d.d))
{
return u3_nul;
}
else {
return u3nc(u3_nul, __(c.d == d.d));
}
return __(f32_eq(c.s, d.s));
}
u3_noun
u3wef_equ(u3_noun cor)
u3wet_equ(u3_noun cor)
{
u3_noun a, b;
@ -275,30 +283,24 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_equ(a, b);
return u3qet_equ(a, b);
}
}
/* gte
*/
u3_noun
u3qef_gte(u3_atom a, u3_atom b)
u3qet_gte(u3_atom a, u3_atom b)
{
union sing c, d;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
if (_nan_test(c.d) || _nan_test(d.d))
{
return u3_nul;
}
else {
return u3nc(u3_nul, __(c.d >= d.d));
}
return __(f32_le(d.s, c.s));
}
u3_noun
u3wef_gte(u3_noun cor)
u3wet_gte(u3_noun cor)
{
u3_noun a, b;
@ -309,30 +311,24 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_gte(a, b);
return u3qet_gte(a, b);
}
}
/* gth
*/
u3_noun
u3qef_gth(u3_atom a, u3_atom b)
u3qet_gth(u3_atom a, u3_atom b)
{
union sing c, d;
c.c = u3r_word(0, a);
d.c = u3r_word(0, b);
if (_nan_test(c.d) || _nan_test(d.d))
{
return u3_nul;
}
else {
return u3nc(u3_nul, __(c.d > d.d));
}
return __(f32_lt(d.s, c.s));
}
u3_noun
u3wef_gth(u3_noun cor)
u3wet_gth(u3_noun cor)
{
u3_noun a, b;
@ -343,6 +339,6 @@ union sing {
return u3m_bail(c3__exit);
}
else {
return u3qef_gth(a, b);
return u3qet_gth(a, b);
}
}

View File

@ -229,6 +229,32 @@ static u3j_core _mood__hoon__rd_d[] =
{}
};
static u3j_harm _mood__hoon__rs_add_a[] = {{".2", u3wet_add}, {}};
static u3j_harm _mood__hoon__rs_sub_a[] = {{".2", u3wet_sub}, {}};
static u3j_harm _mood__hoon__rs_mul_a[] = {{".2", u3wet_mul}, {}};
static u3j_harm _mood__hoon__rs_div_a[] = {{".2", u3wet_div}, {}};
static u3j_harm _mood__hoon__rs_sqt_a[] = {{".2", u3wet_sqt}, {}};
static u3j_harm _mood__hoon__rs_fma_a[] = {{".2", u3wet_fma}, {}};
static u3j_harm _mood__hoon__rs_lth_a[] = {{".2", u3wet_lth}, {}};
static u3j_harm _mood__hoon__rs_lte_a[] = {{".2", u3wet_lte}, {}};
static u3j_harm _mood__hoon__rs_equ_a[] = {{".2", u3wet_equ}, {}};
static u3j_harm _mood__hoon__rs_gte_a[] = {{".2", u3wet_gte}, {}};
static u3j_harm _mood__hoon__rs_gth_a[] = {{".2", u3wet_gth}, {}};
static u3j_core _mood__hoon__rs_d[] =
{ { "add", _mood__hoon__rs_add_a },
{ "sub", _mood__hoon__rs_sub_a },
{ "mul", _mood__hoon__rs_mul_a },
{ "div", _mood__hoon__rs_div_a },
{ "sqt", _mood__hoon__rs_sqt_a },
{ "fma", _mood__hoon__rs_fma_a },
{ "lth", _mood__hoon__rs_lth_a },
{ "lte", _mood__hoon__rs_lte_a },
{ "equ", _mood__hoon__rs_equ_a },
{ "gte", _mood__hoon__rs_gte_a },
{ "gth", _mood__hoon__rs_gth_a },
{}
};
static u3j_harm _mood__hoon__coed__ed_puck_a[] = {{".2", u3wee_puck}, {}};
static u3j_harm _mood__hoon__coed__ed_sign_a[] = {{".2", u3wee_sign}, {}};
static u3j_harm _mood__hoon__coed__ed_veri_a[] = {{".2", u3wee_veri}, {}};
@ -454,10 +480,10 @@ static u3j_core _mood__hoon_d[] =
{ "stew", 0, _mood__hoon__stew_d },
{ "stir", 0, _mood__hoon__stir_d },
{ "og", 0, _mood__hoon__og_d },
{ "rd", 0, _mood__hoon__rd_d },
{ "rs", 0, _mood__hoon__rs_d },
{ "og", 0, _mood__hoon__og_d },
{ "coed", 0, _mood__hoon__coed_d },
{ "scr", 0, _mood__hoon__scr_d },
{ "pfix", _mood__hoon_pfix_a },