urbit/gen164/5/mat.c

54 lines
919 B
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/3/mat.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* functions
*/
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 07:36:29 +04:00
u2_cqe_mat(
2014-09-04 01:33:18 +04:00
u2_atom a)
2013-09-29 00:21:18 +04:00
{
2014-08-20 10:22:41 +04:00
if ( 0 == a ) {
return u2nc(1, 1);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 07:36:29 +04:00
u2_atom b = u2_cqc_met(0, a);
u2_atom c = u2_cqc_met(0, b);
2013-09-29 00:21:18 +04:00
u2_atom u, v, w, x, y, z;
u2_atom p, q;
2014-09-03 07:36:29 +04:00
u = u2_cqa_dec(c);
v = u2_cqa_add(c, c);
w = u2_cqc_bex(c);
x = u2_cqc_end(0, u, b);
y = u2_cqc_lsh(0, u, a);
z = u2_cqc_mix(x, y);
2013-09-29 00:21:18 +04:00
2014-09-03 07:36:29 +04:00
p = u2_cqa_add(v, b);
q = u2_cqc_cat(0, w, z);
2013-09-29 00:21:18 +04:00
2014-08-20 10:22:41 +04:00
u2z(u);
u2z(v);
u2z(w);
u2z(x);
u2z(y);
u2z(z);
2013-09-29 00:21:18 +04:00
2014-08-20 10:22:41 +04:00
return u2nc(p, q);
2013-09-29 00:21:18 +04:00
}
}
2014-09-04 01:33:18 +04:00
u2_noun
2014-09-03 09:46:55 +04:00
u2_cwe_mat(
2014-09-04 01:33:18 +04:00
u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun a;
2014-08-20 10:22:41 +04:00
if ( (u2_none == (a = u2_cr_at(u2_cv_sam, cor))) ) {
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 07:36:29 +04:00
return u2_cqe_mat(a);
2013-09-29 00:21:18 +04:00
}
}