Skip to content

Updating Quaddtype #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0a36a9d
added readme
SwayamInSync Aug 25, 2024
d56e592
renaming module and adding initial longdouble backend support
SwayamInSync Aug 31, 2024
8408227
added ld backend support to casting
SwayamInSync Aug 31, 2024
a652985
added multi backend support to scalar operations
SwayamInSync Sep 1, 2024
7fd8da6
failing: londouble with different dtype
SwayamInSync Sep 1, 2024
d664a59
added backend parameter in default descriptor
SwayamInSync Sep 1, 2024
7a85fbf
removed todo comment: umath.cpp
SwayamInSync Sep 1, 2024
e8cba6a
temporary solution to handle both backends
SwayamInSync Sep 5, 2024
01e9b7e
post-cleaning
SwayamInSync Sep 6, 2024
22982a4
adding dragon4
SwayamInSync Sep 6, 2024
7b43f3b
fixing reduction redorderable issue
SwayamInSync Sep 7, 2024
04480ce
np.dot WIP
SwayamInSync Sep 7, 2024
755e2cd
fixing base
SwayamInSync Sep 10, 2024
0ac5464
added more unary func
SwayamInSync Sep 16, 2024
25dd6b3
removing testing files
SwayamInSync Sep 16, 2024
b719ba4
fixing import statements
SwayamInSync Sep 16, 2024
fe6cabc
removed unnecessary prints
SwayamInSync Sep 16, 2024
0fba040
added separate aligned and unaligned ufunc support
SwayamInSync Sep 17, 2024
4f0a604
WIP
SwayamInSync Sep 17, 2024
707d5d6
fixed longdouble comparison casting issue
SwayamInSync Sep 18, 2024
0a75b91
aligned and unaligned comparison loops
SwayamInSync Sep 18, 2024
0052e16
Creating Quad with Quad
SwayamInSync Sep 19, 2024
082b64b
exposing constants
SwayamInSync Sep 19, 2024
e53edba
resolved reviews
SwayamInSync Sep 20, 2024
bbc99a6
fixing constant error
SwayamInSync Sep 20, 2024
012e90f
Merge branch 'dragon4' into constants
SwayamInSync Sep 20, 2024
41ca3f9
added 128-bit common constants
SwayamInSync Sep 20, 2024
2fd9cad
refactoring
SwayamInSync Sep 20, 2024
672be17
added aligned and unaligned casting loops
SwayamInSync Sep 20, 2024
600b2c8
fixed inter-backend cast segment fault
SwayamInSync Sep 20, 2024
77e25b6
made ufunc return actual value instead of 0
SwayamInSync Sep 21, 2024
87a7891
updated meson.build
SwayamInSync Sep 21, 2024
1a6618a
missed the comma :)
SwayamInSync Sep 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions quaddtype/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Numpy-QuadDType

## Installation

```
pip install numpy==2.1.0
pip install -i https://test.pypi.org/simple/ quaddtype
```

## Usage

```python
import numpy as np
from numpy_quaddtype import QuadPrecDType, QuadPrecision

# using sleef backend (default)
np.array([1,2,3], dtype=QuadPrecDType())
np.array([1,2,3], dtype=QuadPrecDType("sleef"))

# using longdouble backend
np.array([1,2,3], dtype=QuadPrecDType("longdouble"))
```
37 changes: 20 additions & 17 deletions quaddtype/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true'])
project('numpy_quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true'])

py_mod = import('python')
py = py_mod.find_installation()
Expand All @@ -19,30 +19,33 @@ incdir_numpy = run_command(py,
includes = include_directories(
[
incdir_numpy,
'quaddtype/src',
'numpy_quaddtype/src',
]
)

srcs = [
'quaddtype/src/casts.h',
'quaddtype/src/casts.cpp',
'quaddtype/src/scalar.h',
'quaddtype/src/scalar.c',
'quaddtype/src/dtype.h',
'quaddtype/src/dtype.c',
'quaddtype/src/quaddtype_main.c',
'quaddtype/src/scalar_ops.h',
'quaddtype/src/scalar_ops.cpp',
'quaddtype/src/ops.hpp',
'quaddtype/src/umath.h',
'quaddtype/src/umath.cpp'
'numpy_quaddtype/src/quad_common.h',
'numpy_quaddtype/src/casts.h',
'numpy_quaddtype/src/casts.cpp',
'numpy_quaddtype/src/scalar.h',
'numpy_quaddtype/src/scalar.c',
'numpy_quaddtype/src/dtype.h',
'numpy_quaddtype/src/dtype.c',
'numpy_quaddtype/src/quaddtype_main.c',
'numpy_quaddtype/src/scalar_ops.h',
'numpy_quaddtype/src/scalar_ops.cpp',
'numpy_quaddtype/src/ops.hpp',
'numpy_quaddtype/src/umath.h',
'numpy_quaddtype/src/umath.cpp',
'numpy_quaddtype/src/dragon4.h',
'numpy_quaddtype/src/dragon4.c'
]

py.install_sources(
[
'quaddtype/__init__.py',
'numpy_quaddtype/__init__.py',
],
subdir: 'quaddtype',
subdir: 'numpy_quaddtype',
pure: false
)

Expand All @@ -51,6 +54,6 @@ srcs,
c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'],
dependencies: [sleef_dep, sleefquad_dep],
install: true,
subdir: 'quaddtype',
subdir: 'numpy_quaddtype',
include_directories: includes
)
34 changes: 34 additions & 0 deletions quaddtype/numpy_quaddtype/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from ._quaddtype_main import (
QuadPrecision,
QuadPrecDType,
is_longdouble_128,
get_sleef_constant
)

__all__ = [
'QuadPrecision', 'QuadPrecDType', 'SleefQuadPrecision', 'LongDoubleQuadPrecision',
'SleefQuadPrecDType', 'LongDoubleQuadPrecDType', 'is_longdouble_128', 'pi', 'e',
'log2e', 'log10e', 'ln2', 'ln10', 'max_value', 'min_value', 'epsilon'
]

def SleefQuadPrecision(value):
return QuadPrecision(value, backend='sleef')

def LongDoubleQuadPrecision(value):
return QuadPrecision(value, backend='longdouble')

def SleefQuadPrecDType():
return QuadPrecDType(backend='sleef')

def LongDoubleQuadPrecDType():
return QuadPrecDType(backend='longdouble')

pi = get_sleef_constant("pi")
e = get_sleef_constant("e")
log2e = get_sleef_constant("log2e")
log10e = get_sleef_constant("log10e")
ln2 = get_sleef_constant("ln2")
ln10 = get_sleef_constant("ln10")
max_value = get_sleef_constant("quad_max")
min_value = get_sleef_constant("quad_min")
epsilon = get_sleef_constant("epsilon")
Loading
Loading