diff --git a/SparseDiffEngine b/SparseDiffEngine index 3fe6f5b..7e7875d 160000 --- a/SparseDiffEngine +++ b/SparseDiffEngine @@ -1 +1 @@ -Subproject commit 3fe6f5be79be369c8249442e242094ae540d8efc +Subproject commit 7e7875df92f92b0ef2ecd431d77174768aa22e01 diff --git a/pyproject.toml b/pyproject.toml index 4d2c80b..bcd5837 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "sparsediffpy" -version = "0.1.4" +version = "0.1.5" description = "Python bindings for SparseDiffEngine automatic differentiation" requires-python = ">=3.11" dependencies = ["numpy >= 2.0.0"] diff --git a/sparsediffpy/_bindings/atoms/normal_cdf.h b/sparsediffpy/_bindings/atoms/normal_cdf.h new file mode 100644 index 0000000..f45abb8 --- /dev/null +++ b/sparsediffpy/_bindings/atoms/normal_cdf.h @@ -0,0 +1,30 @@ +#ifndef ATOM_NORMAL_CDF_H +#define ATOM_NORMAL_CDF_H + +#include "common.h" + +static PyObject *py_make_normal_cdf(PyObject *self, PyObject *args) +{ + PyObject *child_capsule; + if (!PyArg_ParseTuple(args, "O", &child_capsule)) + { + return NULL; + } + expr *child = (expr *) PyCapsule_GetPointer(child_capsule, EXPR_CAPSULE_NAME); + if (!child) + { + PyErr_SetString(PyExc_ValueError, "invalid child capsule"); + return NULL; + } + + expr *node = new_normal_cdf(child); + if (!node) + { + PyErr_SetString(PyExc_RuntimeError, "failed to create normal_cdf node"); + return NULL; + } + expr_retain(node); /* Capsule owns a reference */ + return PyCapsule_New(node, EXPR_CAPSULE_NAME, expr_capsule_destructor); +} + +#endif /* ATOM_NORMAL_CDF_H */ diff --git a/sparsediffpy/_bindings/bindings.c b/sparsediffpy/_bindings/bindings.c index 9f3c4b0..cbda8e0 100644 --- a/sparsediffpy/_bindings/bindings.c +++ b/sparsediffpy/_bindings/bindings.c @@ -25,6 +25,7 @@ #include "atoms/matmul.h" #include "atoms/multiply.h" #include "atoms/neg.h" +#include "atoms/normal_cdf.h" #include "atoms/power.h" #include "atoms/prod.h" #include "atoms/prod_axis_one.h" @@ -83,6 +84,7 @@ static PyMethodDef DNLPMethods[] = { "e2, ...], n_vars))"}, {"make_sum", py_make_sum, METH_VARARGS, "Create sum node"}, {"make_neg", py_make_neg, METH_VARARGS, "Create neg node"}, + {"make_normal_cdf", py_make_normal_cdf, METH_VARARGS, "Create normal_cdf node"}, {"make_promote", py_make_promote, METH_VARARGS, "Create promote node"}, {"make_multiply", py_make_multiply, METH_VARARGS, "Create elementwise multiply node"},