diff --git a/.ic3_history b/.ic3_history
index f704596..e4a64a5 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,8 +1,3 @@
- 2 + 2
-else
- 3 + 3
- 4 + 4
-end
1/2 + 1/3
1/2 + 2/3
3/2 + 1/3
@@ -97,3 +92,8 @@ quote (Complex) 0
-1/-1 + 1/1
-1/-1
-1/1
+sqrt(-1)
+sqrt(-1) * sqrt(-1)
+sqrt(-2) * sqrt(-2)
+sqrt(1)
+sqrt(2)
diff --git a/libc3/s.c.in b/libc3/s.c.in
index 4f2b070..1af4c4a 100644
--- a/libc3/s.c.in
+++ b/libc3/s.c.in
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=_BITS$ bits=_bits$ */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * s_bits$_sqrt (const s_bits$ x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_S_BITS$;
- dest->data.s_bits$ = (s_bits$) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/s16.c b/libc3/s16.c
index 4f26675..82080ea 100644
--- a/libc3/s16.c
+++ b/libc3/s16.c
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=16 bits=16 */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * s16_sqrt (const s16 x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_S16;
- dest->data.s16 = (s16) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/s32.c b/libc3/s32.c
index 508929c..e4e4bcd 100644
--- a/libc3/s32.c
+++ b/libc3/s32.c
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=32 bits=32 */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * s32_sqrt (const s32 x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_S32;
- dest->data.s32 = (s32) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/s64.c b/libc3/s64.c
index 2626d2d..6dd7df0 100644
--- a/libc3/s64.c
+++ b/libc3/s64.c
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=64 bits=64 */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * s64_sqrt (const s64 x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_S64;
- dest->data.s64 = (s64) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/s8.c b/libc3/s8.c
index ab1abfa..abe667b 100644
--- a/libc3/s8.c
+++ b/libc3/s8.c
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=8 bits=8 */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * s8_sqrt (const s8 x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_S8;
- dest->data.s8 = (s8) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/sw.c b/libc3/sw.c
index 20a4c9b..d2fa600 100644
--- a/libc3/sw.c
+++ b/libc3/sw.c
@@ -11,9 +11,10 @@
* THIS SOFTWARE.
*/
/* Gen from s.h.in BITS=W bits=w */
-#include "assert.h"
#include <math.h>
#include <stdlib.h>
+#include "assert.h"
+#include "complex.h"
#include "integer.h"
#include "tag.h"
#include "tag_type.h"
@@ -99,11 +100,14 @@ s_tag * sw_sqrt (const sw x, s_tag *dest)
{
assert(dest);
if (x < 0) {
- // FIXME
- //dest->type = TAG_COMPLEX;
- return NULL;
+ dest->type = TAG_COMPLEX;
+ dest->data.complex = complex_new();
+ tag_init_u8(&dest->data.complex->x, 0);
+ dest->data.complex->y.type = TAG_F128;
+ dest->data.complex->y.data.f128 = sqrtl((long double) -x);
+ return dest;
}
- dest->type = TAG_SW;
- dest->data.sw = (sw) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/u.c.in b/libc3/u.c.in
index 87a3dcc..1423f0a 100644
--- a/libc3/u.c.in
+++ b/libc3/u.c.in
@@ -119,7 +119,7 @@ u_bits$ * u_bits$_random_uniform (u_bits$ *u, u_bits$ max)
s_tag * u_bits$_sqrt (const u_bits$ x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_U_BITS$;
- dest->data.u_bits$ = (u_bits$) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/u16.c b/libc3/u16.c
index 015b4d9..3df8aa7 100644
--- a/libc3/u16.c
+++ b/libc3/u16.c
@@ -119,7 +119,7 @@ u16 * u16_random_uniform (u16 *u, u16 max)
s_tag * u16_sqrt (const u16 x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_U16;
- dest->data.u16 = (u16) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/u32.c b/libc3/u32.c
index 3ccb108..04f2656 100644
--- a/libc3/u32.c
+++ b/libc3/u32.c
@@ -119,7 +119,7 @@ u32 * u32_random_uniform (u32 *u, u32 max)
s_tag * u32_sqrt (const u32 x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_U32;
- dest->data.u32 = (u32) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/u64.c b/libc3/u64.c
index 73c88b8..2e93fdb 100644
--- a/libc3/u64.c
+++ b/libc3/u64.c
@@ -119,7 +119,7 @@ u64 * u64_random_uniform (u64 *u, u64 max)
s_tag * u64_sqrt (const u64 x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_U64;
- dest->data.u64 = (u64) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/u8.c b/libc3/u8.c
index 3f49c9f..d226ccd 100644
--- a/libc3/u8.c
+++ b/libc3/u8.c
@@ -119,7 +119,7 @@ u8 * u8_random_uniform (u8 *u, u8 max)
s_tag * u8_sqrt (const u8 x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_U8;
- dest->data.u8 = (u8) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}
diff --git a/libc3/uw.c b/libc3/uw.c
index 2476b3c..5b6e825 100644
--- a/libc3/uw.c
+++ b/libc3/uw.c
@@ -119,7 +119,7 @@ uw * uw_random_uniform (uw *u, uw max)
s_tag * uw_sqrt (const uw x, s_tag *dest)
{
assert(dest);
- dest->type = TAG_UW;
- dest->data.uw = (uw) sqrtl((long double) x);
+ dest->type = TAG_F128;
+ dest->data.f128 = sqrtl((long double) x);
return dest;
}