-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconst_scalar_mult.h
More file actions
36 lines (30 loc) · 992 Bytes
/
const_scalar_mult.h
File metadata and controls
36 lines (30 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef ATOM_CONST_SCALAR_MULT_H
#define ATOM_CONST_SCALAR_MULT_H
#include "bivariate_full_dom.h"
#include "common.h"
/* Constant scalar multiplication: a * f(x) where a is a constant double */
static PyObject *py_make_const_scalar_mult(PyObject *self, PyObject *args)
{
PyObject *child_capsule;
double a;
if (!PyArg_ParseTuple(args, "Od", &child_capsule, &a))
{
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_const_scalar_mult(a, child);
if (!node)
{
PyErr_SetString(PyExc_RuntimeError,
"failed to create const_scalar_mult node");
return NULL;
}
expr_retain(node); /* Capsule owns a reference */
return PyCapsule_New(node, EXPR_CAPSULE_NAME, expr_capsule_destructor);
}
#endif /* ATOM_CONST_SCALAR_MULT_H */