Skip to content

Commit

Permalink
Merge pull request #102 from SwayamInSync/dragon4
Browse files Browse the repository at this point in the history
Updating Quaddtype
  • Loading branch information
ngoldbaum authored Sep 22, 2024
2 parents cf6cf91 + 1a6618a commit 79e5ea2
Show file tree
Hide file tree
Showing 31 changed files with 5,201 additions and 1,914 deletions.
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

0 comments on commit 79e5ea2

Please sign in to comment.