shrub/j/e/rd.c

268 lines
4.0 KiB
C
Raw Normal View History

/* j/5/aes.c
**
** This file is in the public domain.
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
union doub {
double d;
c3_d c;
};
/* functions
*/
2014-06-04 23:16:15 +04:00
/* sun
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_sun(u3_atom a)
2014-06-04 23:16:15 +04:00
{
union doub b;
2014-11-06 03:20:01 +03:00
b.d = (double) u3r_chub(0, a);
2014-06-05 06:46:12 +04:00
2014-11-06 03:20:01 +03:00
return u3i_chubs(1, &b.c);
2014-06-04 23:16:15 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_sun(u3_noun cor)
2014-06-04 23:16:15 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun a;
2014-06-04 23:16:15 +04:00
2014-11-18 00:56:51 +03:00
if (c3n == u3r_mean(cor, u3x_sam, &a, 0)
2014-11-05 04:18:47 +03:00
|| c3n == u3ud(a)) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2014-06-04 23:16:15 +04:00
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_sun(a);
2014-06-04 23:16:15 +04:00
}
}
/* mul
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_mul(u3_atom a, u3_atom b)
{
union doub c, d, e;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
e.d = c.d * d.d;
2014-06-05 06:46:12 +04:00
2014-11-06 03:20:01 +03:00
return u3i_chubs(1, &e.c);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_mul(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_mul(a, b);
}
}
/* div
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_div(u3_atom a, u3_atom b)
{
union doub c, d, e;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
e.d = c.d / d.d;
2014-06-05 06:46:12 +04:00
2014-11-06 03:20:01 +03:00
return u3i_chubs(1, &e.c);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_div(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_div(a, b);
}
}
/* add
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_add(u3_atom a, u3_atom b)
{
union doub c, d, e;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
e.d = c.d + d.d;
2014-06-05 06:46:12 +04:00
2014-11-06 03:20:01 +03:00
return u3i_chubs(1, &e.c);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_add(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_add(a, b);
}
}
2014-06-02 23:13:58 +04:00
/* sub
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_sub(u3_atom a, u3_atom b)
2014-06-02 23:13:58 +04:00
{
union doub c, d, e;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
2014-06-02 23:13:58 +04:00
e.d = c.d - d.d;
2014-06-05 06:46:12 +04:00
2014-11-06 03:20:01 +03:00
return u3i_chubs(1, &e.c);
2014-06-02 23:13:58 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_sub(u3_noun cor)
2014-06-02 23:13:58 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-06-02 23:13:58 +04:00
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
2014-06-02 23:13:58 +04:00
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2014-06-02 23:13:58 +04:00
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_sub(a, b);
2014-06-02 23:13:58 +04:00
}
}
/* lte
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_lte(u3_atom a, u3_atom b)
{
union doub c, d;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
2014-06-05 06:46:12 +04:00
2014-11-05 04:18:47 +03:00
return __(c.d <= d.d);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_lte(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_lte(a, b);
}
}
/* lth
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_lth(u3_atom a, u3_atom b)
{
union doub c, d;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
2014-06-05 06:46:12 +04:00
2014-11-05 04:18:47 +03:00
return __(c.d < d.d);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_lth(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_lth(a, b);
}
}
/* gte
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_gte(u3_atom a, u3_atom b)
{
union doub c, d;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
2014-06-05 06:46:12 +04:00
2014-11-05 04:18:47 +03:00
return __(c.d >= d.d);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_gte(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_gte(a, b);
}
}
/* gth
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qer_gth(u3_atom a, u3_atom b)
{
union doub c, d;
2014-11-06 03:20:01 +03:00
c.c = u3r_chub(0, a);
d.c = u3r_chub(0, b);
2014-06-05 06:46:12 +04:00
2014-11-05 04:18:47 +03:00
return __(c.d > d.d);
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wer_gth(u3_noun cor)
{
2014-09-06 00:13:24 +04:00
u3_noun a, b;
2014-11-18 00:56:51 +03:00
if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ||
2014-11-05 04:18:47 +03:00
c3n == u3ud(a) ||
c3n == u3ud(b) )
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
}
else {
2014-11-06 22:13:57 +03:00
return u3qer_gth(a, b);
}
}