-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add bitwise operators * add build to requirements
- Loading branch information
Showing
17 changed files
with
659 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
/* | ||
* This file is part of the micropython-ulab project, | ||
* | ||
* https://github.com/v923z/micropython-ulab | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2023 Zoltán Vörös | ||
*/ | ||
|
||
#ifndef _BITWISE_ | ||
#define _BITWISE_ | ||
|
||
#include "../ulab.h" | ||
#include "../ndarray.h" | ||
|
||
enum BITWISE_FUNCTION_TYPE { | ||
BITWISE_AND, | ||
BITWISE_OR, | ||
BITWISE_XOR, | ||
BITWISE_LEFT_SHIFT, | ||
BITWISE_RIGHT_SHIFT, | ||
}; | ||
|
||
MP_DECLARE_CONST_FUN_OBJ_2(bitwise_bitwise_and_obj); | ||
MP_DECLARE_CONST_FUN_OBJ_2(bitwise_bitwise_or_obj); | ||
MP_DECLARE_CONST_FUN_OBJ_2(bitwise_bitwise_xor_obj); | ||
MP_DECLARE_CONST_FUN_OBJ_2(left_shift_obj); | ||
MP_DECLARE_CONST_FUN_OBJ_2(right_shift_obj); | ||
|
||
#endif /* _BITWISE_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
Fri, 12 May 2023 | ||
|
||
version 6.3.0 | ||
|
||
add bitwise operators | ||
|
||
Wed, 17 May 2023 | ||
|
||
version 6.1.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from ulab import numpy as np | ||
except: | ||
import numpy as np | ||
|
||
|
||
dtypes = (np.uint8, np.int8, np.uint16, np.int16) | ||
|
||
for dtype1 in dtypes: | ||
x1 = np.array(range(5), dtype=dtype1) | ||
for dtype2 in dtypes: | ||
x2 = np.array(range(5, 0, -1), dtype=dtype2) | ||
|
||
print(np.bitwise_and(x1, x2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
array([0, 0, 2, 2, 0], dtype=uint8) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=uint16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int8) | ||
array([0, 0, 2, 2, 0], dtype=uint16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=uint16) | ||
array([0, 0, 2, 2, 0], dtype=uint16) | ||
array([0, 0, 2, 2, 0], dtype=uint16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int16) | ||
array([0, 0, 2, 2, 0], dtype=int16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from ulab import numpy as np | ||
except: | ||
import numpy as np | ||
|
||
|
||
dtypes = (np.uint8, np.int8, np.uint16, np.int16) | ||
|
||
for dtype1 in dtypes: | ||
x1 = np.array(range(5), dtype=dtype1) | ||
for dtype2 in dtypes: | ||
x2 = np.array(range(5, 0, -1), dtype=dtype2) | ||
|
||
print(np.bitwise_or(x1, x2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
array([5, 5, 3, 3, 5], dtype=uint8) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=uint16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int8) | ||
array([5, 5, 3, 3, 5], dtype=uint16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=uint16) | ||
array([5, 5, 3, 3, 5], dtype=uint16) | ||
array([5, 5, 3, 3, 5], dtype=uint16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int16) | ||
array([5, 5, 3, 3, 5], dtype=int16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from ulab import numpy as np | ||
except: | ||
import numpy as np | ||
|
||
|
||
dtypes = (np.uint8, np.int8, np.uint16, np.int16) | ||
|
||
for dtype1 in dtypes: | ||
x1 = np.array(range(5), dtype=dtype1) | ||
for dtype2 in dtypes: | ||
x2 = np.array(range(5, 0, -1), dtype=dtype2) | ||
|
||
print(np.bitwise_xor(x1, x2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
array([5, 5, 1, 1, 5], dtype=uint8) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=uint16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int8) | ||
array([5, 5, 1, 1, 5], dtype=uint16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=uint16) | ||
array([5, 5, 1, 1, 5], dtype=uint16) | ||
array([5, 5, 1, 1, 5], dtype=uint16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int16) | ||
array([5, 5, 1, 1, 5], dtype=int16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from ulab import numpy as np | ||
except: | ||
import numpy as np | ||
|
||
|
||
dtypes = (np.uint8, np.int8, np.uint16, np.int16) | ||
|
||
for dtype1 in dtypes: | ||
x1 = np.array(range(5), dtype=dtype1) | ||
for dtype2 in dtypes: | ||
x2 = np.array(range(5, 0, -1), dtype=dtype2) | ||
|
||
print(np.left_shift(x1, x2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
array([0, 16, 16, 12, 8], dtype=uint8) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=uint16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int8) | ||
array([0, 16, 16, 12, 8], dtype=uint16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=uint16) | ||
array([0, 16, 16, 12, 8], dtype=int8) | ||
array([0, 16, 16, 12, 8], dtype=uint16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int16) | ||
array([0, 16, 16, 12, 8], dtype=int16) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
try: | ||
from ulab import numpy as np | ||
except: | ||
import numpy as np | ||
|
||
|
||
dtypes = (np.uint8, np.int8, np.uint16, np.int16) | ||
|
||
for dtype1 in dtypes: | ||
x1 = np.array(range(5), dtype=dtype1) | ||
for dtype2 in dtypes: | ||
x2 = np.array(range(5, 0, -1), dtype=dtype2) | ||
|
||
print(np.right_shift(x1, x2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
array([0, 0, 0, 0, 2], dtype=uint8) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=uint16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int8) | ||
array([0, 0, 0, 0, 2], dtype=uint16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=uint16) | ||
array([0, 0, 0, 0, 2], dtype=int8) | ||
array([0, 0, 0, 0, 2], dtype=uint16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int16) | ||
array([0, 0, 0, 0, 2], dtype=int16) |