From: Thomas Walker Lynch Date: Wed, 19 Feb 2025 09:02:41 +0000 (+0000) Subject: to/from processor native uint X-Git-Url: https://git.reasoningtechnology.com/style/rt_dark_doc.css?a=commitdiff_plain;h=09d104c0835d0dc8dbb9292425b08bcce6c3651b;p=N to/from processor native uint --- diff --git "a/developer/Python\360\237\226\211/template_N.py" "b/developer/Python\360\237\226\211/template_N.py" index 2ce8770..bc2cc5e 100644 --- "a/developer/Python\360\237\226\211/template_N.py" +++ "b/developer/Python\360\237\226\211/template_N.py" @@ -1,4 +1,11 @@ -def N(namespace: str ,digit_type: str ,digit_extent: int ,constants_block: str) -> str: +def N( + namespace: str + ,digit_type: str + ,digit_array_extent_type: int + ,address_type: str + ,constants_block: str + ) -> str: + """ Returns a source code file for cc to munch on """ @@ -6,7 +13,8 @@ def N(namespace: str ,digit_type: str ,digit_extent: int ,constants_block: str) code = template.format( NS = namespace ,DIGIT_TYPE = digit_type - ,DIGIT_EXTENT = digit_extent + ,DIGIT_ARRAY_EXTENT_TYPE = digit_array_extent_type + ,AddressType = address_type ,CONSTANTS_BLOCK = constants_block ) return code @@ -14,10 +22,9 @@ def N(namespace: str ,digit_type: str ,digit_extent: int ,constants_block: str) def template_N(): return r''' /* - M - The type for the function dictionary. - m - A function dictionary. - T - Is the type for the tableau. The tableau is a memory shared among the functions - In the function dictionary. + M - The type for the function dictionary (manifold). + m - a manifold instance, there can be many, m0, m1 ... + T - Is the type for the tableau. */ #define {NS}·DEBUG @@ -41,9 +48,10 @@ def template_N(): //---------------------------------------- // Instance Data (Declaration Only) - typedef uint32_t Extent; - typedef uint32_t Digit; + typedef {ADDRESS_TYPE} Address; +// +3 - 1 due to 0x and the trailing null character, and being an extent + // tableau type, encapsulated data is unavailable to user code typedef struct {NS}·T {NS}·T; extern {NS}·T *{NS}·zero; @@ -58,7 +66,7 @@ def template_N(): typedef enum{{ {NS}·Status·ok = 0 ,{NS}·Status·overflow = 1 - ,{NS}·Status·accumulator1_overflow = 2 + ,{NS}·Status·accumulator_overflow = 2 ,{NS}·Status·carry = 3 ,{NS}·Status·borrow = 4 ,{NS}·Status·undefined_divide_by_zero = 5 @@ -75,27 +83,35 @@ def template_N(): ,{NS}·Order_gt = 1 }} {NS}·Order; - typedef {NS}·T *( *{NS}·Allocate_MemoryFault )(Extent); + // when alloc runs out of memory + typedef {NS}·T *( *{NS}·Allocate_MemoryFault )(Address); //---------------------------------------- // Interface typedef struct{{ - {NS}·T *(*allocate_array_zero)(Extent, {NS}·Allocate_MemoryFault); - {NS}·T *(*allocate_array)(Extent, {NS}·Allocate_MemoryFault); + // memory allocation + {NS}·T *(*allocate_array_zero)(Address, {NS}·Allocate_MemoryFault); + {NS}·T *(*allocate_array)(Address, {NS}·Allocate_MemoryFault); void (*deallocate)({NS}·T*); + {NS}·T* (*access)({NS}·T*, Address); + // results fits in operand type functions void (*copy)({NS}·T*, {NS}·T*); void (*bit_and)({NS}·T*, {NS}·T*, {NS}·T*); void (*bit_or)({NS}·T*, {NS}·T*, {NS}·T*); void (*bit_complement)({NS}·T*, {NS}·T*); void (*bit_twos_complement)({NS}·T*, {NS}·T*); + + // tests {NS}·Order (*compare)({NS}·T*, {NS}·T*); bool (*lt)({NS}·T*, {NS}·T*); bool (*gt)({NS}·T*, {NS}·T*); bool (*eq)({NS}·T*, {NS}·T*); bool (*eq_zero)({NS}·T*); + + // arithmetic {NS}·Status (*accumulate)({NS}·T *accumulator1 ,{NS}·T *accumulator0 ,...); {NS}·Status (*add)({NS}·T*, {NS}·T*, {NS}·T*); bool (*increment)({NS}·T *a); @@ -103,15 +119,20 @@ def template_N(): {NS}·Status (*multiply)({NS}·T*, {NS}·T*, {NS}·T*, {NS}·T*); {NS}·Status (*divide)({NS}·T*, {NS}·T*, {NS}·T*, {NS}·T*); {NS}·Status (*modulus)({NS}·T*, {NS}·T*, {NS}·T*); - {NS}·Status (*shift_left)(Extent, {NS}·T*, {NS}·T*, {NS}·T*); - {NS}·Status (*shift_right)(Extent, {NS}·T*, {NS}·T*, {NS}·T*); - {NS}·Status (*arithmetic_shift_right)(Extent, {NS}·T*, {NS}·T*); - {NS}·T* (*access)({NS}·T*, Extent); + // shift + {NS}·Status (*shift_left)(Address, {NS}·T*, {NS}·T*, {NS}·T*); + {NS}·Status (*shift_right)(Address, {NS}·T*, {NS}·T*, {NS}·T*); + {NS}·Status (*arithmetic_shift_right)(Address, {NS}·T*, {NS}·T*); + + // import/export + void (*to_string)(char [print_buffer_extent + 1] ,uint32_t value); void (*from_uint32)({NS}·T *destination ,uint32_t value); - }} {NS}·Λ; - Local const {NS}·Λ {NS}·λ; // initialized in the LOCAL section + + }} {NS}·M; + + Local const {NS}·M {NS}·m; // initialized in the LOCAL section #endif @@ -120,31 +141,23 @@ def template_N(): #ifdef {NS}·IMPLEMENTATION - // this part goes into the library + typedef {DIGIT_TYPE} Digit; + const {DIGIT_ARRAY_EXTENT_TYPE} digit_array_extent = {DIGIT_ARRAY_EXTENT}; + + // full type definition for Tableau + struct {NS}·T{{ + Digit d[digit_array_extent + 1]; + }}; + + // this part goes into Nlib.a #ifndef LOCAL #include #include - - struct {NS}·T{{ - Digit d0; - }}; - - {NS}·T {NS}·constant[4] = {{ - {{.d0 = 0}}, - {{.d0 = 1}}, - {{.d0 = ~(uint32_t)0}}, - {{.d0 = 1 << 31}} - }}; - - {NS}·T *{NS}·zero = &{NS}·constant[0]; - {NS}·T *{NS}·one = &{NS}·constant[1]; - {NS}·T *{NS}·all_one_bit = &{NS}·constant[2]; - {NS}·T *{NS}·msb = &{NS}·constant[3]; - {NS}·T *{NS}·lsb = &{NS}·constant[1]; + #include // the allocate an array of N32 - {NS}·T *{NS}·allocate_array(Extent extent ,{NS}·Allocate_MemoryFault memory_fault){{ + {NS}·T *{NS}·allocate_array(Address extent ,{NS}·Allocate_MemoryFault memory_fault){{ {NS}·T *instance = malloc((extent + 1) * sizeof({NS}·T) ); if(!instance){{ return memory_fault ? memory_fault(extent) : NULL; @@ -152,7 +165,7 @@ def template_N(): return instance; }} - {NS}·T *{NS}·allocate_array_zero(Extent extent ,{NS}·Allocate_MemoryFault memory_fault){{ + {NS}·T *{NS}·allocate_array_zero(Address extent ,{NS}·Allocate_MemoryFault memory_fault){{ {NS}·T *instance = calloc( extent + 1 ,sizeof({NS}·T) ); if(!instance){{ return memory_fault ? memory_fault(extent) : NULL; @@ -164,16 +177,40 @@ def template_N(): free(unencumbered); }} + char *to_string({NS}·T *n) { + // Each byte requires two hex characters, plus "0x" prefix and null terminator + const Address string_length = (sizeof(Digit) * (digit_array_extent + 1) * 2) + 3; + char *buffer = malloc(string_length); + if (!buffer) { + return NULL; // Handle allocation failure + } + + strcpy(buffer, "0x"); // Prefix the hex representation + char *ps = buffer + 2; // Pointer to string buffer (after "0x") + + // Pointer to the most significant digit + Digit *pd = n->d + digit_array_extent; + + for (; pd >= n->d; pd--) { + sprintf(ps, "%0*X", (int)(sizeof(Digit) * 2), *pd); + ps += sizeof(Digit) * 2; // Move forward in buffer + } + + return buffer; // Caller must free the allocated buffer + } + #endif - // This part is included after the library user's code + // This part is included after the user's code. If the code at top is a 'header, then this is a 'tailer'. #ifdef LOCAL - // instance + {CONSTANTS_BLOCK} - struct {NS}·T{{ - Digit d0; - }}; + {NS}·T *{NS}·zero = &{NS}·constant[0]; + {NS}·T *{NS}·one = &{NS}·constant[1]; + {NS}·T *{NS}·all_one_bit = &{NS}·constant[2]; + {NS}·T *{NS}·msb = &{NS}·constant[3]; + {NS}·T *{NS}·lsb = &{NS}·constant[1]; // temporary variables // making these LOCAL rather than reserving one block in the library is thread safe @@ -185,19 +222,87 @@ def template_N(): // allocation - extern {NS}·T *{NS}·allocate_array(Extent, {NS}·Allocate_MemoryFault); - extern {NS}·T *{NS}·allocate_array_zero(Extent, {NS}·Allocate_MemoryFault); + extern {NS}·T *{NS}·allocate_array(Address, {NS}·Allocate_MemoryFault); + extern {NS}·T *{NS}·allocate_array_zero(Address, {NS}·Allocate_MemoryFault); extern void {NS}·deallocate({NS}·T *); // so the user can access numbers in an array allocation - Local {NS}·T* {NS}·access({NS}·T *array ,Extent index){{ - return &array[index]; + Local {NS}·T* {NS}·access({NS}·T *array ,Address index){{ + return array + index; }} - Local void {NS}·from_uint32({NS}·T *destination ,uint32_t value){{ - if(destination == NULL) return; - destination->d0 = value; - }} + /* + // a hackish approach + void from_uint64_hack({NS}·T *n, uint64_t value) { + char buffer[24]; // Enough for "0xFFFFFFFFFFFFFFFF" + sprintf(buffer, "0x%llX", (unsigned long long)value); + from_string(n, buffer); + } + + // as it should expand out to: + void from_uint64({NS}·T *n, uint64_t value) { + Digit *pd = n->d; + for (int i = 0; i <= digit_array_extent; i++, pd++) { + *pd = (Digit)(value & ((1ULL << (sizeof(Digit) * 8)) - 1)); // Extract lower bits + value >>= sizeof(Digit) * 8; // Shift right to process next part + } + } + */ + + + #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + #define ENDIAN_DIRECTION -1 // Big-endian: Store high-to-low + #else + #define ENDIAN_DIRECTION 1 // Little-endian: Store low-to-high + #endif + + #define DEFINE_FROM_UINT(TYPE) \ + void from_##TYPE({{NS}}·T *n, TYPE value) {{ \ + const Digit digit_mask = (Digit)((1ULL << (sizeof(Digit) * 8)) - 1); \ + const Digit bits_in_digit = sizeof(Digit) * 8; + Digit *pd = (ENDIAN_DIRECTION == 1) ? n->d : (n->d + digit_array_extent); \ + for (int i = 0; i <= digit_array_extent; i++, pd += ENDIAN_DIRECTION) {{ \ + *pd = (Digit)(value & digit_mask); \ + value >>= bits_in_digit; \ + }} \ + }} + + #define DEFINE_TO_UINT(TYPE) \ + TYPE to_##TYPE(const {{NS}}·T *n) {{ \ + const Digit bits_in_digit = sizeof(Digit) * 8; \ + TYPE value = 0; \ + const Digit *pd = (ENDIAN_DIRECTION == 1) ? (n->d + digit_array_extent) : n->d; \ + for (int i = 0; i <= digit_array_extent; i++, pd -= ENDIAN_DIRECTION) {{ \ + value = (value << bits_in_digit) | *pd; \ + }} \ + return value; \ + }} + + + #ifdef UINT8_MAX + DEFINE_FROM_UINT(uint8_t) + DEFINE_TO_UINT(uint8_t) + #endif + + #ifdef UINT16_MAX + DEFINE_FROM_UINT(uint16_t) + DEFINE_TO_UINT(uint16_t) + #endif + + #ifdef UINT32_MAX + DEFINE_FROM_UINT(uint32_t) + DEFINE_TO_UINT(uint32_t) + #endif + + #ifdef UINT64_MAX + DEFINE_FROM_UINT(uint64_t) + DEFINE_TO_UINT(uint64_t) + #endif + + #ifdef __UINT128_MAX + DEFINE_FROM_UINT(__uint128_t) + DEFINE_TO_UINT(__uint128_t) + #endif // copy, convenience copy @@ -308,7 +413,6 @@ def template_N(): return (diff > a->d0) ? {NS}·Status·borrow : {NS}·Status·ok; }} - Local {NS}·Status {NS}·multiply({NS}·T *product1 ,{NS}·T *product0 ,{NS}·T *a ,{NS}·T *b){{ uint64_t product = (uint64_t)a->d0 * (uint64_t)b->d0; product0->d0 = (uint32_t)product; @@ -418,7 +522,7 @@ def template_N(): return {NS}·shift_right(shift_count, spill, operand, fill); }} - Local const {NS}·Λ {NS}·λ = {{ + Local const {NS}·M {NS}·m = {{ .allocate_array = {NS}·allocate_array ,.allocate_array_zero = {NS}·allocate_array_zero diff --git "a/developer/cc\360\237\226\211/N16.lib.c" "b/developer/cc\360\237\226\211/N16.lib.c" index 3b77116..561b43d 100644 --- "a/developer/cc\360\237\226\211/N16.lib.c" +++ "b/developer/cc\360\237\226\211/N16.lib.c" @@ -111,9 +111,9 @@ N16·T* (*access)(N16·T*, Extent); void (*from_uint32)(N16·T *destination ,uint32_t value); - } N16·Λ; + } N16·M; - Local const N16·Λ N16·λ; // initialized in the LOCAL section + Local const N16·M N16·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N16·shift_right(shift_count, spill, operand, fill); } - Local const N16·Λ N16·λ = { + Local const N16·M N16·m = { .allocate_array = N16·allocate_array ,.allocate_array_zero = N16·allocate_array_zero diff --git "a/developer/cc\360\237\226\211/N32.lib.c" "b/developer/cc\360\237\226\211/N32.lib.c" index fba3c21..ccb3411 100644 --- "a/developer/cc\360\237\226\211/N32.lib.c" +++ "b/developer/cc\360\237\226\211/N32.lib.c" @@ -112,9 +112,9 @@ N32·T* (*access)(N32·T*, Extent); void (*from_uint32)(N32·T *destination ,uint32_t value); - } N32·Λ; + } N32·M; - Local const N32·Λ N32·λ; // initialized in the LOCAL section + Local const N32·M N32·m; // initialized in the LOCAL section #endif @@ -421,7 +421,7 @@ return N32·shift_right(shift_count, spill, operand, fill); } - Local const N32·Λ N32·λ = { + Local const N32·M N32·m = { .allocate_array = N32·allocate_array ,.allocate_array_zero = N32·allocate_array_zero diff --git "a/developer/cc\360\237\226\211/N64.lib.c" "b/developer/cc\360\237\226\211/N64.lib.c" index 9d98d58..6058e9b 100644 --- "a/developer/cc\360\237\226\211/N64.lib.c" +++ "b/developer/cc\360\237\226\211/N64.lib.c" @@ -114,9 +114,9 @@ N64·T* (*access)(N64·T*, Extent); void (*from_uint64)(N64·T *destination, uint64_t value); - } N64·Λ; + } N64·M; - Local const N64·Λ N64·λ; // initialized in the LOCAL section + Local const N64·M N64·m; // initialized in the LOCAL section #endif @@ -442,7 +442,7 @@ return N64·shift_right(shift_count, spill, operand, fill); } - Local const N64·Λ N64·λ = { + Local const N64·M N64·m = { .allocate_array = N64·allocate_array ,.allocate_array_zero = N64·allocate_array_zero ,.deallocate = N64·deallocate diff --git "a/developer/cc\360\237\226\211/N8.lib.c" "b/developer/cc\360\237\226\211/N8.lib.c" index ad52309..df6e01c 100644 --- "a/developer/cc\360\237\226\211/N8.lib.c" +++ "b/developer/cc\360\237\226\211/N8.lib.c" @@ -111,9 +111,9 @@ N8·T* (*access)(N8·T*, Extent); void (*from_uint32)(N8·T *destination ,uint32_t value); - } N8·Λ; + } N8·M; - Local const N8·Λ N8·λ; // initialized in the LOCAL section + Local const N8·M N8·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N8·shift_right(shift_count, spill, operand, fill); } - Local const N8·Λ N8·λ = { + Local const N8·M N8·m = { .allocate_array = N8·allocate_array ,.allocate_array_zero = N8·allocate_array_zero diff --git a/developer/experiment/encapsulated_array.c b/developer/experiment/encapsulated_array.c new file mode 100644 index 0000000..a318233 --- /dev/null +++ b/developer/experiment/encapsulated_array.c @@ -0,0 +1,32 @@ +#include +#include + +typedef void *Incognito; + +int f(Incognito x){ return 0;} + +int g(){ + void *x = NULL; + return f(x); // type mismatch correct? +} + +int main(){ + printf("All is good."); + return 0; +} + +/* +There is no type mismatch error as hoped. + + +2025-02-19T06:56:21Z[developer] +Thomas-developer@Stanley§/home/Thomas-masu/developer/N/developer/experiment§ +> gcc encapsulated_array.c + +2025-02-19T06:56:39Z[developer] +Thomas-developer@Stanley§/home/Thomas-masu/developer/N/developer/experiment§ +> ./a.out +All is good. +2025-02-19T06:56:43Z[developer] + +*/ diff --git a/developer/experiment/encapsulated_struct.c b/developer/experiment/encapsulated_struct.c new file mode 100644 index 0000000..47d3ee0 --- /dev/null +++ b/developer/experiment/encapsulated_struct.c @@ -0,0 +1,31 @@ +#include +#include + +typedef struct Incognito Incognito; + +int f(Incognito x){ return 0;} + +int g(){ + void *x = NULL; + return f(x); // type mismatch correct? +} + +int main(){ + printf("All is good."); + return 0; +} + +/* +This works when the encapsulated_array did not. We never even defined Incognito, where +as the Incognito array had a definition. + + +2025-02-19T06:57:34Z[developer] +Thomas-developer@Stanley§/home/Thomas-masu/developer/N/developer/experiment§ +> gcc encapsulated_struct.c +encapsulated_struct.c:6:17: error: parameter 1 (‘x’) has incomplete type + 6 | int f(Incognito x){ return 0;} + | ~~~~~~~~~~^ + + +*/ diff --git a/developer/experiment/try_letters.c b/developer/experiment/try_letters.c index 079d1a4..2bf88cd 100644 --- a/developer/experiment/try_letters.c +++ b/developer/experiment/try_letters.c @@ -3,7 +3,7 @@ // Define interface and instance types typedef struct { void (*print_value)(int); -} N32·Λ; // Interface type +} N32·M; // Interface type typedef struct { int value; @@ -15,7 +15,7 @@ void print_value_function(int value) { } // Default interface instance -const N32·Λ N32·λ = { +const N32·M N32·m = { .print_value = print_value_function }; @@ -25,7 +25,7 @@ int main() { // Call function via interface printf("Calling via interface: "); - N32·λ.print_value(instance.value); + N32·m.print_value(instance.value); return 0; } diff --git "a/document\360\237\226\211/Manifold_analogy.org" "b/document\360\237\226\211/Manifold_analogy.org" deleted file mode 100644 index e9e82e2..0000000 --- "a/document\360\237\226\211/Manifold_analogy.org" +++ /dev/null @@ -1,177 +0,0 @@ -#+TITLE: RT Tableau Method -#+AUTHOR: Thomas - -* Memory - -A *base-relative memory map* is a dictionary that associates symbol names with offsets from a base address. A C ~struct typedef~ is an example means for declaring a base-relative memory map. A base-relative memory map has a length associated with it. - -Another term for a *base-relative memory map* is *memory format*. A defined memory format can be bound to a name. The names are required to be distinct, though the formats bound to the names need not be. - -An *instance* of , where is the name of a memory format, is a region of memory that has been bound to memory format . - -The *type* of an instance is the name of its memory format. - -* Pointer - -A *pointer* is a memory address that has been bound to a memory format. This technique is used to assure that writes to the memory address conform to the bound memory format. This helps programs to respect the bounds of memory allocations. - -The *type* of a pointer is the name of the memory format it has been bound to. - -* Function Pointer - -The address of a function can be bound to a name and an array of memory formats, -one for each argument and the return value. - -The *type* of a function is defined by its name and its array of memory format names. - -The type of a function can be looked up from the function's name. - -* Function Dictionary - -A *function dictionary* is a list of function names and addresses, keyed by function names. - -A *function dictionary template* is a collection of function types associated with a specific memory format. - -A *function dictionary instance* is a collection of function implementations that conform to a function dictionary template. - -* Object - -If the potentially many instances of a given memory format are operated on exclusively by a closed set of functions, these functions can be collected into a dictionary called the memory format's *interface*. - -Conversely, there is no conventional name for an instance of memory that is manipulated by only a closed set of functions. In TTCA, the term *tableau* was introduced for such memory. (A *tableau* is a small chalkboard that was once used by students and could be erased and rewritten.) - -Another term that could be used for such memory is *taishou* (対象), meaning "subject" or "target" in Japanese. - -* Working with `.lib.c` Files in RT C - -In the RT C design, each module’s interface **and** implementation are contained in -a single file named `something.lib.c`. Traditional `.h` headers are replaced by -preprocessor-guarded interface sections, while the main implementation and any -“local” (private) code appear in separate blocks. If you want to learn more about -this format, there is a dedicated document explaining how `.lib.c` files are structured, -along with how and why they’re compiled. - -Briefly: - -- **Interface Section** - Declares the memory format (`struct N32·T`, for instance) and the function dictionary - type (`N32·Λ`), along with any prototypes that external code needs. - -- **Implementation Section** - Provides the actual definitions of the functions from the interface, compiled into - an object file (e.g., `N32.lib.o`) that goes into a library (`.a` or `.so`). - -- **Local Section** - (Guarded by `#ifdef LOCAL`) Contains private utility functions or test helpers. - Only included when a `.cli.c` test or other special code explicitly requests it. - -This structure keeps all relevant code (interface, implementation, internal helpers) -in a single `.lib.c` file, yet still enforces encapsulation via preprocessor macros. -It aligns well with the *tableau* and *function dictionary* concepts described here: -the memory format and method table are declared in the interface section, their -implementations go in the implementation section, and if you need advanced debugging -routines or private details, you can optionally include the local section. - - -* More about Tableau (Taishou) - -Below is a minimal example that shows how an instance of a memory format (`N32·T`) can be exclusively manipulated by a *function dictionary* (`N32·Λ`). This concrete “tableau” (taishou) usage illustrates how the memory is bound to specific operations—no external code should modify the memory except through the provided dictionary functions. - -#+BEGIN_SRC c -#include -#include - -// 1. Define the memory format (tableau) -typedef struct { - uint32_t value; -} N32·T; // This struct is our 'tableau'. - -// 2. Provide some functions that operate on N32·T -void N32·copy(N32·T *dst, const N32·T *src){ - dst->value = src->value; -} - -void N32·increment(N32·T *t){ - t->value++; -} - -void N32·print(const N32·T *t){ - printf("Value: %u\n", t->value); -} - -// 3. Declare a function dictionary (method table) -typedef struct { - void (*copy)(N32·T*, const N32·T*); - void (*increment)(N32·T*); - void (*print)(const N32·T*); -} N32·Λ; - -// 4. Provide a concrete instance of the dictionary -const N32·Λ N32·λ = { - .copy = N32·copy, - .increment = N32·increment, - .print = N32·print -}; - -// 5. Demonstrate usage in a main function -int main(void) { - // Create an instance of N32·T (our tableau) - N32·T my_number = { .value = 10 }; - - // Manipulate it exclusively through the function dictionary - N32·λ.increment(&my_number); // Increment by 1 - N32·λ.print(&my_number); // Output should show "Value: 11" - - // Create another instance and copy its contents - N32·T another_number = { .value = 42 }; - N32·λ.copy(&my_number, &another_number); - N32·λ.print(&my_number); // Output should show "Value: 42" - - return 0; -} -#+END_SRC - -When compiled and run (e.g., `gcc example.c -o example && ./example`), the program -prints: - -#+BEGIN_EXAMPLE -Value: 11 -Value: 42 -#+END_EXAMPLE - -In this way, `my_number` is a tableau. All modifications happen via a *closed set of -functions*—here, the operations are defined in the function dictionary `N32·λ`. No -external code is allowed to poke into `my_number.value` directly (beyond this demonstration), -upholding the idea that a “tableau” is memory dedicated to a specific “function dictionary.” - - -* Terminology Considerations - -The use of the word *type* in this document aligns with C’s conventions. However, other -programming paradigms, such as those in C++ and Java, may define *types* differently. -For example, C++ allows types to include behavior (methods), while C’s types only -define memory structure. - ---- - -**Summary of Key Terms:** -- *Memory Format*: A named layout of memory. -- *Instance*: A memory region adhering to a specific format. -- *Pointer*: A memory address bound to a memory format. -- *Function Dictionary*: A set of functions associated with a memory format. -- *Tableau/Taishou*: A memory instance operated on exclusively by a function dictionary. -- *Function Dictionary Template*: A function dictionary where function types replace function implementations. - - -A *base-relative memory map* is a dictionary that associates symbol names with offsets -from a base address. A C ~struct typedef~ is an example means for declaring a -base-relative memory map. A base-relative memory map has a length associated with it. - -Another term for a *base-relative memory map* is *memory format*. A -defined memory format can be bound to a name. The names are required -to be distinct, though the formats bound to the names need not be. - -An *instance* of , where is the name of a memory format, is a region -of memory that has been bound to memory format . - -The *type* of an instance is the name of its memory format. diff --git "a/document\360\237\226\211/Manifold_interpretation.org" "b/document\360\237\226\211/Manifold_interpretation.org" index e01e6af..ad85f35 100644 --- "a/document\360\237\226\211/Manifold_interpretation.org" +++ "b/document\360\237\226\211/Manifold_interpretation.org" @@ -1,6 +1,42 @@ #+TITLE: Manifold Interpretation #+AUTHOR: Thomas +* Concept + +The general idea is to use non-standard analysis to formalize the Arithmetic grid of +Kulisch and Miranker. + +The increment on K&M's grid is then the epsilon of non-standard analysis, or a high enough power of epsilon such that the analysis will standardize to zero. + +When at a first point located from input X, one can reach a second point by incrementing X, the two points are said to be neighbors, which might or might not be mutual. Neighbors are said to be connected, neighborliness is not mutual, then connection is directed. + +In this manner we can claim that our discrete work is non-standard analysis of continuous functions. We can then pull in terminology from topology and analysis. + +Well at least this establishes a framework for naming some variables. + +* Definition of a Manifold in this context. + +Given a tableau. + +Given a function space of commutable functions of N natural numbers. + +Define a mathematical object that consists of a subset of the functions that have +some of their inputs bound to come from the given tableau. + +Curry away the free variable inputs to each functions and build in a direct +reference to the shared tableau. + +Call this object a manifold. + +Consider the value of the tableau to be a location on the manifold. The set +of functions then behave differently depending where on the manifold we look. + +* Nonstandard extension + +Define a vector function as the values of the functions on the manifold, say F. This defines the local space. Our location in the local space is X, the inputs to the functions. + +There is incremental change in F with incremental change in X. Consider F to be describing a Hyperreal space. Standardization leads to differential behavior in the corresponding real space. + * Space and Hyperreal Local Space diff --git "a/document\360\237\226\211/RT_C_tableau_methhod.org" "b/document\360\237\226\211/RT_C_tableau_methhod.org" index e9e82e2..3e1f533 100644 --- "a/document\360\237\226\211/RT_C_tableau_methhod.org" +++ "b/document\360\237\226\211/RT_C_tableau_methhod.org" @@ -55,7 +55,7 @@ Briefly: - **Interface Section** Declares the memory format (`struct N32·T`, for instance) and the function dictionary - type (`N32·Λ`), along with any prototypes that external code needs. + type (`N32·M`), along with any prototypes that external code needs. - **Implementation Section** Provides the actual definitions of the functions from the interface, compiled into @@ -75,7 +75,7 @@ routines or private details, you can optionally include the local section. * More about Tableau (Taishou) -Below is a minimal example that shows how an instance of a memory format (`N32·T`) can be exclusively manipulated by a *function dictionary* (`N32·Λ`). This concrete “tableau” (taishou) usage illustrates how the memory is bound to specific operations—no external code should modify the memory except through the provided dictionary functions. +Below is a minimal example that shows how an instance of a memory format (`N32·T`) can be exclusively manipulated by a *function dictionary* (`N32·M`). This concrete “tableau” (taishou) usage illustrates how the memory is bound to specific operations—no external code should modify the memory except through the provided dictionary functions. #+BEGIN_SRC c #include @@ -104,10 +104,10 @@ typedef struct { void (*copy)(N32·T*, const N32·T*); void (*increment)(N32·T*); void (*print)(const N32·T*); -} N32·Λ; +} N32·M; // 4. Provide a concrete instance of the dictionary -const N32·Λ N32·λ = { +const N32·M N32·m = { .copy = N32·copy, .increment = N32·increment, .print = N32·print @@ -119,13 +119,13 @@ int main(void) { N32·T my_number = { .value = 10 }; // Manipulate it exclusively through the function dictionary - N32·λ.increment(&my_number); // Increment by 1 - N32·λ.print(&my_number); // Output should show "Value: 11" + N32·m.increment(&my_number); // Increment by 1 + N32·m.print(&my_number); // Output should show "Value: 11" // Create another instance and copy its contents N32·T another_number = { .value = 42 }; - N32·λ.copy(&my_number, &another_number); - N32·λ.print(&my_number); // Output should show "Value: 42" + N32·m.copy(&my_number, &another_number); + N32·m.print(&my_number); // Output should show "Value: 42" return 0; } @@ -140,7 +140,7 @@ Value: 42 #+END_EXAMPLE In this way, `my_number` is a tableau. All modifications happen via a *closed set of -functions*—here, the operations are defined in the function dictionary `N32·λ`. No +functions*—here, the operations are defined in the function dictionary `N32·m`. No external code is allowed to poke into `my_number.value` directly (beyond this demonstration), upholding the idea that a “tableau” is memory dedicated to a specific “function dictionary.” diff --git "a/document\360\237\226\211/RT_cli_c_file.org" "b/document\360\237\226\211/RT_cli_c_file.org" index 07f3760..06d6723 100644 --- "a/document\360\237\226\211/RT_cli_c_file.org" +++ "b/document\360\237\226\211/RT_cli_c_file.org" @@ -105,26 +105,26 @@ int main(int argc ,char **argv){ uint32_t b_val = (uint32_t)atoi(argv[2]); // Allocate N32 objects - N32·T *numbers = N32·λ.allocate_array(2 ,NULL); + N32·T *numbers = N32·m.allocate_array(2 ,NULL); if(!numbers){ printf("Allocation failed.\n"); return 2; } // Initialize - N32·λ.from_uint32(N32·λ.access(numbers ,0) ,a_val); - N32·λ.from_uint32(N32·λ.access(numbers ,1) ,b_val); + N32·m.from_uint32(N32·m.access(numbers ,0) ,a_val); + N32·m.from_uint32(N32·m.access(numbers ,1) ,b_val); // Perform add N32·T result; - N32·λ.add(&result, N32·λ.access(numbers ,0), N32·λ.access(numbers ,1)); + N32·m.add(&result, N32·m.access(numbers ,0), N32·m.access(numbers ,1)); printf("Sum of %u and %u is %u\n", a_val, b_val, result.d0); // Perform subtract - N32·λ.subtract(&result, N32·λ.access(numbers ,0), N32·λ.access(numbers ,1)); + N32·m.subtract(&result, N32·m.access(numbers ,0), N32·m.access(numbers ,1)); printf("Diff of %u and %u is %u\n", a_val, b_val, result.d0); - N32·λ.deallocate(numbers); + N32·m.deallocate(numbers); return 0; } #+END_SRC diff --git "a/document\360\237\226\211/unicode_character_use.org" "b/document\360\237\226\211/unicode_character_use.org" index 125e34b..dbc9361 100644 --- "a/document\360\237\226\211/unicode_character_use.org" +++ "b/document\360\237\226\211/unicode_character_use.org" @@ -12,9 +12,9 @@ The following characters are used: · - The center dot is a proposed namespace sepearator for C. Currently it is used ad hoc as the prefix portion of identifiers. There is some support in Python scripts. -Λ - This is used to name function dictionary type. Function dictionaries are struct types +M - This is used to name function dictionary type. Function dictionaries are struct types full of functions, and act as interfaces. -λ - A common name or prefix for an instance of a function dictionary type. This follows +m - A common name or prefix for an instance of a function dictionary type. This follows the convention that type names are PascalCase, and instance names are snake_case. diff --git a/tester/cc/N16.lib.c b/tester/cc/N16.lib.c index 3b77116..561b43d 100644 --- a/tester/cc/N16.lib.c +++ b/tester/cc/N16.lib.c @@ -111,9 +111,9 @@ N16·T* (*access)(N16·T*, Extent); void (*from_uint32)(N16·T *destination ,uint32_t value); - } N16·Λ; + } N16·M; - Local const N16·Λ N16·λ; // initialized in the LOCAL section + Local const N16·M N16·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N16·shift_right(shift_count, spill, operand, fill); } - Local const N16·Λ N16·λ = { + Local const N16·M N16·m = { .allocate_array = N16·allocate_array ,.allocate_array_zero = N16·allocate_array_zero diff --git a/tester/cc/N16PN.lib.c b/tester/cc/N16PN.lib.c index d7a2e05..bd63d9e 100644 --- a/tester/cc/N16PN.lib.c +++ b/tester/cc/N16PN.lib.c @@ -111,9 +111,9 @@ N16PN·T* (*access)(N16PN·T*, Extent); void (*from_uint32)(N16PN·T *destination ,uint32_t value); - } N16PN·Λ; + } N16PN·M; - Local const N16PN·Λ N16PN·λ; // initialized in the LOCAL section + Local const N16PN·M N16PN·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N16PN·shift_right(shift_count, spill, operand, fill); } - Local const N16PN·Λ N16PN·λ = { + Local const N16PN·M N16PN·m = { .allocate_array = N16PN·allocate_array ,.allocate_array_zero = N16PN·allocate_array_zero diff --git a/tester/cc/N32.lib.c b/tester/cc/N32.lib.c index fba3c21..ccb3411 100644 --- a/tester/cc/N32.lib.c +++ b/tester/cc/N32.lib.c @@ -112,9 +112,9 @@ N32·T* (*access)(N32·T*, Extent); void (*from_uint32)(N32·T *destination ,uint32_t value); - } N32·Λ; + } N32·M; - Local const N32·Λ N32·λ; // initialized in the LOCAL section + Local const N32·M N32·m; // initialized in the LOCAL section #endif @@ -421,7 +421,7 @@ return N32·shift_right(shift_count, spill, operand, fill); } - Local const N32·Λ N32·λ = { + Local const N32·M N32·m = { .allocate_array = N32·allocate_array ,.allocate_array_zero = N32·allocate_array_zero diff --git a/tester/cc/N32PN.lib.c b/tester/cc/N32PN.lib.c index 952f570..b62a6c4 100644 --- a/tester/cc/N32PN.lib.c +++ b/tester/cc/N32PN.lib.c @@ -112,9 +112,9 @@ N32PN·T* (*access)(N32PN·T*, Extent); void (*from_uint32)(N32PN·T *destination ,uint32_t value); - } N32PN·Λ; + } N32PN·M; - Local const N32PN·Λ N32PN·λ; // initialized in the LOCAL section + Local const N32PN·M N32PN·m; // initialized in the LOCAL section #endif @@ -421,7 +421,7 @@ return N32PN·shift_right(shift_count, spill, operand, fill); } - Local const N32PN·Λ N32PN·λ = { + Local const N32PN·M N32PN·m = { .allocate_array = N32PN·allocate_array ,.allocate_array_zero = N32PN·allocate_array_zero diff --git a/tester/cc/N32_1x32.lib.c b/tester/cc/N32_1x32.lib.c index c43bc8b..c2f97f2 100644 --- a/tester/cc/N32_1x32.lib.c +++ b/tester/cc/N32_1x32.lib.c @@ -112,9 +112,9 @@ N32_1x32·T* (*access)(N32_1x32·T*, Extent); void (*from_uint32)(N32_1x32·T *destination ,uint32_t value); - } N32_1x32·Λ; + } N32_1x32·M; - Local const N32_1x32·Λ N32_1x32·λ; // initialized in the LOCAL section + Local const N32_1x32·M N32_1x32·m; // initialized in the LOCAL section #endif @@ -421,7 +421,7 @@ return N32_1x32·shift_right(shift_count, spill, operand, fill); } - Local const N32_1x32·Λ N32_1x32·λ = { + Local const N32_1x32·M N32_1x32·m = { .allocate_array = N32_1x32·allocate_array ,.allocate_array_zero = N32_1x32·allocate_array_zero diff --git a/tester/cc/N32_4x8.lib.c b/tester/cc/N32_4x8.lib.c index 22cced5..b66c143 100644 --- a/tester/cc/N32_4x8.lib.c +++ b/tester/cc/N32_4x8.lib.c @@ -112,9 +112,9 @@ N32_4x8·T* (*access)(N32_4x8·T*, Extent); void (*from_uint32)(N32_4x8·T *destination ,uint32_t value); - } N32_4x8·Λ; + } N32_4x8·M; - Local const N32_4x8·Λ N32_4x8·λ; // initialized in the LOCAL section + Local const N32_4x8·M N32_4x8·m; // initialized in the LOCAL section #endif @@ -421,7 +421,7 @@ return N32_4x8·shift_right(shift_count, spill, operand, fill); } - Local const N32_4x8·Λ N32_4x8·λ = { + Local const N32_4x8·M N32_4x8·m = { .allocate_array = N32_4x8·allocate_array ,.allocate_array_zero = N32_4x8·allocate_array_zero diff --git a/tester/cc/N64.lib.c b/tester/cc/N64.lib.c index 9d98d58..6058e9b 100644 --- a/tester/cc/N64.lib.c +++ b/tester/cc/N64.lib.c @@ -114,9 +114,9 @@ N64·T* (*access)(N64·T*, Extent); void (*from_uint64)(N64·T *destination, uint64_t value); - } N64·Λ; + } N64·M; - Local const N64·Λ N64·λ; // initialized in the LOCAL section + Local const N64·M N64·m; // initialized in the LOCAL section #endif @@ -442,7 +442,7 @@ return N64·shift_right(shift_count, spill, operand, fill); } - Local const N64·Λ N64·λ = { + Local const N64·M N64·m = { .allocate_array = N64·allocate_array ,.allocate_array_zero = N64·allocate_array_zero ,.deallocate = N64·deallocate diff --git a/tester/cc/N64PN.lib.c b/tester/cc/N64PN.lib.c index 583ad08..97f74fc 100644 --- a/tester/cc/N64PN.lib.c +++ b/tester/cc/N64PN.lib.c @@ -114,9 +114,9 @@ N64PN·T* (*access)(N64PN·T*, Extent); void (*from_uint64)(N64PN·T *destination, uint64_t value); - } N64PN·Λ; + } N64PN·M; - Local const N64PN·Λ N64PN·λ; // initialized in the LOCAL section + Local const N64PN·M N64PN·m; // initialized in the LOCAL section #endif @@ -442,7 +442,7 @@ return N64PN·shift_right(shift_count, spill, operand, fill); } - Local const N64PN·Λ N64PN·λ = { + Local const N64PN·M N64PN·m = { .allocate_array = N64PN·allocate_array ,.allocate_array_zero = N64PN·allocate_array_zero ,.deallocate = N64PN·deallocate diff --git a/tester/cc/N8.lib.c b/tester/cc/N8.lib.c index ad52309..df6e01c 100644 --- a/tester/cc/N8.lib.c +++ b/tester/cc/N8.lib.c @@ -111,9 +111,9 @@ N8·T* (*access)(N8·T*, Extent); void (*from_uint32)(N8·T *destination ,uint32_t value); - } N8·Λ; + } N8·M; - Local const N8·Λ N8·λ; // initialized in the LOCAL section + Local const N8·M N8·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N8·shift_right(shift_count, spill, operand, fill); } - Local const N8·Λ N8·λ = { + Local const N8·M N8·m = { .allocate_array = N8·allocate_array ,.allocate_array_zero = N8·allocate_array_zero diff --git a/tester/cc/N8PN.lib.c b/tester/cc/N8PN.lib.c index 9cfd66d..3955f1c 100644 --- a/tester/cc/N8PN.lib.c +++ b/tester/cc/N8PN.lib.c @@ -111,9 +111,9 @@ N8PN·T* (*access)(N8PN·T*, Extent); void (*from_uint32)(N8PN·T *destination ,uint32_t value); - } N8PN·Λ; + } N8PN·M; - Local const N8PN·Λ N8PN·λ; // initialized in the LOCAL section + Local const N8PN·M N8PN·m; // initialized in the LOCAL section #endif @@ -397,7 +397,7 @@ return N8PN·shift_right(shift_count, spill, operand, fill); } - Local const N8PN·Λ N8PN·λ = { + Local const N8PN·M N8PN·m = { .allocate_array = N8PN·allocate_array ,.allocate_array_zero = N8PN·allocate_array_zero diff --git a/tester/cc/test_N32.cli.c b/tester/cc/test_N32.cli.c index 563711f..25451bb 100644 --- a/tester/cc/test_N32.cli.c +++ b/tester/cc/test_N32.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(2 ,NULL); + N32·T *array = N32·m.allocate_array(2 ,NULL); if( !array ) return false; // Access elements via access function - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); // Assign value and copy - N32·λ.from_uint32(a ,42); - N32·λ.copy(b ,a); + N32·m.from_uint32(a ,42); + N32·m.copy(b ,a); - bool success = ( N32·λ.compare(b ,a) == N32·Order_eq ); - N32·λ.deallocate(array); + bool success = ( N32·m.compare(b ,a) == N32·Order_eq ); + N32·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3 ,NULL); + N32·T *array = N32·m.allocate_array(3 ,NULL); if( !array ) return false; - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); - N32·T *result = N32·λ.access(array ,2); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); + N32·T *result = N32·m.access(array ,2); - N32·λ.from_uint32(a ,20); - N32·λ.from_uint32(b ,22); + N32·m.from_uint32(a ,20); + N32·m.from_uint32(b ,22); - if( N32·λ.add(result ,a ,b) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_gt ) return false; + if( N32·m.add(result ,a ,b) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_gt ) return false; - if( N32·λ.subtract(result ,b ,a) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_lt ) return false; + if( N32·m.subtract(result ,b ,a) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_lt ) return false; - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *result = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *result = N32·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.from_uint32(b, 0xF0F0F0F0); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32·λ.bit_and(result, a, b); - N32·λ.from_uint32(a, 0x00000000); - if(N32·λ.compare(result, a) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_and(result, a, b); + N32·m.from_uint32(a, 0x00000000); + if(N32·m.compare(result, a) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32·λ.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32·λ.bit_or(result, a, b); - N32·λ.from_uint32(b, 0xFFFFFFFF); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_or(result, a, b); + N32·m.from_uint32(b, 0xFFFFFFFF); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F0); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F0); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_twos_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F1); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_twos_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F1); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *c = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *c = N32·m.access(array, 2); // First set: a=0, b=42, c=42 - N32·λ.from_uint32(a, 0); - N32·λ.from_uint32(b, 42); - N32·λ.from_uint32(c, 42); + N32·m.from_uint32(a, 0); + N32·m.from_uint32(b, 42); + N32·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(!N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32·λ.eq(b, c)){ - N32·λ.deallocate(array); + if(!N32·m.eq(b, c)){ + N32·m.deallocate(array); return false; } // eq(a, b) => false - if(N32·λ.eq(a, b)){ - N32·λ.deallocate(array); + if(N32·m.eq(a, b)){ + N32·m.deallocate(array); return false; } // compare(a, b) => N32·Order_lt - if(N32·λ.compare(a, b) != N32·Order_lt){ - N32·λ.deallocate(array); + if(N32·m.compare(a, b) != N32·Order_lt){ + N32·m.deallocate(array); return false; } // compare(b, a) => N32·Order_gt - if(N32·λ.compare(b, a) != N32·Order_gt){ - N32·λ.deallocate(array); + if(N32·m.compare(b, a) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // compare(b, c) => N32·Order_eq - if(N32·λ.compare(b, c) != N32·Order_eq){ - N32·λ.deallocate(array); + if(N32·m.compare(b, c) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32·λ.lt(a, b) || !N32·λ.gt(b, a)){ - N32·λ.deallocate(array); + if(!N32·m.lt(a, b) || !N32·m.gt(b, a)){ + N32·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32·λ.from_uint32(a, 100); - N32·λ.from_uint32(b, 50); - if(N32·λ.compare(a, b) != N32·Order_gt){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 100); + N32·m.from_uint32(b, 50); + if(N32·m.compare(a, b) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *operand = N32·λ.access(array, 0); - N32·T *fill = N32·λ.access(array, 1); - N32·T *spill = N32·λ.access(array, 2); + N32·T *operand = N32·m.access(array, 0); + N32·T *fill = N32·m.access(array, 1); + N32·T *spill = N32·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32·λ.from_uint32(operand, 1); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(4, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 1); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(4, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(array); return false; } - N32·T *temp = N32·λ.allocate_array(1, NULL); + N32·T *temp = N32·m.allocate_array(1, NULL); if(!temp){ - N32·λ.deallocate(array); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 16); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 16); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(fill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(fill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(spill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(spill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(operand)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(operand)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 1); - if(N32·λ.compare(spill, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 1); + if(N32·m.compare(spill, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_right(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_right(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0x40000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0x40000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(spill, 0); - if(N32·λ.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(spill, 0); + if(N32·m.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0xC0000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0xC0000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.deallocate(temp); + N32·m.deallocate(array); return true; } diff --git a/tester/cc/test_N32_0.cli.c b/tester/cc/test_N32_0.cli.c index 5e2f792..58b8f3c 100644 --- a/tester/cc/test_N32_0.cli.c +++ b/tester/cc/test_N32_0.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(1 ,NULL); + N32·T *array = N32·m.allocate_array(1 ,NULL); if( !array ) return false; // Access elements via access function - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); // Assign value and copy - N32·λ.from_uint32(a ,42); - N32·λ.copy(b ,a); + N32·m.from_uint32(a ,42); + N32·m.copy(b ,a); - bool success = ( N32·λ.compare(b ,a) == N32·Order_eq ); - N32·λ.deallocate(array); + bool success = ( N32·m.compare(b ,a) == N32·Order_eq ); + N32·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(2 ,NULL); + N32·T *array = N32·m.allocate_array(2 ,NULL); if( !array ) return false; - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); - N32·T *result = N32·λ.access(array ,2); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); + N32·T *result = N32·m.access(array ,2); - N32·λ.from_uint32(a ,20); - N32·λ.from_uint32(b ,22); + N32·m.from_uint32(a ,20); + N32·m.from_uint32(b ,22); - if( N32·λ.add(result ,a ,b) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_gt ) return false; + if( N32·m.add(result ,a ,b) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_gt ) return false; - if( N32·λ.subtract(result ,b ,a) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_lt ) return false; + if( N32·m.subtract(result ,b ,a) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_lt ) return false; - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(2, NULL); + N32·T *array = N32·m.allocate_array(2, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *result = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *result = N32·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.from_uint32(b, 0xF0F0F0F0); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32·λ.bit_and(result, a, b); - N32·λ.from_uint32(a, 0x00000000); - if(N32·λ.compare(result, a) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_and(result, a, b); + N32·m.from_uint32(a, 0x00000000); + if(N32·m.compare(result, a) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32·λ.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32·λ.bit_or(result, a, b); - N32·λ.from_uint32(b, 0xFFFFFFFF); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_or(result, a, b); + N32·m.from_uint32(b, 0xFFFFFFFF); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F0); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F0); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_twos_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F1); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_twos_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F1); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(2, NULL); + N32·T *array = N32·m.allocate_array(2, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *c = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *c = N32·m.access(array, 2); // First set: a=0, b=42, c=42 - N32·λ.from_uint32(a, 0); - N32·λ.from_uint32(b, 42); - N32·λ.from_uint32(c, 42); + N32·m.from_uint32(a, 0); + N32·m.from_uint32(b, 42); + N32·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(!N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32·λ.eq(b, c)){ - N32·λ.deallocate(array); + if(!N32·m.eq(b, c)){ + N32·m.deallocate(array); return false; } // eq(a, b) => false - if(N32·λ.eq(a, b)){ - N32·λ.deallocate(array); + if(N32·m.eq(a, b)){ + N32·m.deallocate(array); return false; } // compare(a, b) => N32·Order_lt - if(N32·λ.compare(a, b) != N32·Order_lt){ - N32·λ.deallocate(array); + if(N32·m.compare(a, b) != N32·Order_lt){ + N32·m.deallocate(array); return false; } // compare(b, a) => N32·Order_gt - if(N32·λ.compare(b, a) != N32·Order_gt){ - N32·λ.deallocate(array); + if(N32·m.compare(b, a) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // compare(b, c) => N32·Order_eq - if(N32·λ.compare(b, c) != N32·Order_eq){ - N32·λ.deallocate(array); + if(N32·m.compare(b, c) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32·λ.lt(a, b) || !N32·λ.gt(b, a)){ - N32·λ.deallocate(array); + if(!N32·m.lt(a, b) || !N32·m.gt(b, a)){ + N32·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32·λ.from_uint32(a, 100); - N32·λ.from_uint32(b, 50); - if(N32·λ.compare(a, b) != N32·Order_gt){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 100); + N32·m.from_uint32(b, 50); + if(N32·m.compare(a, b) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32·T *array = N32·λ.allocate_array(2, NULL); + N32·T *array = N32·m.allocate_array(2, NULL); if(!array) return false; - N32·T *operand = N32·λ.access(array, 0); - N32·T *fill = N32·λ.access(array, 1); - N32·T *spill = N32·λ.access(array, 2); + N32·T *operand = N32·m.access(array, 0); + N32·T *fill = N32·m.access(array, 1); + N32·T *spill = N32·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32·λ.from_uint32(operand, 1); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(4, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 1); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(4, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(array); return false; } - N32·T *temp = N32·λ.allocate_array(1, NULL); + N32·T *temp = N32·m.allocate_array(1, NULL); if(!temp){ - N32·λ.deallocate(array); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 16); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 16); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(fill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(fill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(spill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(spill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(operand)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(operand)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 1); - if(N32·λ.compare(spill, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 1); + if(N32·m.compare(spill, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_right(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_right(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0x40000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0x40000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(spill, 0); - if(N32·λ.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(spill, 0); + if(N32·m.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0xC0000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0xC0000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.deallocate(temp); + N32·m.deallocate(array); return true; } diff --git a/tester/cc/test_N32_1x32.cli.c b/tester/cc/test_N32_1x32.cli.c index 2960d43..3c9beb4 100644 --- a/tester/cc/test_N32_1x32.cli.c +++ b/tester/cc/test_N32_1x32.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(2 ,NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(2 ,NULL); if( !array ) return false; // Access elements via access function - N32_1x32·T *a = N32_1x32·λ.access(array ,0); - N32_1x32·T *b = N32_1x32·λ.access(array ,1); + N32_1x32·T *a = N32_1x32·m.access(array ,0); + N32_1x32·T *b = N32_1x32·m.access(array ,1); // Assign value and copy - N32_1x32·λ.from_uint32(a ,42); - N32_1x32·λ.copy(b ,a); + N32_1x32·m.from_uint32(a ,42); + N32_1x32·m.copy(b ,a); - bool success = ( N32_1x32·λ.compare(b ,a) == N32_1x32·Order_eq ); - N32_1x32·λ.deallocate(array); + bool success = ( N32_1x32·m.compare(b ,a) == N32_1x32·Order_eq ); + N32_1x32·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(3 ,NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(3 ,NULL); if( !array ) return false; - N32_1x32·T *a = N32_1x32·λ.access(array ,0); - N32_1x32·T *b = N32_1x32·λ.access(array ,1); - N32_1x32·T *result = N32_1x32·λ.access(array ,2); + N32_1x32·T *a = N32_1x32·m.access(array ,0); + N32_1x32·T *b = N32_1x32·m.access(array ,1); + N32_1x32·T *result = N32_1x32·m.access(array ,2); - N32_1x32·λ.from_uint32(a ,20); - N32_1x32·λ.from_uint32(b ,22); + N32_1x32·m.from_uint32(a ,20); + N32_1x32·m.from_uint32(b ,22); - if( N32_1x32·λ.add(result ,a ,b) != N32_1x32·Status·ok ) return false; - if( N32_1x32·λ.compare(result ,N32_1x32·λ.access(array ,0)) != N32_1x32·Order_gt ) return false; + if( N32_1x32·m.add(result ,a ,b) != N32_1x32·Status·ok ) return false; + if( N32_1x32·m.compare(result ,N32_1x32·m.access(array ,0)) != N32_1x32·Order_gt ) return false; - if( N32_1x32·λ.subtract(result ,b ,a) != N32_1x32·Status·ok ) return false; - if( N32_1x32·λ.compare(result ,N32_1x32·λ.access(array ,0)) != N32_1x32·Order_lt ) return false; + if( N32_1x32·m.subtract(result ,b ,a) != N32_1x32·Status·ok ) return false; + if( N32_1x32·m.compare(result ,N32_1x32·m.access(array ,0)) != N32_1x32·Order_lt ) return false; - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(3, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(3, NULL); if(!array) return false; - N32_1x32·T *a = N32_1x32·λ.access(array, 0); - N32_1x32·T *b = N32_1x32·λ.access(array, 1); - N32_1x32·T *result = N32_1x32·λ.access(array, 2); + N32_1x32·T *a = N32_1x32·m.access(array, 0); + N32_1x32·T *b = N32_1x32·m.access(array, 1); + N32_1x32·T *result = N32_1x32·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F0); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32_1x32·λ.bit_and(result, a, b); - N32_1x32·λ.from_uint32(a, 0x00000000); - if(N32_1x32·λ.compare(result, a) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.bit_and(result, a, b); + N32_1x32·m.from_uint32(a, 0x00000000); + if(N32_1x32·m.compare(result, a) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32_1x32·λ.bit_or(result, a, b); - N32_1x32·λ.from_uint32(b, 0xFFFFFFFF); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.bit_or(result, a, b); + N32_1x32·m.from_uint32(b, 0xFFFFFFFF); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.bit_complement(result, a); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F0); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.bit_complement(result, a); + N32_1x32·m.from_uint32(b, 0xF0F0F0F0); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.bit_twos_complement(result, a); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F1); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.bit_twos_complement(result, a); + N32_1x32·m.from_uint32(b, 0xF0F0F0F1); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(3, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(3, NULL); if(!array) return false; - N32_1x32·T *a = N32_1x32·λ.access(array, 0); - N32_1x32·T *b = N32_1x32·λ.access(array, 1); - N32_1x32·T *c = N32_1x32·λ.access(array, 2); + N32_1x32·T *a = N32_1x32·m.access(array, 0); + N32_1x32·T *b = N32_1x32·m.access(array, 1); + N32_1x32·T *c = N32_1x32·m.access(array, 2); // First set: a=0, b=42, c=42 - N32_1x32·λ.from_uint32(a, 0); - N32_1x32·λ.from_uint32(b, 42); - N32_1x32·λ.from_uint32(c, 42); + N32_1x32·m.from_uint32(a, 0); + N32_1x32·m.from_uint32(b, 42); + N32_1x32·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32_1x32·λ.eq_zero(a)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(a)){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_1x32·λ.eq_zero(b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(b)){ + N32_1x32·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32_1x32·λ.eq(b, c)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq(b, c)){ + N32_1x32·m.deallocate(array); return false; } // eq(a, b) => false - if(N32_1x32·λ.eq(a, b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq(a, b)){ + N32_1x32·m.deallocate(array); return false; } // compare(a, b) => N32_1x32·Order_lt - if(N32_1x32·λ.compare(a, b) != N32_1x32·Order_lt){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(a, b) != N32_1x32·Order_lt){ + N32_1x32·m.deallocate(array); return false; } // compare(b, a) => N32_1x32·Order_gt - if(N32_1x32·λ.compare(b, a) != N32_1x32·Order_gt){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(b, a) != N32_1x32·Order_gt){ + N32_1x32·m.deallocate(array); return false; } // compare(b, c) => N32_1x32·Order_eq - if(N32_1x32·λ.compare(b, c) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(b, c) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32_1x32·λ.lt(a, b) || !N32_1x32·λ.gt(b, a)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.lt(a, b) || !N32_1x32·m.gt(b, a)){ + N32_1x32·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32_1x32·λ.from_uint32(a, 100); - N32_1x32·λ.from_uint32(b, 50); - if(N32_1x32·λ.compare(a, b) != N32_1x32·Order_gt){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 100); + N32_1x32·m.from_uint32(b, 50); + if(N32_1x32·m.compare(a, b) != N32_1x32·Order_gt){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32_1x32·λ.eq_zero(a)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(a)){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_1x32·λ.eq_zero(b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(b)){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32_1x32·T *array = N32_1x32·λ.allocate_array(3, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(3, NULL); if(!array) return false; - N32_1x32·T *operand = N32_1x32·λ.access(array, 0); - N32_1x32·T *fill = N32_1x32·λ.access(array, 1); - N32_1x32·T *spill = N32_1x32·λ.access(array, 2); + N32_1x32·T *operand = N32_1x32·m.access(array, 0); + N32_1x32·T *fill = N32_1x32·m.access(array, 1); + N32_1x32·T *spill = N32_1x32·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32_1x32·λ.from_uint32(operand, 1); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_left(4, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 1); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_left(4, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·T *temp = N32_1x32·λ.allocate_array(1, NULL); + N32_1x32·T *temp = N32_1x32·m.allocate_array(1, NULL); if(!temp){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 16); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 16); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(N32_1x32·λ.compare(fill, N32_1x32·zero) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(fill, N32_1x32·zero) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(N32_1x32·λ.compare(spill, N32_1x32·zero) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(spill, N32_1x32·zero) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_left(1, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_left(1, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(operand)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(operand)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 1); - if(N32_1x32·λ.compare(spill, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 1); + if(N32_1x32·m.compare(spill, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_right(1, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_right(1, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 0x40000000); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 0x40000000); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(spill)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(spill)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.arithmetic_shift_right(1, operand, spill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.arithmetic_shift_right(1, operand, spill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 0xC0000000); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 0xC0000000); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(spill)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(spill)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return true; } diff --git a/tester/cc/test_N32_1x32_0.cli.c b/tester/cc/test_N32_1x32_0.cli.c index 42cae99..6a32d9f 100644 --- a/tester/cc/test_N32_1x32_0.cli.c +++ b/tester/cc/test_N32_1x32_0.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(1 ,NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(1 ,NULL); if( !array ) return false; // Access elements via access function - N32_1x32·T *a = N32_1x32·λ.access(array ,0); - N32_1x32·T *b = N32_1x32·λ.access(array ,1); + N32_1x32·T *a = N32_1x32·m.access(array ,0); + N32_1x32·T *b = N32_1x32·m.access(array ,1); // Assign value and copy - N32_1x32·λ.from_uint32(a ,42); - N32_1x32·λ.copy(b ,a); + N32_1x32·m.from_uint32(a ,42); + N32_1x32·m.copy(b ,a); - bool success = ( N32_1x32·λ.compare(b ,a) == N32_1x32·Order_eq ); - N32_1x32·λ.deallocate(array); + bool success = ( N32_1x32·m.compare(b ,a) == N32_1x32·Order_eq ); + N32_1x32·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(2 ,NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(2 ,NULL); if( !array ) return false; - N32_1x32·T *a = N32_1x32·λ.access(array ,0); - N32_1x32·T *b = N32_1x32·λ.access(array ,1); - N32_1x32·T *result = N32_1x32·λ.access(array ,2); + N32_1x32·T *a = N32_1x32·m.access(array ,0); + N32_1x32·T *b = N32_1x32·m.access(array ,1); + N32_1x32·T *result = N32_1x32·m.access(array ,2); - N32_1x32·λ.from_uint32(a ,20); - N32_1x32·λ.from_uint32(b ,22); + N32_1x32·m.from_uint32(a ,20); + N32_1x32·m.from_uint32(b ,22); - if( N32_1x32·λ.add(result ,a ,b) != N32_1x32·Status·ok ) return false; - if( N32_1x32·λ.compare(result ,N32_1x32·λ.access(array ,0)) != N32_1x32·Order_gt ) return false; + if( N32_1x32·m.add(result ,a ,b) != N32_1x32·Status·ok ) return false; + if( N32_1x32·m.compare(result ,N32_1x32·m.access(array ,0)) != N32_1x32·Order_gt ) return false; - if( N32_1x32·λ.subtract(result ,b ,a) != N32_1x32·Status·ok ) return false; - if( N32_1x32·λ.compare(result ,N32_1x32·λ.access(array ,0)) != N32_1x32·Order_lt ) return false; + if( N32_1x32·m.subtract(result ,b ,a) != N32_1x32·Status·ok ) return false; + if( N32_1x32·m.compare(result ,N32_1x32·m.access(array ,0)) != N32_1x32·Order_lt ) return false; - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(2, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(2, NULL); if(!array) return false; - N32_1x32·T *a = N32_1x32·λ.access(array, 0); - N32_1x32·T *b = N32_1x32·λ.access(array, 1); - N32_1x32·T *result = N32_1x32·λ.access(array, 2); + N32_1x32·T *a = N32_1x32·m.access(array, 0); + N32_1x32·T *b = N32_1x32·m.access(array, 1); + N32_1x32·T *result = N32_1x32·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F0); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32_1x32·λ.bit_and(result, a, b); - N32_1x32·λ.from_uint32(a, 0x00000000); - if(N32_1x32·λ.compare(result, a) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.bit_and(result, a, b); + N32_1x32·m.from_uint32(a, 0x00000000); + if(N32_1x32·m.compare(result, a) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32_1x32·λ.bit_or(result, a, b); - N32_1x32·λ.from_uint32(b, 0xFFFFFFFF); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.bit_or(result, a, b); + N32_1x32·m.from_uint32(b, 0xFFFFFFFF); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.bit_complement(result, a); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F0); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.bit_complement(result, a); + N32_1x32·m.from_uint32(b, 0xF0F0F0F0); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32_1x32·λ.from_uint32(a, 0x0F0F0F0F); - N32_1x32·λ.bit_twos_complement(result, a); - N32_1x32·λ.from_uint32(b, 0xF0F0F0F1); - if(N32_1x32·λ.compare(result, b) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 0x0F0F0F0F); + N32_1x32·m.bit_twos_complement(result, a); + N32_1x32·m.from_uint32(b, 0xF0F0F0F1); + if(N32_1x32·m.compare(result, b) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32_1x32·T *array = N32_1x32·λ.allocate_array(2, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(2, NULL); if(!array) return false; - N32_1x32·T *a = N32_1x32·λ.access(array, 0); - N32_1x32·T *b = N32_1x32·λ.access(array, 1); - N32_1x32·T *c = N32_1x32·λ.access(array, 2); + N32_1x32·T *a = N32_1x32·m.access(array, 0); + N32_1x32·T *b = N32_1x32·m.access(array, 1); + N32_1x32·T *c = N32_1x32·m.access(array, 2); // First set: a=0, b=42, c=42 - N32_1x32·λ.from_uint32(a, 0); - N32_1x32·λ.from_uint32(b, 42); - N32_1x32·λ.from_uint32(c, 42); + N32_1x32·m.from_uint32(a, 0); + N32_1x32·m.from_uint32(b, 42); + N32_1x32·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32_1x32·λ.eq_zero(a)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(a)){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_1x32·λ.eq_zero(b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(b)){ + N32_1x32·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32_1x32·λ.eq(b, c)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq(b, c)){ + N32_1x32·m.deallocate(array); return false; } // eq(a, b) => false - if(N32_1x32·λ.eq(a, b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq(a, b)){ + N32_1x32·m.deallocate(array); return false; } // compare(a, b) => N32_1x32·Order_lt - if(N32_1x32·λ.compare(a, b) != N32_1x32·Order_lt){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(a, b) != N32_1x32·Order_lt){ + N32_1x32·m.deallocate(array); return false; } // compare(b, a) => N32_1x32·Order_gt - if(N32_1x32·λ.compare(b, a) != N32_1x32·Order_gt){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(b, a) != N32_1x32·Order_gt){ + N32_1x32·m.deallocate(array); return false; } // compare(b, c) => N32_1x32·Order_eq - if(N32_1x32·λ.compare(b, c) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(b, c) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32_1x32·λ.lt(a, b) || !N32_1x32·λ.gt(b, a)){ - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.lt(a, b) || !N32_1x32·m.gt(b, a)){ + N32_1x32·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32_1x32·λ.from_uint32(a, 100); - N32_1x32·λ.from_uint32(b, 50); - if(N32_1x32·λ.compare(a, b) != N32_1x32·Order_gt){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(a, 100); + N32_1x32·m.from_uint32(b, 50); + if(N32_1x32·m.compare(a, b) != N32_1x32·Order_gt){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32_1x32·λ.eq_zero(a)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(a)){ + N32_1x32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_1x32·λ.eq_zero(b)){ - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.eq_zero(b)){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32_1x32·T *array = N32_1x32·λ.allocate_array(2, NULL); + N32_1x32·T *array = N32_1x32·m.allocate_array(2, NULL); if(!array) return false; - N32_1x32·T *operand = N32_1x32·λ.access(array, 0); - N32_1x32·T *fill = N32_1x32·λ.access(array, 1); - N32_1x32·T *spill = N32_1x32·λ.access(array, 2); + N32_1x32·T *operand = N32_1x32·m.access(array, 0); + N32_1x32·T *fill = N32_1x32·m.access(array, 1); + N32_1x32·T *spill = N32_1x32·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32_1x32·λ.from_uint32(operand, 1); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_left(4, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 1); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_left(4, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(array); return false; } - N32_1x32·T *temp = N32_1x32·λ.allocate_array(1, NULL); + N32_1x32·T *temp = N32_1x32·m.allocate_array(1, NULL); if(!temp){ - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 16); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 16); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(N32_1x32·λ.compare(fill, N32_1x32·zero) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(fill, N32_1x32·zero) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(N32_1x32·λ.compare(spill, N32_1x32·zero) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(N32_1x32·m.compare(spill, N32_1x32·zero) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_left(1, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_left(1, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(operand)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(operand)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 1); - if(N32_1x32·λ.compare(spill, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 1); + if(N32_1x32·m.compare(spill, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(fill, 0); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.shift_right(1, spill, operand, fill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(fill, 0); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.shift_right(1, spill, operand, fill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 0x40000000); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 0x40000000); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(spill)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(spill)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32_1x32·λ.from_uint32(operand, 0x80000000); - N32_1x32·λ.from_uint32(spill, 0); - if(N32_1x32·λ.arithmetic_shift_right(1, operand, spill) != N32_1x32·Status·ok){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(operand, 0x80000000); + N32_1x32·m.from_uint32(spill, 0); + if(N32_1x32·m.arithmetic_shift_right(1, operand, spill) != N32_1x32·Status·ok){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.from_uint32(temp, 0xC0000000); - if(N32_1x32·λ.compare(operand, temp) != N32_1x32·Order_eq){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.from_uint32(temp, 0xC0000000); + if(N32_1x32·m.compare(operand, temp) != N32_1x32·Order_eq){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - if(!N32_1x32·λ.eq_zero(spill)){ - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + if(!N32_1x32·m.eq_zero(spill)){ + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return false; } - N32_1x32·λ.deallocate(temp); - N32_1x32·λ.deallocate(array); + N32_1x32·m.deallocate(temp); + N32_1x32·m.deallocate(array); return true; } diff --git a/tester/cc/test_N32_4x8.cli.c b/tester/cc/test_N32_4x8.cli.c index c540478..ecbc457 100644 --- a/tester/cc/test_N32_4x8.cli.c +++ b/tester/cc/test_N32_4x8.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(2 ,NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(2 ,NULL); if( !array ) return false; // Access elements via access function - N32_4x8·T *a = N32_4x8·λ.access(array ,0); - N32_4x8·T *b = N32_4x8·λ.access(array ,1); + N32_4x8·T *a = N32_4x8·m.access(array ,0); + N32_4x8·T *b = N32_4x8·m.access(array ,1); // Assign value and copy - N32_4x8·λ.from_uint32(a ,42); - N32_4x8·λ.copy(b ,a); + N32_4x8·m.from_uint32(a ,42); + N32_4x8·m.copy(b ,a); - bool success = ( N32_4x8·λ.compare(b ,a) == N32_4x8·Order_eq ); - N32_4x8·λ.deallocate(array); + bool success = ( N32_4x8·m.compare(b ,a) == N32_4x8·Order_eq ); + N32_4x8·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(3 ,NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(3 ,NULL); if( !array ) return false; - N32_4x8·T *a = N32_4x8·λ.access(array ,0); - N32_4x8·T *b = N32_4x8·λ.access(array ,1); - N32_4x8·T *result = N32_4x8·λ.access(array ,2); + N32_4x8·T *a = N32_4x8·m.access(array ,0); + N32_4x8·T *b = N32_4x8·m.access(array ,1); + N32_4x8·T *result = N32_4x8·m.access(array ,2); - N32_4x8·λ.from_uint32(a ,20); - N32_4x8·λ.from_uint32(b ,22); + N32_4x8·m.from_uint32(a ,20); + N32_4x8·m.from_uint32(b ,22); - if( N32_4x8·λ.add(result ,a ,b) != N32_4x8·Status·ok ) return false; - if( N32_4x8·λ.compare(result ,N32_4x8·λ.access(array ,0)) != N32_4x8·Order_gt ) return false; + if( N32_4x8·m.add(result ,a ,b) != N32_4x8·Status·ok ) return false; + if( N32_4x8·m.compare(result ,N32_4x8·m.access(array ,0)) != N32_4x8·Order_gt ) return false; - if( N32_4x8·λ.subtract(result ,b ,a) != N32_4x8·Status·ok ) return false; - if( N32_4x8·λ.compare(result ,N32_4x8·λ.access(array ,0)) != N32_4x8·Order_lt ) return false; + if( N32_4x8·m.subtract(result ,b ,a) != N32_4x8·Status·ok ) return false; + if( N32_4x8·m.compare(result ,N32_4x8·m.access(array ,0)) != N32_4x8·Order_lt ) return false; - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(3, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(3, NULL); if(!array) return false; - N32_4x8·T *a = N32_4x8·λ.access(array, 0); - N32_4x8·T *b = N32_4x8·λ.access(array, 1); - N32_4x8·T *result = N32_4x8·λ.access(array, 2); + N32_4x8·T *a = N32_4x8·m.access(array, 0); + N32_4x8·T *b = N32_4x8·m.access(array, 1); + N32_4x8·T *result = N32_4x8·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F0); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32_4x8·λ.bit_and(result, a, b); - N32_4x8·λ.from_uint32(a, 0x00000000); - if(N32_4x8·λ.compare(result, a) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.bit_and(result, a, b); + N32_4x8·m.from_uint32(a, 0x00000000); + if(N32_4x8·m.compare(result, a) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32_4x8·λ.bit_or(result, a, b); - N32_4x8·λ.from_uint32(b, 0xFFFFFFFF); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.bit_or(result, a, b); + N32_4x8·m.from_uint32(b, 0xFFFFFFFF); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.bit_complement(result, a); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F0); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.bit_complement(result, a); + N32_4x8·m.from_uint32(b, 0xF0F0F0F0); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.bit_twos_complement(result, a); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F1); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.bit_twos_complement(result, a); + N32_4x8·m.from_uint32(b, 0xF0F0F0F1); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(3, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(3, NULL); if(!array) return false; - N32_4x8·T *a = N32_4x8·λ.access(array, 0); - N32_4x8·T *b = N32_4x8·λ.access(array, 1); - N32_4x8·T *c = N32_4x8·λ.access(array, 2); + N32_4x8·T *a = N32_4x8·m.access(array, 0); + N32_4x8·T *b = N32_4x8·m.access(array, 1); + N32_4x8·T *c = N32_4x8·m.access(array, 2); // First set: a=0, b=42, c=42 - N32_4x8·λ.from_uint32(a, 0); - N32_4x8·λ.from_uint32(b, 42); - N32_4x8·λ.from_uint32(c, 42); + N32_4x8·m.from_uint32(a, 0); + N32_4x8·m.from_uint32(b, 42); + N32_4x8·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32_4x8·λ.eq_zero(a)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(a)){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_4x8·λ.eq_zero(b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(b)){ + N32_4x8·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32_4x8·λ.eq(b, c)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq(b, c)){ + N32_4x8·m.deallocate(array); return false; } // eq(a, b) => false - if(N32_4x8·λ.eq(a, b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq(a, b)){ + N32_4x8·m.deallocate(array); return false; } // compare(a, b) => N32_4x8·Order_lt - if(N32_4x8·λ.compare(a, b) != N32_4x8·Order_lt){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(a, b) != N32_4x8·Order_lt){ + N32_4x8·m.deallocate(array); return false; } // compare(b, a) => N32_4x8·Order_gt - if(N32_4x8·λ.compare(b, a) != N32_4x8·Order_gt){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(b, a) != N32_4x8·Order_gt){ + N32_4x8·m.deallocate(array); return false; } // compare(b, c) => N32_4x8·Order_eq - if(N32_4x8·λ.compare(b, c) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(b, c) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32_4x8·λ.lt(a, b) || !N32_4x8·λ.gt(b, a)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.lt(a, b) || !N32_4x8·m.gt(b, a)){ + N32_4x8·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32_4x8·λ.from_uint32(a, 100); - N32_4x8·λ.from_uint32(b, 50); - if(N32_4x8·λ.compare(a, b) != N32_4x8·Order_gt){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 100); + N32_4x8·m.from_uint32(b, 50); + if(N32_4x8·m.compare(a, b) != N32_4x8·Order_gt){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32_4x8·λ.eq_zero(a)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(a)){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_4x8·λ.eq_zero(b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(b)){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32_4x8·T *array = N32_4x8·λ.allocate_array(3, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(3, NULL); if(!array) return false; - N32_4x8·T *operand = N32_4x8·λ.access(array, 0); - N32_4x8·T *fill = N32_4x8·λ.access(array, 1); - N32_4x8·T *spill = N32_4x8·λ.access(array, 2); + N32_4x8·T *operand = N32_4x8·m.access(array, 0); + N32_4x8·T *fill = N32_4x8·m.access(array, 1); + N32_4x8·T *spill = N32_4x8·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32_4x8·λ.from_uint32(operand, 1); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_left(4, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 1); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_left(4, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·T *temp = N32_4x8·λ.allocate_array(1, NULL); + N32_4x8·T *temp = N32_4x8·m.allocate_array(1, NULL); if(!temp){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 16); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 16); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(N32_4x8·λ.compare(fill, N32_4x8·zero) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(fill, N32_4x8·zero) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(N32_4x8·λ.compare(spill, N32_4x8·zero) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(spill, N32_4x8·zero) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_left(1, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_left(1, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(operand)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(operand)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 1); - if(N32_4x8·λ.compare(spill, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 1); + if(N32_4x8·m.compare(spill, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_right(1, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_right(1, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 0x40000000); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 0x40000000); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(spill)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(spill)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.arithmetic_shift_right(1, operand, spill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.arithmetic_shift_right(1, operand, spill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 0xC0000000); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 0xC0000000); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(spill)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(spill)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return true; } diff --git a/tester/cc/test_N32_4x8_0.cli.c b/tester/cc/test_N32_4x8_0.cli.c index daf0e11..7535a25 100644 --- a/tester/cc/test_N32_4x8_0.cli.c +++ b/tester/cc/test_N32_4x8_0.cli.c @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(1 ,NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(1 ,NULL); if( !array ) return false; // Access elements via access function - N32_4x8·T *a = N32_4x8·λ.access(array ,0); - N32_4x8·T *b = N32_4x8·λ.access(array ,1); + N32_4x8·T *a = N32_4x8·m.access(array ,0); + N32_4x8·T *b = N32_4x8·m.access(array ,1); // Assign value and copy - N32_4x8·λ.from_uint32(a ,42); - N32_4x8·λ.copy(b ,a); + N32_4x8·m.from_uint32(a ,42); + N32_4x8·m.copy(b ,a); - bool success = ( N32_4x8·λ.compare(b ,a) == N32_4x8·Order_eq ); - N32_4x8·λ.deallocate(array); + bool success = ( N32_4x8·m.compare(b ,a) == N32_4x8·Order_eq ); + N32_4x8·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(2 ,NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(2 ,NULL); if( !array ) return false; - N32_4x8·T *a = N32_4x8·λ.access(array ,0); - N32_4x8·T *b = N32_4x8·λ.access(array ,1); - N32_4x8·T *result = N32_4x8·λ.access(array ,2); + N32_4x8·T *a = N32_4x8·m.access(array ,0); + N32_4x8·T *b = N32_4x8·m.access(array ,1); + N32_4x8·T *result = N32_4x8·m.access(array ,2); - N32_4x8·λ.from_uint32(a ,20); - N32_4x8·λ.from_uint32(b ,22); + N32_4x8·m.from_uint32(a ,20); + N32_4x8·m.from_uint32(b ,22); - if( N32_4x8·λ.add(result ,a ,b) != N32_4x8·Status·ok ) return false; - if( N32_4x8·λ.compare(result ,N32_4x8·λ.access(array ,0)) != N32_4x8·Order_gt ) return false; + if( N32_4x8·m.add(result ,a ,b) != N32_4x8·Status·ok ) return false; + if( N32_4x8·m.compare(result ,N32_4x8·m.access(array ,0)) != N32_4x8·Order_gt ) return false; - if( N32_4x8·λ.subtract(result ,b ,a) != N32_4x8·Status·ok ) return false; - if( N32_4x8·λ.compare(result ,N32_4x8·λ.access(array ,0)) != N32_4x8·Order_lt ) return false; + if( N32_4x8·m.subtract(result ,b ,a) != N32_4x8·Status·ok ) return false; + if( N32_4x8·m.compare(result ,N32_4x8·m.access(array ,0)) != N32_4x8·Order_lt ) return false; - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(2, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(2, NULL); if(!array) return false; - N32_4x8·T *a = N32_4x8·λ.access(array, 0); - N32_4x8·T *b = N32_4x8·λ.access(array, 1); - N32_4x8·T *result = N32_4x8·λ.access(array, 2); + N32_4x8·T *a = N32_4x8·m.access(array, 0); + N32_4x8·T *b = N32_4x8·m.access(array, 1); + N32_4x8·T *result = N32_4x8·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F0); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32_4x8·λ.bit_and(result, a, b); - N32_4x8·λ.from_uint32(a, 0x00000000); - if(N32_4x8·λ.compare(result, a) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.bit_and(result, a, b); + N32_4x8·m.from_uint32(a, 0x00000000); + if(N32_4x8·m.compare(result, a) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32_4x8·λ.bit_or(result, a, b); - N32_4x8·λ.from_uint32(b, 0xFFFFFFFF); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.bit_or(result, a, b); + N32_4x8·m.from_uint32(b, 0xFFFFFFFF); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.bit_complement(result, a); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F0); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.bit_complement(result, a); + N32_4x8·m.from_uint32(b, 0xF0F0F0F0); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32_4x8·λ.from_uint32(a, 0x0F0F0F0F); - N32_4x8·λ.bit_twos_complement(result, a); - N32_4x8·λ.from_uint32(b, 0xF0F0F0F1); - if(N32_4x8·λ.compare(result, b) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 0x0F0F0F0F); + N32_4x8·m.bit_twos_complement(result, a); + N32_4x8·m.from_uint32(b, 0xF0F0F0F1); + if(N32_4x8·m.compare(result, b) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32_4x8·T *array = N32_4x8·λ.allocate_array(2, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(2, NULL); if(!array) return false; - N32_4x8·T *a = N32_4x8·λ.access(array, 0); - N32_4x8·T *b = N32_4x8·λ.access(array, 1); - N32_4x8·T *c = N32_4x8·λ.access(array, 2); + N32_4x8·T *a = N32_4x8·m.access(array, 0); + N32_4x8·T *b = N32_4x8·m.access(array, 1); + N32_4x8·T *c = N32_4x8·m.access(array, 2); // First set: a=0, b=42, c=42 - N32_4x8·λ.from_uint32(a, 0); - N32_4x8·λ.from_uint32(b, 42); - N32_4x8·λ.from_uint32(c, 42); + N32_4x8·m.from_uint32(a, 0); + N32_4x8·m.from_uint32(b, 42); + N32_4x8·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32_4x8·λ.eq_zero(a)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(a)){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_4x8·λ.eq_zero(b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(b)){ + N32_4x8·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32_4x8·λ.eq(b, c)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq(b, c)){ + N32_4x8·m.deallocate(array); return false; } // eq(a, b) => false - if(N32_4x8·λ.eq(a, b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq(a, b)){ + N32_4x8·m.deallocate(array); return false; } // compare(a, b) => N32_4x8·Order_lt - if(N32_4x8·λ.compare(a, b) != N32_4x8·Order_lt){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(a, b) != N32_4x8·Order_lt){ + N32_4x8·m.deallocate(array); return false; } // compare(b, a) => N32_4x8·Order_gt - if(N32_4x8·λ.compare(b, a) != N32_4x8·Order_gt){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(b, a) != N32_4x8·Order_gt){ + N32_4x8·m.deallocate(array); return false; } // compare(b, c) => N32_4x8·Order_eq - if(N32_4x8·λ.compare(b, c) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(b, c) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32_4x8·λ.lt(a, b) || !N32_4x8·λ.gt(b, a)){ - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.lt(a, b) || !N32_4x8·m.gt(b, a)){ + N32_4x8·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32_4x8·λ.from_uint32(a, 100); - N32_4x8·λ.from_uint32(b, 50); - if(N32_4x8·λ.compare(a, b) != N32_4x8·Order_gt){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(a, 100); + N32_4x8·m.from_uint32(b, 50); + if(N32_4x8·m.compare(a, b) != N32_4x8·Order_gt){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32_4x8·λ.eq_zero(a)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(a)){ + N32_4x8·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32_4x8·λ.eq_zero(b)){ - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.eq_zero(b)){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32_4x8·T *array = N32_4x8·λ.allocate_array(2, NULL); + N32_4x8·T *array = N32_4x8·m.allocate_array(2, NULL); if(!array) return false; - N32_4x8·T *operand = N32_4x8·λ.access(array, 0); - N32_4x8·T *fill = N32_4x8·λ.access(array, 1); - N32_4x8·T *spill = N32_4x8·λ.access(array, 2); + N32_4x8·T *operand = N32_4x8·m.access(array, 0); + N32_4x8·T *fill = N32_4x8·m.access(array, 1); + N32_4x8·T *spill = N32_4x8·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32_4x8·λ.from_uint32(operand, 1); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_left(4, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 1); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_left(4, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(array); return false; } - N32_4x8·T *temp = N32_4x8·λ.allocate_array(1, NULL); + N32_4x8·T *temp = N32_4x8·m.allocate_array(1, NULL); if(!temp){ - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 16); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 16); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(N32_4x8·λ.compare(fill, N32_4x8·zero) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(fill, N32_4x8·zero) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(N32_4x8·λ.compare(spill, N32_4x8·zero) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(N32_4x8·m.compare(spill, N32_4x8·zero) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_left(1, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_left(1, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(operand)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(operand)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 1); - if(N32_4x8·λ.compare(spill, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 1); + if(N32_4x8·m.compare(spill, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(fill, 0); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.shift_right(1, spill, operand, fill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(fill, 0); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.shift_right(1, spill, operand, fill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 0x40000000); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 0x40000000); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(spill)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(spill)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32_4x8·λ.from_uint32(operand, 0x80000000); - N32_4x8·λ.from_uint32(spill, 0); - if(N32_4x8·λ.arithmetic_shift_right(1, operand, spill) != N32_4x8·Status·ok){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(operand, 0x80000000); + N32_4x8·m.from_uint32(spill, 0); + if(N32_4x8·m.arithmetic_shift_right(1, operand, spill) != N32_4x8·Status·ok){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.from_uint32(temp, 0xC0000000); - if(N32_4x8·λ.compare(operand, temp) != N32_4x8·Order_eq){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.from_uint32(temp, 0xC0000000); + if(N32_4x8·m.compare(operand, temp) != N32_4x8·Order_eq){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - if(!N32_4x8·λ.eq_zero(spill)){ - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + if(!N32_4x8·m.eq_zero(spill)){ + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return false; } - N32_4x8·λ.deallocate(temp); - N32_4x8·λ.deallocate(array); + N32_4x8·m.deallocate(temp); + N32_4x8·m.deallocate(array); return true; } diff --git "a/tester/deprecated\360\237\226\211/test_N32.cli.c" "b/tester/deprecated\360\237\226\211/test_N32.cli.c" index 563711f..25451bb 100644 --- "a/tester/deprecated\360\237\226\211/test_N32.cli.c" +++ "b/tester/deprecated\360\237\226\211/test_N32.cli.c" @@ -81,278 +81,278 @@ int main(int argc ,char **argv){ bool test_copy(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(2 ,NULL); + N32·T *array = N32·m.allocate_array(2 ,NULL); if( !array ) return false; // Access elements via access function - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); // Assign value and copy - N32·λ.from_uint32(a ,42); - N32·λ.copy(b ,a); + N32·m.from_uint32(a ,42); + N32·m.copy(b ,a); - bool success = ( N32·λ.compare(b ,a) == N32·Order_eq ); - N32·λ.deallocate(array); + bool success = ( N32·m.compare(b ,a) == N32·Order_eq ); + N32·m.deallocate(array); return success; } bool test_arithmetic(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3 ,NULL); + N32·T *array = N32·m.allocate_array(3 ,NULL); if( !array ) return false; - N32·T *a = N32·λ.access(array ,0); - N32·T *b = N32·λ.access(array ,1); - N32·T *result = N32·λ.access(array ,2); + N32·T *a = N32·m.access(array ,0); + N32·T *b = N32·m.access(array ,1); + N32·T *result = N32·m.access(array ,2); - N32·λ.from_uint32(a ,20); - N32·λ.from_uint32(b ,22); + N32·m.from_uint32(a ,20); + N32·m.from_uint32(b ,22); - if( N32·λ.add(result ,a ,b) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_gt ) return false; + if( N32·m.add(result ,a ,b) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_gt ) return false; - if( N32·λ.subtract(result ,b ,a) != N32·Status·ok ) return false; - if( N32·λ.compare(result ,N32·λ.access(array ,0)) != N32·Order_lt ) return false; + if( N32·m.subtract(result ,b ,a) != N32·Status·ok ) return false; + if( N32·m.compare(result ,N32·m.access(array ,0)) != N32·Order_lt ) return false; - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_bitwise_operations(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *result = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *result = N32·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.from_uint32(b, 0xF0F0F0F0); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - N32·λ.bit_and(result, a, b); - N32·λ.from_uint32(a, 0x00000000); - if(N32·λ.compare(result, a) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_and(result, a, b); + N32·m.from_uint32(a, 0x00000000); + if(N32·m.compare(result, a) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // Reset a to 0x0F0F0F0F for next tests - N32·λ.from_uint32(a, 0x0F0F0F0F); + N32·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - N32·λ.bit_or(result, a, b); - N32·λ.from_uint32(b, 0xFFFFFFFF); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.bit_or(result, a, b); + N32·m.from_uint32(b, 0xFFFFFFFF); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F0); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F0); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - N32·λ.from_uint32(a, 0x0F0F0F0F); - N32·λ.bit_twos_complement(result, a); - N32·λ.from_uint32(b, 0xF0F0F0F1); - if(N32·λ.compare(result, b) != N32·Order_eq){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 0x0F0F0F0F); + N32·m.bit_twos_complement(result, a); + N32·m.from_uint32(b, 0xF0F0F0F1); + if(N32·m.compare(result, b) != N32·Order_eq){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_comparisons(){ // Allocate memory - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *a = N32·λ.access(array, 0); - N32·T *b = N32·λ.access(array, 1); - N32·T *c = N32·λ.access(array, 2); + N32·T *a = N32·m.access(array, 0); + N32·T *b = N32·m.access(array, 1); + N32·T *c = N32·m.access(array, 2); // First set: a=0, b=42, c=42 - N32·λ.from_uint32(a, 0); - N32·λ.from_uint32(b, 42); - N32·λ.from_uint32(c, 42); + N32·m.from_uint32(a, 0); + N32·m.from_uint32(b, 42); + N32·m.from_uint32(c, 42); // eq_zero(a) => true - if(!N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(!N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } // eq(b, c) => true - if(!N32·λ.eq(b, c)){ - N32·λ.deallocate(array); + if(!N32·m.eq(b, c)){ + N32·m.deallocate(array); return false; } // eq(a, b) => false - if(N32·λ.eq(a, b)){ - N32·λ.deallocate(array); + if(N32·m.eq(a, b)){ + N32·m.deallocate(array); return false; } // compare(a, b) => N32·Order_lt - if(N32·λ.compare(a, b) != N32·Order_lt){ - N32·λ.deallocate(array); + if(N32·m.compare(a, b) != N32·Order_lt){ + N32·m.deallocate(array); return false; } // compare(b, a) => N32·Order_gt - if(N32·λ.compare(b, a) != N32·Order_gt){ - N32·λ.deallocate(array); + if(N32·m.compare(b, a) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // compare(b, c) => N32·Order_eq - if(N32·λ.compare(b, c) != N32·Order_eq){ - N32·λ.deallocate(array); + if(N32·m.compare(b, c) != N32·Order_eq){ + N32·m.deallocate(array); return false; } // lt(a, b) => true, gt(b, a) => true - if(!N32·λ.lt(a, b) || !N32·λ.gt(b, a)){ - N32·λ.deallocate(array); + if(!N32·m.lt(a, b) || !N32·m.gt(b, a)){ + N32·m.deallocate(array); return false; } // Second set: a=100, b=50 - N32·λ.from_uint32(a, 100); - N32·λ.from_uint32(b, 50); - if(N32·λ.compare(a, b) != N32·Order_gt){ - N32·λ.deallocate(array); + N32·m.from_uint32(a, 100); + N32·m.from_uint32(b, 50); + if(N32·m.compare(a, b) != N32·Order_gt){ + N32·m.deallocate(array); return false; } // eq_zero(a) => false - if(N32·λ.eq_zero(a)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(a)){ + N32·m.deallocate(array); return false; } // eq_zero(b) => false - if(N32·λ.eq_zero(b)){ - N32·λ.deallocate(array); + if(N32·m.eq_zero(b)){ + N32·m.deallocate(array); return false; } - N32·λ.deallocate(array); + N32·m.deallocate(array); return true; } bool test_shifts(){ // Allocate memory for operand, fill, spill - N32·T *array = N32·λ.allocate_array(3, NULL); + N32·T *array = N32·m.allocate_array(3, NULL); if(!array) return false; - N32·T *operand = N32·λ.access(array, 0); - N32·T *fill = N32·λ.access(array, 1); - N32·T *spill = N32·λ.access(array, 2); + N32·T *operand = N32·m.access(array, 0); + N32·T *fill = N32·m.access(array, 1); + N32·T *spill = N32·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - N32·λ.from_uint32(operand, 1); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(4, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 1); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(4, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(array); return false; } - N32·T *temp = N32·λ.allocate_array(1, NULL); + N32·T *temp = N32·m.allocate_array(1, NULL); if(!temp){ - N32·λ.deallocate(array); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 16); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 16); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(fill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(fill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(N32·λ.compare(spill, N32·zero) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(N32·m.compare(spill, N32·zero) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_left(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_left(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(operand)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(operand)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 1); - if(N32·λ.compare(spill, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 1); + if(N32·m.compare(spill, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(fill, 0); - N32·λ.from_uint32(spill, 0); - if(N32·λ.shift_right(1, spill, operand, fill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(fill, 0); + N32·m.from_uint32(spill, 0); + if(N32·m.shift_right(1, spill, operand, fill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0x40000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0x40000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - N32·λ.from_uint32(operand, 0x80000000); - N32·λ.from_uint32(spill, 0); - if(N32·λ.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(operand, 0x80000000); + N32·m.from_uint32(spill, 0); + if(N32·m.arithmetic_shift_right(1, operand, spill) != N32·Status·ok){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.from_uint32(temp, 0xC0000000); - if(N32·λ.compare(operand, temp) != N32·Order_eq){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.from_uint32(temp, 0xC0000000); + if(N32·m.compare(operand, temp) != N32·Order_eq){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - if(!N32·λ.eq_zero(spill)){ - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + if(!N32·m.eq_zero(spill)){ + N32·m.deallocate(temp); + N32·m.deallocate(array); return false; } - N32·λ.deallocate(temp); - N32·λ.deallocate(array); + N32·m.deallocate(temp); + N32·m.deallocate(array); return true; } diff --git a/tester/python/template_test_N32_0.py b/tester/python/template_test_N32_0.py index 5d07a5c..a9734d6 100644 --- a/tester/python/template_test_N32_0.py +++ b/tester/python/template_test_N32_0.py @@ -97,278 +97,278 @@ int main(int argc ,char **argv){{ bool test_copy(){{ // Allocate memory - {NS}·T *array = {NS}·λ.allocate_array(1 ,NULL); + {NS}·T *array = {NS}·m.allocate_array(1 ,NULL); if( !array ) return false; // Access elements via access function - {NS}·T *a = {NS}·λ.access(array ,0); - {NS}·T *b = {NS}·λ.access(array ,1); + {NS}·T *a = {NS}·m.access(array ,0); + {NS}·T *b = {NS}·m.access(array ,1); // Assign value and copy - {NS}·λ.from_uint32(a ,42); - {NS}·λ.copy(b ,a); + {NS}·m.from_uint32(a ,42); + {NS}·m.copy(b ,a); - bool success = ( {NS}·λ.compare(b ,a) == {NS}·Order_eq ); - {NS}·λ.deallocate(array); + bool success = ( {NS}·m.compare(b ,a) == {NS}·Order_eq ); + {NS}·m.deallocate(array); return success; }} bool test_arithmetic(){{ // Allocate memory - {NS}·T *array = {NS}·λ.allocate_array(2 ,NULL); + {NS}·T *array = {NS}·m.allocate_array(2 ,NULL); if( !array ) return false; - {NS}·T *a = {NS}·λ.access(array ,0); - {NS}·T *b = {NS}·λ.access(array ,1); - {NS}·T *result = {NS}·λ.access(array ,2); + {NS}·T *a = {NS}·m.access(array ,0); + {NS}·T *b = {NS}·m.access(array ,1); + {NS}·T *result = {NS}·m.access(array ,2); - {NS}·λ.from_uint32(a ,20); - {NS}·λ.from_uint32(b ,22); + {NS}·m.from_uint32(a ,20); + {NS}·m.from_uint32(b ,22); - if( {NS}·λ.add(result ,a ,b) != {NS}·Status·ok ) return false; - if( {NS}·λ.compare(result ,{NS}·λ.access(array ,0)) != {NS}·Order_gt ) return false; + if( {NS}·m.add(result ,a ,b) != {NS}·Status·ok ) return false; + if( {NS}·m.compare(result ,{NS}·m.access(array ,0)) != {NS}·Order_gt ) return false; - if( {NS}·λ.subtract(result ,b ,a) != {NS}·Status·ok ) return false; - if( {NS}·λ.compare(result ,{NS}·λ.access(array ,0)) != {NS}·Order_lt ) return false; + if( {NS}·m.subtract(result ,b ,a) != {NS}·Status·ok ) return false; + if( {NS}·m.compare(result ,{NS}·m.access(array ,0)) != {NS}·Order_lt ) return false; - {NS}·λ.deallocate(array); + {NS}·m.deallocate(array); return true; }} bool test_bitwise_operations(){{ // Allocate memory - {NS}·T *array = {NS}·λ.allocate_array(2, NULL); + {NS}·T *array = {NS}·m.allocate_array(2, NULL); if(!array) return false; - {NS}·T *a = {NS}·λ.access(array, 0); - {NS}·T *b = {NS}·λ.access(array, 1); - {NS}·T *result = {NS}·λ.access(array, 2); + {NS}·T *a = {NS}·m.access(array, 0); + {NS}·T *b = {NS}·m.access(array, 1); + {NS}·T *result = {NS}·m.access(array, 2); // a = 0x0F0F0F0F, b = 0xF0F0F0F0 - {NS}·λ.from_uint32(a, 0x0F0F0F0F); - {NS}·λ.from_uint32(b, 0xF0F0F0F0); + {NS}·m.from_uint32(a, 0x0F0F0F0F); + {NS}·m.from_uint32(b, 0xF0F0F0F0); // bit_and => expect 0x00000000 - {NS}·λ.bit_and(result, a, b); - {NS}·λ.from_uint32(a, 0x00000000); - if({NS}·λ.compare(result, a) != {NS}·Order_eq){{ - {NS}·λ.deallocate(array); + {NS}·m.bit_and(result, a, b); + {NS}·m.from_uint32(a, 0x00000000); + if({NS}·m.compare(result, a) != {NS}·Order_eq){{ + {NS}·m.deallocate(array); return false; }} // Reset a to 0x0F0F0F0F for next tests - {NS}·λ.from_uint32(a, 0x0F0F0F0F); + {NS}·m.from_uint32(a, 0x0F0F0F0F); // bit_or => expect 0xFFFFFFFF - {NS}·λ.bit_or(result, a, b); - {NS}·λ.from_uint32(b, 0xFFFFFFFF); - if({NS}·λ.compare(result, b) != {NS}·Order_eq){{ - {NS}·λ.deallocate(array); + {NS}·m.bit_or(result, a, b); + {NS}·m.from_uint32(b, 0xFFFFFFFF); + if({NS}·m.compare(result, b) != {NS}·Order_eq){{ + {NS}·m.deallocate(array); return false; }} // bit_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F0 - {NS}·λ.from_uint32(a, 0x0F0F0F0F); - {NS}·λ.bit_complement(result, a); - {NS}·λ.from_uint32(b, 0xF0F0F0F0); - if({NS}·λ.compare(result, b) != {NS}·Order_eq){{ - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(a, 0x0F0F0F0F); + {NS}·m.bit_complement(result, a); + {NS}·m.from_uint32(b, 0xF0F0F0F0); + if({NS}·m.compare(result, b) != {NS}·Order_eq){{ + {NS}·m.deallocate(array); return false; }} // bit_twos_complement(a=0x0F0F0F0F) => expect 0xF0F0F0F1 - {NS}·λ.from_uint32(a, 0x0F0F0F0F); - {NS}·λ.bit_twos_complement(result, a); - {NS}·λ.from_uint32(b, 0xF0F0F0F1); - if({NS}·λ.compare(result, b) != {NS}·Order_eq){{ - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(a, 0x0F0F0F0F); + {NS}·m.bit_twos_complement(result, a); + {NS}·m.from_uint32(b, 0xF0F0F0F1); + if({NS}·m.compare(result, b) != {NS}·Order_eq){{ + {NS}·m.deallocate(array); return false; }} - {NS}·λ.deallocate(array); + {NS}·m.deallocate(array); return true; }} bool test_comparisons(){{ // Allocate memory - {NS}·T *array = {NS}·λ.allocate_array(2, NULL); + {NS}·T *array = {NS}·m.allocate_array(2, NULL); if(!array) return false; - {NS}·T *a = {NS}·λ.access(array, 0); - {NS}·T *b = {NS}·λ.access(array, 1); - {NS}·T *c = {NS}·λ.access(array, 2); + {NS}·T *a = {NS}·m.access(array, 0); + {NS}·T *b = {NS}·m.access(array, 1); + {NS}·T *c = {NS}·m.access(array, 2); // First set: a=0, b=42, c=42 - {NS}·λ.from_uint32(a, 0); - {NS}·λ.from_uint32(b, 42); - {NS}·λ.from_uint32(c, 42); + {NS}·m.from_uint32(a, 0); + {NS}·m.from_uint32(b, 42); + {NS}·m.from_uint32(c, 42); // eq_zero(a) => true - if(!{NS}·λ.eq_zero(a)){{ - {NS}·λ.deallocate(array); + if(!{NS}·m.eq_zero(a)){{ + {NS}·m.deallocate(array); return false; }} // eq_zero(b) => false - if({NS}·λ.eq_zero(b)){{ - {NS}·λ.deallocate(array); + if({NS}·m.eq_zero(b)){{ + {NS}·m.deallocate(array); return false; }} // eq(b, c) => true - if(!{NS}·λ.eq(b, c)){{ - {NS}·λ.deallocate(array); + if(!{NS}·m.eq(b, c)){{ + {NS}·m.deallocate(array); return false; }} // eq(a, b) => false - if({NS}·λ.eq(a, b)){{ - {NS}·λ.deallocate(array); + if({NS}·m.eq(a, b)){{ + {NS}·m.deallocate(array); return false; }} // compare(a, b) => {NS}·Order_lt - if({NS}·λ.compare(a, b) != {NS}·Order_lt){{ - {NS}·λ.deallocate(array); + if({NS}·m.compare(a, b) != {NS}·Order_lt){{ + {NS}·m.deallocate(array); return false; }} // compare(b, a) => {NS}·Order_gt - if({NS}·λ.compare(b, a) != {NS}·Order_gt){{ - {NS}·λ.deallocate(array); + if({NS}·m.compare(b, a) != {NS}·Order_gt){{ + {NS}·m.deallocate(array); return false; }} // compare(b, c) => {NS}·Order_eq - if({NS}·λ.compare(b, c) != {NS}·Order_eq){{ - {NS}·λ.deallocate(array); + if({NS}·m.compare(b, c) != {NS}·Order_eq){{ + {NS}·m.deallocate(array); return false; }} // lt(a, b) => true, gt(b, a) => true - if(!{NS}·λ.lt(a, b) || !{NS}·λ.gt(b, a)){{ - {NS}·λ.deallocate(array); + if(!{NS}·m.lt(a, b) || !{NS}·m.gt(b, a)){{ + {NS}·m.deallocate(array); return false; }} // Second set: a=100, b=50 - {NS}·λ.from_uint32(a, 100); - {NS}·λ.from_uint32(b, 50); - if({NS}·λ.compare(a, b) != {NS}·Order_gt){{ - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(a, 100); + {NS}·m.from_uint32(b, 50); + if({NS}·m.compare(a, b) != {NS}·Order_gt){{ + {NS}·m.deallocate(array); return false; }} // eq_zero(a) => false - if({NS}·λ.eq_zero(a)){{ - {NS}·λ.deallocate(array); + if({NS}·m.eq_zero(a)){{ + {NS}·m.deallocate(array); return false; }} // eq_zero(b) => false - if({NS}·λ.eq_zero(b)){{ - {NS}·λ.deallocate(array); + if({NS}·m.eq_zero(b)){{ + {NS}·m.deallocate(array); return false; }} - {NS}·λ.deallocate(array); + {NS}·m.deallocate(array); return true; }} bool test_shifts(){{ // Allocate memory for operand, fill, spill - {NS}·T *array = {NS}·λ.allocate_array(2, NULL); + {NS}·T *array = {NS}·m.allocate_array(2, NULL); if(!array) return false; - {NS}·T *operand = {NS}·λ.access(array, 0); - {NS}·T *fill = {NS}·λ.access(array, 1); - {NS}·T *spill = {NS}·λ.access(array, 2); + {NS}·T *operand = {NS}·m.access(array, 0); + {NS}·T *fill = {NS}·m.access(array, 1); + {NS}·T *spill = {NS}·m.access(array, 2); // Subtest A: shift_left(4) with operand=1 => expect operand=16, fill=0, spill=0 - {NS}·λ.from_uint32(operand, 1); - {NS}·λ.from_uint32(fill, 0); - {NS}·λ.from_uint32(spill, 0); - if({NS}·λ.shift_left(4, spill, operand, fill) != {NS}·Status·ok){{ - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(operand, 1); + {NS}·m.from_uint32(fill, 0); + {NS}·m.from_uint32(spill, 0); + if({NS}·m.shift_left(4, spill, operand, fill) != {NS}·Status·ok){{ + {NS}·m.deallocate(array); return false; }} - {NS}·T *temp = {NS}·λ.allocate_array(1, NULL); + {NS}·T *temp = {NS}·m.allocate_array(1, NULL); if(!temp){{ - {NS}·λ.deallocate(array); + {NS}·m.deallocate(array); return false; }} - {NS}·λ.from_uint32(temp, 16); - if({NS}·λ.compare(operand, temp) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(temp, 16); + if({NS}·m.compare(operand, temp) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - if({NS}·λ.compare(fill, {NS}·zero) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + if({NS}·m.compare(fill, {NS}·zero) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - if({NS}·λ.compare(spill, {NS}·zero) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + if({NS}·m.compare(spill, {NS}·zero) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} // Subtest B: shift_left(1) with operand=0x80000000 => expect operand=0, spill=1 - {NS}·λ.from_uint32(operand, 0x80000000); - {NS}·λ.from_uint32(fill, 0); - {NS}·λ.from_uint32(spill, 0); - if({NS}·λ.shift_left(1, spill, operand, fill) != {NS}·Status·ok){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(operand, 0x80000000); + {NS}·m.from_uint32(fill, 0); + {NS}·m.from_uint32(spill, 0); + if({NS}·m.shift_left(1, spill, operand, fill) != {NS}·Status·ok){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - if(!{NS}·λ.eq_zero(operand)){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + if(!{NS}·m.eq_zero(operand)){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - {NS}·λ.from_uint32(temp, 1); - if({NS}·λ.compare(spill, temp) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(temp, 1); + if({NS}·m.compare(spill, temp) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} // Subtest C: shift_right(1) with operand=0x80000000 => expect operand=0x40000000, spill=0 - {NS}·λ.from_uint32(operand, 0x80000000); - {NS}·λ.from_uint32(fill, 0); - {NS}·λ.from_uint32(spill, 0); - if({NS}·λ.shift_right(1, spill, operand, fill) != {NS}·Status·ok){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(operand, 0x80000000); + {NS}·m.from_uint32(fill, 0); + {NS}·m.from_uint32(spill, 0); + if({NS}·m.shift_right(1, spill, operand, fill) != {NS}·Status·ok){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - {NS}·λ.from_uint32(temp, 0x40000000); - if({NS}·λ.compare(operand, temp) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(temp, 0x40000000); + if({NS}·m.compare(operand, temp) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - if(!{NS}·λ.eq_zero(spill)){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + if(!{NS}·m.eq_zero(spill)){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} // Subtest D: arithmetic_shift_right(1) with operand=0x80000000 => expect operand=0xC0000000, spill=0 - {NS}·λ.from_uint32(operand, 0x80000000); - {NS}·λ.from_uint32(spill, 0); - if({NS}·λ.arithmetic_shift_right(1, operand, spill) != {NS}·Status·ok){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(operand, 0x80000000); + {NS}·m.from_uint32(spill, 0); + if({NS}·m.arithmetic_shift_right(1, operand, spill) != {NS}·Status·ok){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - {NS}·λ.from_uint32(temp, 0xC0000000); - if({NS}·λ.compare(operand, temp) != {NS}·Order_eq){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.from_uint32(temp, 0xC0000000); + if({NS}·m.compare(operand, temp) != {NS}·Order_eq){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - if(!{NS}·λ.eq_zero(spill)){{ - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + if(!{NS}·m.eq_zero(spill)){{ + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return false; }} - {NS}·λ.deallocate(temp); - {NS}·λ.deallocate(array); + {NS}·m.deallocate(temp); + {NS}·m.deallocate(array); return true; }}